commit 25d89e6e460e68329e7a3f388fe3e150a8f5474a
Author:     Laslo Hunhold <[email protected]>
AuthorDate: Sun Jul 31 11:46:48 2022 +0200
Commit:     Laslo Hunhold <[email protected]>
CommitDate: Sun Jul 31 11:46:48 2022 +0200

    Use (size_t)(-1) instead of SIZE_MAX and fix style
    
    SIZE_MAX cannot be relied upon to fully reflect size_t's size. A
    portable idiom is to simply cast -1 to size_t to get the type's maximum
    value.
    
    Signed-off-by: Laslo Hunhold <[email protected]>

diff --git a/gen/util.c b/gen/util.c
index cefcee7..bfe0dbf 100644
--- a/gen/util.c
+++ b/gen/util.c
@@ -34,11 +34,12 @@ struct break_test_payload
 static void *
 reallocate_array(void *p, size_t len, size_t size)
 {
-       if (len > 0 && size > SIZE_MAX/len) {
+       if (len > 0 && size > (size_t)(-1) / len) {
                errno = ENOMEM;
                return NULL;
        }
-       return realloc(p, len*size);
+
+       return realloc(p, len * size);
 }
 
 int

Reply via email to