get_size() stores the size returned by get_size64() before testing its return value. When get_size64() fails without writing the size (empty string, negative, out of range, unknown suffix), an uninitialized value is read. Store the size only on success, as get_size_and_cell() does; every caller tests the return value, so none can see the change. Clang's static analyzer reports the read ("Assigned value is uninitialized"). Fixes: 8798ab4c4c02 ("tc: Add get_size64 and get_size64_and_cell") Signed-off-by: Dave Seddon --- lib/utils_math.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/utils_math.c b/lib/utils_math.c index d082a391..d9bf3aa0 100644 --- a/lib/utils_math.c +++ b/lib/utils_math.c @@ -151,13 +151,12 @@ int get_size(unsigned int *size, const char *str) int rv; rv = get_size64(&sz64, str); - *size = sz64; - if (rv) return rv; if (sz64 > UINT_MAX) return -1; + *size = sz64; return 0; } -- 2.56.0