From: Peter Hutterer Date: Fri, 22 Aug 2014 05:08:57 +0000 (+1000) Subject: Swap conditions for ARRAY_FOR_EACH() X-Git-Tag: 0.6.0~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bd8e3086939230a3501a6ee6ea3b2cdb1b2203a2;p=platform%2Fupstream%2Flibinput.git Swap conditions for ARRAY_FOR_EACH() The current conditions result in _elem being assigned _arr[i] before the condition is checked. This is fine since we then break from the loop and don't access it anyway, but it makes Coverity unhappy. Signed-off-by: Peter Hutterer --- diff --git a/src/libinput-util.h b/src/libinput-util.h index 2f1a1dbf..5d366b02 100644 --- a/src/libinput-util.h +++ b/src/libinput-util.h @@ -76,7 +76,7 @@ int list_empty(const struct list *list); #define NLONGS(x) (((x) + LONG_BITS - 1) / LONG_BITS) #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) #define ARRAY_FOR_EACH(_arr, _elem) \ - for (size_t _i = 0; (_elem = &_arr[_i]) && _i < ARRAY_LENGTH(_arr); _i++) + for (size_t _i = 0; _i < ARRAY_LENGTH(_arr) && (_elem = &_arr[_i]); _i++) #define min(a, b) (((a) < (b)) ? (a) : (b)) #define max(a, b) (((a) > (b)) ? (a) : (b))