NetworkManager/src/libnm-std-aux
Thomas Haller 40a77de88e std-aux: workaround usage of _Pragma() inside nm_assert()
Older gcc versions don't like this. The _Pragam() itself is to workaround a
-Wnonnull-compare warning with gcc 14.

After all, we use compiler warning extensively. They are our linters and have
necessarily false positives. To make them usable across a wide range of
compilers, is a constant effort.

Here is another one.

The error:

  ./src/libnm-std-aux/nm-std-aux.h: In function ‘nm_utils_addr_family_other’:
  ./src/libnm-std-aux/nm-std-aux.h:230:36: error: expected expression before ‘#pragma’
    230 | #define NM_PRAGMA_DIAGNOSTICS_PUSH _Pragma("GCC diagnostic push")
        |                                    ^~~~~~~
  ./src/libnm-std-aux/nm-std-aux.h:232:5: note: in expansion of macro ‘NM_PRAGMA_DIAGNOSTICS_PUSH’
    232 |     NM_PRAGMA_DIAGNOSTICS_PUSH _Pragma(_NM_PRAGMA_WARNING_DO(warning))
        |     ^~~~~~~~~~~~~~~~~~~~~~~~~~
  ./src/libnm-std-aux/nm-std-aux.h:291:9: note: in expansion of macro ‘NM_PRAGMA_WARNING_DISABLE’
    291 |         NM_PRAGMA_WARNING_DISABLE("-Wnonnull-compare");                \
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~
  ./src/libnm-std-aux/nm-std-aux.h:953:9: note: in expansion of macro ‘nm_assert’
    953 |         nm_assert(true || NM_UNIQ_T(xx, uniq) == (x));                    \
        |         ^~~~~~~~~
  ./src/libnm-std-aux/nm-std-aux.h:961:27: note: in expansion of macro ‘_NM_IN_SET’
    961 | #define NM_IN_SET(x, ...) _NM_IN_SET(NM_UNIQ, ||, typeof(x), x, __VA_ARGS__)
        |                           ^~~~~~~~~~
  ./src/libnm-std-aux/nm-std-aux.h:1493:15: note: in expansion of macro ‘NM_IN_SET’
   1493 |     nm_assert(NM_IN_SET((addr_family), NM_AF_INET, NM_AF_INET6))
        |               ^~~~~~~~~
  ./src/libnm-std-aux/nm-std-aux.h:1502:9: note: in expansion of macro ‘nm_assert_addr_family’
   1502 |         nm_assert_addr_family(NM_UNIQ_T(_addr_family, uniq));    \
        |         ^~~~~~~~~~~~~~~~~~~~~
  ./src/libnm-std-aux/nm-std-aux.h:1510:33: note: in expansion of macro ‘_NM_IS_IPv4’
   1510 | #define NM_IS_IPv4(addr_family) _NM_IS_IPv4(NM_UNIQ, addr_family)
        |                                 ^~~~~~~~~~~
  ./src/libnm-std-aux/nm-std-aux.h:1515:12: note: in expansion of macro ‘NM_IS_IPv4’
   1515 |     return NM_IS_IPv4(addr_family) ? NM_AF_INET6 : NM_AF_INET;
        |            ^~~~~~~~~~

Fixes: 62c1745f62 ('std-aux: suppress "-Wnonnull-compare" warning in nm_assert()')
(cherry picked from commit e4b154e1b0)
2024-02-09 12:53:54 +01:00
..
c-list-util.c std-aux: add c_list_insert_sorted() 2022-07-28 11:05:14 +02:00
c-list-util.h std-aux: add c_list_is_empty_or_single() helper 2023-03-08 15:34:47 +01:00
meson.build build: remove "shared/" from include search path 2021-02-24 12:49:06 +01:00
nm-dbus-compat.h build: move "shared/nm-std-aux" to "src/libnm-std-aux" 2021-02-24 12:48:24 +01:00
nm-default-std.h all: use _NM_G_TYPE_CHECK_INSTANCE_CAST() for internal uses 2022-12-16 10:55:03 +01:00
nm-linux-compat.h platform: remove CSME related code 2023-09-25 11:46:24 +00:00
nm-networkmanager-compilation.h build: move "shared/nm-std-aux" to "src/libnm-std-aux" 2021-02-24 12:48:24 +01:00
nm-std-aux.h std-aux: workaround usage of _Pragma() inside nm_assert() 2024-02-09 12:53:54 +01:00
nm-std-utils.c std-aux: extract and add _nm_strerror_r() helper 2023-09-12 12:39:43 +00:00
nm-std-utils.h std-aux: extract and add _nm_strerror_r() helper 2023-09-12 12:39:43 +00:00
README.md all: add some README.md files describing the purpose of our sources 2021-08-19 17:51:11 +02:00
unaligned-fundamental.h systemd: update code from upstream (2023-02-07) 2023-02-08 18:59:33 +01:00
unaligned.h systemd: update code from upstream (2023-02-07) 2023-02-08 18:59:33 +01:00

libnm-std-aux

A static helper library with general purpose helpers on top of standard C (C11).

As this has no additional dependencies, we should have all our C code use this internal helper library. It contains helpers that should be available (and used) everywhere where we write C.

Our C is gnu11, that is C11 or newer with some GCC-ism. The requirement is that it is supported by all complilers we care about (in pratice GCC and Clang).

Parts of this library are usually already included via the nm-default*.h headers.