X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fshared%2Fprioq.c;h=537befc623a1554bd4b57bb115ca223bacddbbb4;hp=64c44aef8266bfef9bab49ea12cb397f6cb777f7;hb=68313d3dfa2082dae8a06643d639e0200afc19fc;hpb=a3de5ae1d7d881bbd4869c6c4a200c84bda00ced diff --git a/src/shared/prioq.c b/src/shared/prioq.c index 64c44aef8..537befc62 100644 --- a/src/shared/prioq.c +++ b/src/shared/prioq.c @@ -159,7 +159,7 @@ int prioq_put(Prioq *q, void *data, unsigned *idx) { unsigned n; struct prioq_item *j; - n = MAX((q->n_items+1) * 2, 16); + n = MAX((q->n_items+1) * 2, 16u); j = realloc(q->items, sizeof(struct prioq_item) * n); if (!j) return -ENOMEM; @@ -211,13 +211,14 @@ static void remove_item(Prioq *q, struct prioq_item *i) { } } -static struct prioq_item* find_item(Prioq *q, void *data, unsigned *idx) { +_pure_ static struct prioq_item* find_item(Prioq *q, void *data, unsigned *idx) { struct prioq_item *i; assert(q); if (idx) { - if (*idx > q->n_items) + if (*idx == PRIOQ_IDX_NULL || + *idx > q->n_items) return NULL; i = q->items + *idx;