1. 10 Jun, 2021 20 commits
    • Thomas Haller's avatar
      build: merge branch 'th/workaround-glib-atomic-pointer-get' · 39012584
      Thomas Haller authored
      !667
      
      (cherry picked from commit b57198a7)
      (cherry picked from commit 90a36d5e)
      (cherry picked from commit dec74df5)
      (cherry picked from commit 3f3397ab)
      (cherry picked from commit 3f13d4d5)
      39012584
    • Thomas Haller's avatar
      libnm: with meson include "nm-default.h" for glib-mkenums sources · 8d94c7e2
      Thomas Haller authored
      We also do that for the autotools implementation.
      
      (cherry picked from commit fd57e966)
      (cherry picked from commit c807e772)
      (cherry picked from commit 63f2d73b)
      (cherry picked from commit 6efb6696)
      (cherry picked from commit ea9c19ec)
      8d94c7e2
    • Thomas Haller's avatar
      libnm/tests: include "nm-default.h" for "libnm-core/tests/nm-core-tests-enum-types.c" · 87a0904b
      Thomas Haller authored
      With glib2-2.67.0-1.fc34.x86_64.rpm, clang-11.0.0-2.fc34.x86_64.rpm, the
      generated code emits a compiler warning:
      
          libnm-core/tests/nm-core-tests-enum-types.c:17:7: error: passing 'typeof (*(&g_define_type_id__volatile)) *' (aka 'volatile unsigned long *') to parameter of type 'gsize *' (aka 'unsigned long *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
            if (g_once_init_enter (&g_define_type_id__volatile))
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/glib/gthread.h:260:7: note: expanded from macro 'g_once_init_enter'
              (!g_atomic_pointer_get (location) &&                             \
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
              __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                               ^~~~~~~~~~~~~~~~~
          libnm-core/tests/nm-core-tests-enum-types.c:40:7: error: passing 'typeof (*(&g_define_type_id__volatile)) *' (aka 'volatile unsigned long *') to parameter of type 'gsize *' (aka 'unsigned long *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
            if (g_once_init_enter (&g_define_type_id__volatile))
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/glib/gthread.h:260:7: note: expanded from macro 'g_once_init_enter'
              (!g_atomic_pointer_get (location) &&                             \
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
              __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                               ^~~~~~~~~~~~~~~~~
          libnm-core/tests/nm-core-tests-enum-types.c:63:7: error: passing 'typeof (*(&g_define_type_id__volatile)) *' (aka 'volatile unsigned long *') to parameter of type 'gsize *' (aka 'unsigned long *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
            if (g_once_init_enter (&g_define_type_id__volatile))
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/glib/gthread.h:260:7: note: expanded from macro 'g_once_init_enter'
              (!g_atomic_pointer_get (location) &&                             \
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
              __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                               ^~~~~~~~~~~~~~~~~
      
      We could pass "-Wincompatible-pointer-types-discards-qualifiers" as CFLAGS
      when building this file. However, we have a workaround in our "nm-glib-aux/nm-glib.h",
      so we can instead include "nm-default.h". At first glance, that might look like
      the less preferable solution. However, this file is only there for unit tests,
      and we also include "nm-default.h" for other sources that are generated with
      "glib-mkenums". So, doing it also for our tests becomes the preferable solution.
      
      (cherry picked from commit 755d97d3)
      (cherry picked from commit 294efba1)
      (cherry picked from commit 2cff3f36)
      (cherry picked from commit cb1a632c)
      (cherry picked from commit df4008e9)
      87a0904b
    • Thomas Haller's avatar
      shared: don't enforce unset G_LOG_DOMAIN in "nm-default.h" · 2bfa92a4
      Thomas Haller authored
      When including <glib.h>, it will always define G_LOG_DOMAIN if it
      is not yet defined.
      
      Usually we want to include "nm-default.h" as very first header. In that
      case, <glib.h> is not yet included. Then the previous check #error works
      well.
      
      However, if we include "nm-default.h" in sources generated by
      glib-mkenums, then the generator first already includes <glib.h>,
      and thus defines G_LOG_DOMAIN. It does so for "libnm-core/nm-core-enum-types.c"
      and "libnm/nm-enum-types.c", where the #error would not trigger.
      But we will also include "nm-default.h" for "libnm-core/tests/nm-core-tests-enum-types.c".
      That will start triggering this #error.
      
      While in general we want to include "nm-default.h" first, we also need
      to support cases where <glib.h> gets included first. Thus this error is
      not useful. Remove it.
      
      (cherry picked from commit 42fa8f3d)
      (cherry picked from commit a1f3cebb)
      (cherry picked from commit 61d78ed3)
      (cherry picked from commit 33113c71)
      (cherry picked from commit cefe7456)
      2bfa92a4
    • Thomas Haller's avatar
      shared: also reimplement g_atomic_pointer_set() macro · 48629533
      Thomas Haller authored
      It's not strictly necessary, because contrary to g_atomic_pointer_get()
      and g_atomic_pointer_compare_and_exchange(), glib's variant for the
      setter is mostly fine.
      
      Still, reimplement it, because we use typeof() eagerly and can thus add
      more static checks than glib.
      
      (cherry picked from commit 7c60e984)
      (cherry picked from commit 6ded463f)
      (cherry picked from commit 976b358b)
      (cherry picked from commit 296a770a)
      (cherry picked from commit 32c81a29)
      48629533
    • Thomas Haller's avatar
      shared: add a compat implementation for g_atomic_pointer_get() · 9654d6fa
      Thomas Haller authored
      With glib2-2.67.0-1.fc34.x86_64.rpm, clang-11.0.0-2.fc34.x86_64.rpm, we
      get a failure for g_atomic_pointer_get():
      
          ../shared/nm-glib-aux/nm-hash-utils.c:38:9: error: passing 'typeof (*(&global_seed)) *' (aka 'const unsigned char *volatile *') to parameter of type 'const guint8 **' (aka 'const unsigned char **') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
              g = g_atomic_pointer_get(&global_seed);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
              __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                               ^~~~~~~~~~~~~~~~~
          ../shared/nm-glib-aux/nm-hash-utils.c:109:32: error: passing 'typeof (*(&global_seed)) *' (aka 'const unsigned char *volatile *') to parameter of type 'const guint8 **' (aka 'const unsigned char **') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
              return ((*((const guint *) _get_hash_key())) ^ static_seed) ?: 3679500967u;
                                         ^~~~~~~~~~~~~~~
          ../shared/nm-glib-aux/nm-hash-utils.c:84:14: note: expanded from macro '_get_hash_key'
                  _g = g_atomic_pointer_get(&global_seed); \
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
              __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                               ^~~~~~~~~~~~~~~~~
          ../shared/nm-glib-aux/nm-hash-utils.c:123:9: error: passing 'typeof (*(&global_seed)) *' (aka 'const unsigned char *volatile *') to parameter of type 'const guint8 **' (aka 'const unsigned char **') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
              g = _get_hash_key();
                  ^~~~~~~~~~~~~~~
          ../shared/nm-glib-aux/nm-hash-utils.c:84:14: note: expanded from macro '_get_hash_key'
                  _g = g_atomic_pointer_get(&global_seed); \
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
              __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                               ^~~~~~~~~~~~~~~~~
      
      (cherry picked from commit 5e57ea37)
      (cherry picked from commit 1e4cfba6)
      (cherry picked from commit 446cac18)
      (cherry picked from commit af4d01b5)
      (cherry picked from commit 17c83d09)
      9654d6fa
    • Thomas Haller's avatar
      introspection: avoid compiler warning in generated introspection files · 5c317a86
      Thomas Haller authored
      Disable "-Wincompatible-pointer-types-discards-qualifiers" warning, as
      this breaks build of the gdbus-codegen files.
      
      With glib2-2.67.0-1.fc34.x86_64.rpm, clang-11.0.0-2.fc34.x86_64.rpm, we
      get a failure to build generated code:
      
          introspection/org.freedesktop.NetworkManager.AccessPoint.c:438:1: error: passing 'typeof (*(&g_define_type_id__volatile)) *' (aka 'volatile unsigned long *') to parameter of type 'gsize *' (aka 'unsigned long *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
          G_DEFINE_INTERFACE (NMDBusAccessPoint, nmdbus_access_point, G_TYPE_OBJECT)
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/gobject/gtype.h:1784:47: note: expanded from macro 'G_DEFINE_INTERFACE'
          #define G_DEFINE_INTERFACE(TN, t_n, T_P)                    G_DEFINE_INTERFACE_WITH_CODE(TN, t_n, T_P, ;)
                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/gobject/gtype.h:1803:61: note: expanded from macro 'G_DEFINE_INTERFACE_WITH_CODE'
          #define G_DEFINE_INTERFACE_WITH_CODE(TN, t_n, T_P, _C_)     _G_DEFINE_INTERFACE_EXTENDED_BEGIN(TN, t_n, T_P) {_C_;} _G_DEFINE_INTERFACE_EXTENDED_END()
                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/gobject/gtype.h:2042:7: note: expanded from macro '_G_DEFINE_INTERFACE_EXTENDED_BEGIN'
            if (g_once_init_enter (&g_define_type_id__volatile))  \
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/glib/gthread.h:260:7: note: expanded from macro 'g_once_init_enter'
              (!g_atomic_pointer_get (location) &&                             \
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
              __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                               ^~~~~~~~~~~~~~~~~
          introspection/org.freedesktop.NetworkManager.AccessPoint.c:944:1: error: passing 'typeof (*(&g_define_type_id__volatile)) *' (aka 'volatile unsigned long *') to parameter of type 'gsize *' (aka 'unsigned long *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
          G_DEFINE_TYPE_WITH_CODE (NMDBusAccessPointProxy, nmdbus_access_point_proxy, G_TYPE_DBUS_PROXY,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/gobject/gtype.h:1615:56: note: expanded from macro 'G_DEFINE_TYPE_WITH_CODE'
          #define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_)          _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/gobject/gtype.h:2032:3: note: expanded from macro '_G_DEFINE_TYPE_EXTENDED_BEGIN'
            _G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/gobject/gtype.h:2000:7: note: expanded from macro '_G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER'
            if (g_once_init_enter (&g_define_type_id__volatile))  \
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/glib/gthread.h:260:7: note: expanded from macro 'g_once_init_enter'
              (!g_atomic_pointer_get (location) &&                             \
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
              __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                               ^~~~~~~~~~~~~~~~~
          introspection/org.freedesktop.NetworkManager.AccessPoint.c:1729:1: error: passing 'typeof (*(&g_define_type_id__volatile)) *' (aka 'volatile unsigned long *') to parameter of type 'gsize *' (aka 'unsigned long *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
          G_DEFINE_TYPE_WITH_CODE (NMDBusAccessPointSkeleton, nmdbus_access_point_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/gobject/gtype.h:1615:56: note: expanded from macro 'G_DEFINE_TYPE_WITH_CODE'
          #define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_)          _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/gobject/gtype.h:2032:3: note: expanded from macro '_G_DEFINE_TYPE_EXTENDED_BEGIN'
            _G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/gobject/gtype.h:2000:7: note: expanded from macro '_G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER'
            if (g_once_init_enter (&g_define_type_id__volatile))  \
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/glib/gthread.h:260:7: note: expanded from macro 'g_once_init_enter'
              (!g_atomic_pointer_get (location) &&                             \
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
              __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                               ^~~~~~~~~~~~~~~~~
      
      (cherry picked from commit 03d9ec27)
      (cherry picked from commit 595c5854)
      (cherry picked from commit 3a31fc45)
      (cherry picked from commit cb28b6a0)
      (cherry picked from commit 983f87c5)
      5c317a86
    • Thomas Haller's avatar
      build: don't depend dispatcher code on introspection sources · bb31dcd5
      Thomas Haller authored
      The dispatcher code does not use the generated introspection sources
      (anymore). Don't add a dependency.
      
      (cherry picked from commit e0a3a5e2)
      (cherry picked from commit 6ba600cb)
      (cherry picked from commit b8a172a6)
      (cherry picked from commit 2d6690ec)
      (cherry picked from commit 9b0ee443)
      bb31dcd5
    • Thomas Haller's avatar
      tests: avoid race condition in nmtstc_service_cleanup() · 0958a291
      Thomas Haller authored
      It seems it can happen that the service is not yet unregistered from the
      D-Bus broker, even if we already reaped the PID.
      
          /builds/NetworkManager/NetworkManager/tools/run-nm-test.sh --called-from-make /builds/NetworkManager/NetworkManager/build    --launch-dbus=auto /builds/NetworkManager/NetworkManager/build/libnm/tests/test-nm-client
          --- stdout ---
          /libnm/device-added:
          nmtst: initialize nmtst_get_rand() with NMTST_SEED_RAND=0
          --- stderr ---
          **
          test:ERROR:../shared/nm-test-utils-impl.c:216:nmtstc_service_cleanup: assertion failed: (!name_exists(info->bus, "org.freedesktop.NetworkManager"))
      
      Workaround by waiting a bit.
      
      We now iterate the main GMainContext, unlike before. But that
      should not cause any problems for the test.
      
      (cherry picked from commit 1b8ccacc)
      (cherry picked from commit d10d14d7)
      (cherry picked from commit d34e6193)
      (cherry picked from commit b4302981)
      (cherry picked from commit 2009025c)
      0958a291
    • Thomas Haller's avatar
      shared/tests: add nmtst_main_context_iterate_until_full() helper · 96b63d3f
      Thomas Haller authored
      (cherry picked from commit 230250e6)
      (cherry picked from commit 20cfc1f3)
      (cherry picked from commit c6666589)
      (cherry picked from commit fa82b663)
      (cherry picked from commit 08a8b757)
      96b63d3f
    • Thomas Haller's avatar
      shared/tests: add nmtst_g_source_nop() helper · 7a9af721
      Thomas Haller authored
      (cherry picked from commit ca2b79d9)
      (cherry picked from commit ddb69b21)
      (cherry picked from commit e0699824)
      (cherry picked from commit 83586524)
      (cherry picked from commit 2d59d02d)
      7a9af721
    • Thomas Haller's avatar
      platform/tests: better handling "timeout_msec" argument in nmtst_main_context_iterate_until() · c909149c
      Thomas Haller authored
      nmtst_main_context_iterate_until() is a macro, and we don't want to restrict the
      valid integer type (or range) of the "timeout_msec" argument.
      
      In particular, if the user calculates a timeout with "timestamp_msec -
      now_msec", the resulting "timeout_msec" might be a negative gint64.
      We should handle that gracefully, and not let it be cast to a huge
      unsigned int.
      
      (cherry picked from commit 6cb68884)
      (cherry picked from commit 4d572bea)
      (cherry picked from commit 95b74a3b)
      (cherry picked from commit 500c63db)
      (cherry picked from commit e8a5cee1)
      c909149c
    • Thomas Haller's avatar
      shared/tests: add nmtst_main_context_iterate_until() helper · 6237d89c
      Thomas Haller authored
      Like nmtst_main_context_iterate_until_assert(), but allows to
      run into timeout.
      
      (cherry picked from commit f2baa10b)
      (cherry picked from commit 3e41eb83)
      6237d89c
    • Thomas Haller's avatar
      shared/tests/trivial: rename nmtst_main_context_iterate_until() to... · 1d10ff84
      Thomas Haller authored
      shared/tests/trivial: rename nmtst_main_context_iterate_until() to nmtst_main_context_iterate_until_assert()
      
      nmtst_main_context_iterate_until*() iterates until the condition is
      satisfied. If that doesn't happen within timeout, it fails an assertion.
      
      Rename the function to make that clearer.
      
      (cherry picked from commit 90bb46c8)
      (cherry picked from commit 68800feb)
      1d10ff84
    • Thomas Haller's avatar
      shared/tests: use nmtst_g_source_set_boolean_true() in nmtst_main_context_iterate_until() · 977cee72
      Thomas Haller authored
      (cherry picked from commit eceaa39a)
      (cherry picked from commit 8673206f)
      977cee72
    • Thomas Haller's avatar
      shared/tests: add nmtst_g_source_set_boolean_true() helper · 52bd1d8c
      Thomas Haller authored
      (cherry picked from commit 0008c6c8)
      (cherry picked from commit 421844c8)
      52bd1d8c
    • Thomas Haller's avatar
      shared/tests: add nmtst_main_context_iterate_until() helper · a7f451a2
      Thomas Haller authored
      (cherry picked from commit 88ef02ec)
      a7f451a2
    • Thomas Haller's avatar
      libnm: suppress "-Warray-bounds" warning in nm_team_link_watcher_new_ethtool() · e5f51866
      Thomas Haller authored
      gcc-11.0.0-0.7.fc34 warns here:
      
          CC       libnm-core/libnm_core_la-nm-setting-team.lo
        libnm-core/nm-setting-team.c: In function ‘nm_team_link_watcher_new_ethtool’:
        libnm-core/nm-setting-team.c:127:33: error: array subscript ‘NMTeamLinkWatcher[0]’ is partly outside array bounds of ‘unsigned char[16]’ [-Werror=array-bounds]
          127 |     watcher->ref_count          = 1;
              |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
        libnm-core/nm-setting-team.c:125:15: note: referencing an object of size 16 allocated by ‘g_malloc’
          125 |     watcher = g_malloc(nm_offsetofend(NMTeamLinkWatcher, ethtool));
              |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        libnm-core/nm-setting-team.c:128:33: error: array subscript ‘NMTeamLinkWatcher[0]’ is partly outside array bounds of ‘unsigned char[16]’ [-Werror=array-bounds]
          128 |     watcher->type               = LINK_WATCHER_ETHTOOL;
              |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
        libnm-core/nm-setting-team.c:125:15: note: referencing an object of size 16 allocated by ‘g_malloc’
          125 |     watcher = g_malloc(nm_offsetofend(NMTeamLinkWatcher, ethtool));
              |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        libnm-core/nm-setting-team.c:129:33: error: array subscript ‘NMTeamLinkWatcher[0]’ is partly outside array bounds of ‘unsigned char[16]’ [-Werror=array-bounds]
          129 |     watcher->ethtool.delay_up   = delay_up;
              |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
        libnm-core/nm-setting-team.c:125:15: note: referencing an object of size 16 allocated by ‘g_malloc’
          125 |     watcher = g_malloc(nm_offsetofend(NMTeamLinkWatcher, ethtool));
              |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        libnm-core/nm-setting-team.c:130:33: error: array subscript ‘NMTeamLinkWatcher[0]’ is partly outside array bounds of ‘unsigned char[16]’ [-Werror=array-bounds]
          130 |     watcher->ethtool.delay_down = delay_down;
              |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
        libnm-core/nm-setting-team.c:125:15: note: referencing an object of size 16 allocated by ‘g_malloc’
          125 |     watcher = g_malloc(nm_offsetofend(NMTeamLinkWatcher, ethtool));
              |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Maybe we should not use this trick and just malloc() a struct of the
      intended size, however:
      
       - the code below does a similar thing, doing it differently for ethtool
         watcher is confusing.
      
       - the NMTeamLinkWatcher is a union which cannot alter its type. In no
         case is it correct to access the fields of the wrong union type. By
         allocating a smaller chunk, valgrind might catch such bugs.
         Also, NMTeamLinkWatcher's definition is private to the C source file,
         in no case must anybody assume that the rest of the buffer actually
         exists.
      
      Hence, workaround the warning by suppressing it.
      
      (cherry picked from commit e5699dbc)
      (cherry picked from commit 221547bc)
      (cherry picked from commit 8f3cf4f3)
      (cherry picked from commit 675c7df8)
      (cherry picked from commit 6efbf360)
      e5f51866
    • Thomas Haller's avatar
      shared: add nm_auto_destroy_and_unref_gsource macro · 502646f1
      Thomas Haller authored
      (cherry picked from commit 3b95905a)
      502646f1
    • Thomas Haller's avatar
      shared: add nm_g_source_destroy_and_unref() helper · d0bbd9fc
      Thomas Haller authored
      (cherry picked from commit c02710bb)
      d0bbd9fc
  2. 26 Oct, 2020 1 commit
  3. 29 Sep, 2020 3 commits
  4. 18 Sep, 2020 1 commit
  5. 09 Sep, 2020 2 commits
  6. 08 Sep, 2020 13 commits