1. 18 Apr, 2019 1 commit
    • Thomas Haller's avatar
      shared: move most of "shared/nm-utils" to "shared/nm-glib-aux" · 80db06f7
      Thomas Haller authored
      From the files under "shared/nm-utils" we build an internal library
      that provides glib-based helper utilities.
      
      Move the files of that basic library to a new subdirectory
      "shared/nm-glib-aux" and rename the helper library "libnm-core-base.la"
      to "libnm-glib-aux.la".
      
      Reasons:
      
       - the name "utils" is overused in our code-base. Everything's an
         "utils". Give this thing a more distinct name.
      
       - there were additional files under "shared/nm-utils", which are not
         part of this internal library "libnm-utils-base.la". All the files
         that are part of this library should be together in the same
         directory, but files that are not, should not be there.
      
       - the new name should better convey what this library is and what is isn't:
         it's a set of utilities and helper functions that extend glib with
         funcitonality that we commonly need.
      
      There are still some files left under "shared/nm-utils". They have less
      a unifying propose to be in their own directory, so I leave them there
      for now. But at least they are separate from "shared/nm-glib-aux",
      which has a very clear purpose.
      80db06f7
  2. 17 Feb, 2019 4 commits
  3. 12 Feb, 2019 1 commit
  4. 15 Sep, 2018 1 commit
  5. 27 Aug, 2018 1 commit
    • Thomas Haller's avatar
      build: always define NM_MORE_LOGGING define and don't check with #ifdef · 3b5f8c91
      Thomas Haller authored
      Using '#ifdef' is generally error prone. It's better to always define
      a define and check for it explicitly. This way, the compiler can issue
      a warning if the define does not exist.
      
      Also, note how meson would always define NM_MORE_LOGGING, possibly to
      "0". That means, for meson, we unintentionally always enabled more
      logging because the define was always present.
      
      Fix that.
      3b5f8c91
  6. 10 May, 2018 1 commit
    • Lubomir Rintel's avatar
      all: use the elvis operator wherever possible · e69d3869
      Lubomir Rintel authored
      Coccinelle:
      
        @@
        expression a, b;
        @@
        -a ? a : b
        +a ?: b
      
      Applied with:
      
        spatch --sp-file ternary.cocci --in-place --smpl-spacing --dir .
      
      With some manual adjustments on spots that Cocci didn't catch for
      reasons unknown.
      
      Thanks to the marvelous effort of the GNU compiler developer we can now
      spare a couple of bits that could be used for more important things,
      like this commit message. Standards commitees yet have to catch up.
      e69d3869
  7. 30 Apr, 2018 1 commit
  8. 19 Mar, 2018 1 commit
    • Thomas Haller's avatar
      all: avoid calling g_free on a const pointer with g_clear_pointer() · f0442a47
      Thomas Haller authored
      With g_clear_pointer(pptr, g_free), pptr is cast to a non-const pointer,
      and hence there is no compiler warning about calling g_free() in a const
      pointer. However, it still feels ugly to pass a const pointer to
      g_clear_pointer(). We should either add an explicity cast, or just
      make the pointer non-const.
      
      I guess part of the problem is that C's "const char *" means that the
      string itself is immutable, but also that it cannot be freed. We most
      often want a different semantic: the string itself is immutable after
      being initialized once, but the memory itself can and will be freed.
      Such a notion of immutable C strings cannot be expressed.
      
      For that, just remove the "const" from the declarations. Although we
      don't want to modify the (content of the) string, it's still more a
      mutable string.
      
      Only in _vt_cmd_obj_copy_lnk_vlan(), add an explicity cast but keep the
      type as const. The reason is, that we really want that NMPObject
      instances are immutable (in the sense that they don't modify while
      existing), but that doesn't mean the memory cannot be freed.
      f0442a47
  9. 21 Feb, 2018 2 commits
    • Beniamino Galvani's avatar
      ovs: don't consume error in method callback · 878a3a41
      Beniamino Galvani authored
      The error should be freed by callback functions, but only
      _monitor_bridges_cb() actually does it. Simplify this by letting the
      caller own the error.
      
      Fixes: 830a5a14
      878a3a41
    • Beniamino Galvani's avatar
      ovs: add error code for callbacks to indicate NM is quitting · cf796151
      Beniamino Galvani authored
      When NM quits it destroys all singletons including NMOvsdb, which
      invokes callbacks for every pending method call. In the shutdown,
      extra care must be taken to not access objects that are already in a
      inconsistent state; for example here, the callback changes the device
      state, and this causes an access to data that has already been
      cleared:
      
       #0  _g_log_abort (breakpoint=breakpoint@entry=1) at gmessages.c:554
       #1  g_logv (log_domain=0x5635653b6817 "NetworkManager", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffb4b2c1e0) at gmessages.c:1362
       #2  g_log (log_domain=log_domain@entry=0x5635653b6817 "NetworkManager", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7fbb3f58fa4a "%s: assertion '%s' failed") at gmessages.c:1403
       #3  g_return_if_fail_warning (log_domain=log_domain@entry=0x5635653b6817 "NetworkManager", pretty_function=pretty_function@entry=0x5635653b6b00 <__func__.34463> "nm_device_factory_manager_find_factory_for_connection", expression=expression@entry=0x5635653b6719 "factories_by_setting") at gmessages.c:2702
       #4  nm_device_factory_manager_find_factory_for_connection (connection=connection@entry=0x56356627e0e0) at src/devices/nm-device-factory.c:243
       #5  nm_manager_get_connection_iface (self=0x563566241080 [NMManager], connection=connection@entry=0x56356627e0e0, out_parent=out_parent@entry=0x0, error=error@entry=0x0) at src/nm-manager.c:1458
       #6  check_connection_compatible (self=<optimized out>, connection=0x56356627e0e0) at src/devices/nm-device.c:4679
       #7  check_connection_compatible (device=0x56356647b1b0 [NMDeviceOvsInterface], connection=0x56356627e0e0) at src/devices/ovs/nm-device-ovs-interface.c:95
       #8  _nm_device_check_connection_available (self=0x56356647b1b0 [NMDeviceOvsInterface], connection=0x56356627e0e0, flags=NM_DEVICE_CHECK_CON_AVAILABLE_NONE, specific_object=0x0) at src/devices/nm-device.c:12102
       #9  nm_device_check_connection_available (self=self@entry=0x56356647b1b0 [NMDeviceOvsInterface], connection=0x56356627e0e0, flags=flags@entry=NM_DEVICE_CHECK_CON_AVAILABLE_NONE, specific_object=specific_object@entry=0x0) at src/devices/nm-device.c:12131
       #10 nm_device_recheck_available_connections (self=self@entry=0x56356647b1b0 [NMDeviceOvsInterface]) at src/devices/nm-device.c:12238
       #11 _set_state_full (self=self@entry=0x56356647b1b0 [NMDeviceOvsInterface], state=state@entry=NM_DEVICE_STATE_FAILED, reason=reason@entry=NM_DEVICE_STATE_REASON_OVSDB_FAILED, quitting=quitting@entry=0) at src/devices/nm-device.c:13065
       #12 nm_device_state_changed (self=self@entry=0x56356647b1b0 [NMDeviceOvsInterface], state=state@entry=NM_DEVICE_STATE_FAILED, reason=reason@entry=NM_DEVICE_STATE_REASON_OVSDB_FAILED) at src/devices/nm-device.c:13328
       #13 del_iface_cb (error=<optimized out>, user_data=0x56356647b1b0) at src/devices/ovs/nm-device-ovs-port.c:160
       #14 _transact_cb (self=self@entry=0x5635662b9ba0 [NMOvsdb], result=result@entry=0x0, error=0x563566259a10, user_data=user_data@entry=0x5635662ff320) at src/devices/ovs/nm-ovsdb.c:1449
       #15 ovsdb_disconnect (self=self@entry=0x5635662b9ba0 [NMOvsdb]) at src/devices/ovs/nm-ovsdb.c:1331
       #16 dispose (object=0x5635662b9ba0 [NMOvsdb]) at src/devices/ovs/nm-ovsdb.c:1558
       #17 g_object_unref (_object=0x5635662b9ba0) at gobject.c:3293
       #18 _nm_singleton_instance_destroy () at src/nm-core-utils.c:138
       #19 _dl_fini () at dl-fini.c:253
       #20 __run_exit_handlers (status=status@entry=0, listp=0x7fbb3e1ad6c8 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true) at exit.c:77
       #21 __GI_exit (status=status@entry=0) at exit.c:99
       #22 main (argc=1, argv=0x7fffb4b2cc38) at src/main.c:468
      
      Add a new error code to indicate to callbacks that we are quitting and
      no further action must be taken. This is preferable to having
      additional references because it allows us to free the resources owned
      by callbacks immediately, while references can easily create loops.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1543871
      cf796151
  10. 09 Nov, 2017 2 commits
    • Thomas Haller's avatar
      all: update compatiblity for older libjansson versions · 595aaf0f
      Thomas Haller authored
      - nm-ovsdb.c uses json_load_callback(), which is jansson v2.4.
        Hence, it cannot build the OVS plugin in our Travis-CI, which is
        still on Ubuntu Precise. Disable building the plugin in travis and
        add a compiler warning when building against an older version.
      
      - since jansson v2.3, there is json_object_key_to_iter() to implement
        the for-each macros. Use it in json_object_foreach_safe() when
        available.
      595aaf0f
    • Thomas Haller's avatar
      all: use nm-jansson.h · 650a47e1
      Thomas Haller authored
      650a47e1
  11. 31 Oct, 2017 3 commits
  12. 30 Oct, 2017 1 commit