summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVladimír Čunát <vladimir.cunat@nic.cz>2024-09-12 14:54:16 +0200
committerVladimír Čunát <vladimir.cunat@nic.cz>2024-09-12 15:37:21 +0200
commit20f67c0925fd6b050efcf565714720679f1fcd33 (patch)
tree34218c379ac74d1a4292190b47e3cb6bbd2ba5cc /lib
parentdaemon/session2: try to avoid triggering Coverity (diff)
downloadknot-resolver-20f67c0925fd6b050efcf565714720679f1fcd33.tar.xz
knot-resolver-20f67c0925fd6b050efcf565714720679f1fcd33.zip
lib/generic/array: extend the return type of array_push*()
In case of no error, the index is returned, but `int` isn't a great choice for returning array indices. (though I doubt that we can get anywhere near 2^31 elements in practice) Detected by Coverity.
Diffstat (limited to 'lib')
-rw-r--r--lib/generic/array.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/generic/array.h b/lib/generic/array.h
index 9bea546b..eb1f7bc2 100644
--- a/lib/generic/array.h
+++ b/lib/generic/array.h
@@ -122,7 +122,7 @@ static inline void array_std_free(void *baton, void *p)
* @return element index on success, <0 on failure
*/
#define array_push_mm(array, val, reserve, baton) \
- (int)((array).len < (array).cap ? ((array).at[(array).len] = (val), (array).len++) \
+ (ssize_t)((array).len < (array).cap ? ((array).at[(array).len] = (val), (array).len++) \
: (array_reserve_mm(array, ((array).cap + 1), reserve, baton) < 0 ? -1 \
: ((array).at[(array).len] = (val), (array).len++)))