NetworkManager/shared/nm-std-aux
Thomas Haller 040c86f15c
shared: avoid compiler warning for nm_utils_get_next_realloc_size() returning huge sizes
On s390x (gcc-8.3.1-5.1.el8.s390x) the compiler warns that we don't
pass size larger than 2^63-1 to malloc. With LTO enabled, it is also
quite adamant in detecting that with nm_utils_get_next_realloc_size().

Optimally, we would disable this useless warning with "-Wno-alloc-size-larger-than",
but that seems not to work. So add a workaround in code :(

It's hard to actually workaround the warning while handling all kinds of
sizes. The only simple solution is to no handle such huge cases and only
assert.

    In function 'nm_secret_mem_realloc',
        inlined from '_nm_str_buf_ensure_size' at shared/nm-glib-aux/nm-shared-utils.c:5316:31:
    shared/nm-glib-aux/nm-secret-utils.h:180:17: error: argument 1 value '18446744073709551615' exceeds maximum object size 9223372036854775807 [-Werror=alloc-size-larger-than=]
             m_new = g_malloc(new_len);
                     ^
    shared/nm-glib-aux/nm-secret-utils.h: In function '_nm_str_buf_ensure_size':
    /usr/include/glib-2.0/glib/gmem.h:78:10: note: in a call to allocation function 'g_malloc' declared here
     gpointer g_malloc         (gsize  n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
              ^
    lto1: all warnings being treated as errors
2021-01-11 19:03:28 +01:00
..
c-list-util.c all: update deprecated SPDX license identifiers 2021-01-05 09:46:21 +01:00
c-list-util.h all: update deprecated SPDX license identifiers 2021-01-05 09:46:21 +01:00
nm-dbus-compat.h all: update deprecated SPDX license identifiers 2021-01-05 09:46:21 +01:00
nm-std-aux.h all: update deprecated SPDX license identifiers 2021-01-05 09:46:21 +01:00
nm-std-utils.c shared: avoid compiler warning for nm_utils_get_next_realloc_size() returning huge sizes 2021-01-11 19:03:28 +01:00
nm-std-utils.h all: update deprecated SPDX license identifiers 2021-01-05 09:46:21 +01:00
unaligned.h shared: don't clang-format "shared/nm-std-aux/unaligned.h" 2021-01-05 09:37:02 +01:00