Skip to content

Commit e52ce6c

Browse files
MaxKellermannnikic
authored andcommitted
apc_iterator: use size_t instead of zend_long/int where appropriate
More -Wsign-compare fixes.
1 parent 84eab15 commit e52ce6c

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

apc_iterator.c

+11-12
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ static int apc_iterator_check_expiry(apc_cache_t* cache, apc_cache_entry_t *entr
210210
/* }}} */
211211

212212
/* {{{ apc_iterator_fetch_active */
213-
static int apc_iterator_fetch_active(apc_iterator_t *iterator) {
214-
int count = 0;
213+
static size_t apc_iterator_fetch_active(apc_iterator_t *iterator) {
214+
size_t count = 0;
215215
apc_iterator_item_t *item;
216216
time_t t = apc_time();
217217

@@ -250,8 +250,8 @@ static int apc_iterator_fetch_active(apc_iterator_t *iterator) {
250250
/* }}} */
251251

252252
/* {{{ apc_iterator_fetch_deleted */
253-
static int apc_iterator_fetch_deleted(apc_iterator_t *iterator) {
254-
int count = 0;
253+
static size_t apc_iterator_fetch_deleted(apc_iterator_t *iterator) {
254+
size_t count = 0;
255255
apc_iterator_item_t *item;
256256

257257
if (!apc_cache_rlock(apc_user_cache)) {
@@ -288,14 +288,13 @@ static int apc_iterator_fetch_deleted(apc_iterator_t *iterator) {
288288
/* {{{ apc_iterator_totals */
289289
static void apc_iterator_totals(apc_iterator_t *iterator) {
290290
time_t t = apc_time();
291-
int i;
292291

293292
if (!apc_cache_rlock(apc_user_cache)) {
294293
return;
295294
}
296295

297296
php_apc_try {
298-
for (i=0; i < apc_user_cache->nslots; i++) {
297+
for (size_t i=0; i < apc_user_cache->nslots; i++) {
299298
apc_cache_entry_t *entry = apc_user_cache->slots[i];
300299
while (entry) {
301300
if (apc_iterator_check_expiry(apc_user_cache, entry, t)) {
@@ -315,18 +314,13 @@ static void apc_iterator_totals(apc_iterator_t *iterator) {
315314
}
316315
/* }}} */
317316

318-
void apc_iterator_obj_init(apc_iterator_t *iterator, zval *search, zend_long format, zend_long chunk_size, zend_long list)
317+
void apc_iterator_obj_init(apc_iterator_t *iterator, zval *search, zend_long format, size_t chunk_size, zend_long list)
319318
{
320319
if (!APCG(enabled)) {
321320
zend_throw_error(NULL, "APC must be enabled to use APCUIterator");
322321
return;
323322
}
324323

325-
if (chunk_size < 0) {
326-
apc_error("APCUIterator chunk size must be 0 or greater");
327-
return;
328-
}
329-
330324
if (format > APC_ITER_ALL) {
331325
apc_error("APCUIterator format is invalid");
332326
return;
@@ -384,6 +378,11 @@ PHP_METHOD(APCUIterator, __construct) {
384378
return;
385379
}
386380

381+
if (chunk_size < 0) {
382+
apc_error("APCUIterator chunk size must be 0 or greater");
383+
return;
384+
}
385+
387386
apc_iterator_obj_init(iterator, search, format, chunk_size, list);
388387
}
389388

apc_iterator.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@
5050
typedef struct _apc_iterator_t {
5151
short int initialized; /* sanity check in case __construct failed */
5252
zend_long format; /* format bitmask of the return values ie: key, value, info */
53-
int (*fetch)(struct _apc_iterator_t *iterator);
53+
size_t (*fetch)(struct _apc_iterator_t *iterator);
5454
/* fetch callback to fetch items from cache slots or lists */
55-
zend_long slot_idx; /* index to the slot array or linked list */
56-
zend_long chunk_size; /* number of entries to pull down per fetch */
55+
size_t slot_idx; /* index to the slot array or linked list */
56+
size_t chunk_size; /* number of entries to pull down per fetch */
5757
apc_stack_t *stack; /* stack of entries pulled from cache */
5858
int stack_idx; /* index into the current stack */
5959
pcre_cache_entry *pce; /* regex filter on entry identifiers */
@@ -85,7 +85,7 @@ PHP_APCU_API void apc_iterator_obj_init(
8585
apc_iterator_t *iterator,
8686
zval *search,
8787
zend_long format,
88-
zend_long chunk_size,
88+
size_t chunk_size,
8989
zend_long list);
9090
PHP_APCU_API zend_class_entry* apc_iterator_get_ce(void);
9191
PHP_APCU_API int apc_iterator_init(int module_number);

0 commit comments

Comments
 (0)