NetworkManager/shared/nm-utils
Thomas Haller 63ca07f492 shared: add nm_clear_pointer() and implement existing nm_clear_*() based on it
Add an alternative to g_clear_pointer(). The differences are:

  - nm_clear_pointer() is more type safe as it does not cast neither the
    pointer nor the destroy function. Commonly, the types should be compatible
    and not requiring a cast. Casting in the macro eliminates some of the
    compilers type checking. For example, while
       g_clear_pointer (&priv->hash_table, g_ptr_array_unref);
    compiles, nm_clear_pointer() would prevent such an invalid use.

  - also, clear the destination pointer *before* invoking the destroy
    function. Destroy might emit signals (like weak-pointer callbacks
    of GArray clear functions). Clear the destination first, so that
    we don't leave a dangling pointer there.

  - return TRUE/FALSE depending on whether there was a pointer to clear.

I tested that redefining g_clear_pointer()/g_clear_object() with our
more typesafe nm_* variants still compiles and indicates no bugs. So
that is good. It's not really expected that turning on more static checks
would yield a large number of bugs, because generally our code is in a good
shape already. We have few such bugs, because we already turn all all warnings
and extra checks that make sense. That however is not an argument for
not introducing (and using) a more resticted implementation.
2018-03-19 15:51:17 +01:00
..
c-list-util.c shared: implement c_list_sort() as non-recursive merge-sort 2018-01-03 16:41:47 +01:00
c-list-util.h c-list: add c_list_sort() 2017-07-25 06:42:14 +02:00
c-list.h c-list: re-import latest version of c-list.h from upstream 2017-11-28 11:26:39 +01:00
gsystem-local-alloc.h shared: move shared files to subdirectory "shared/nm-utils/" 2016-06-16 10:45:53 +02:00
nm-c-list.h shared: add NMCListElem 2018-01-09 14:24:53 +01:00
nm-compat.c shared/compat: minor refactoring of compat code 2017-12-22 15:53:22 +01:00
nm-compat.h shared/compat: add compat for nm_setting_vpn_get_data_keys() and nm_setting_vpn_get_secret_keys() 2017-11-23 14:44:25 +01:00
nm-dedup-multi.c shared/utils/dedup-multi: make nm_dedup_multi_obj_unref() return void 2018-02-08 17:11:46 +01:00
nm-dedup-multi.h shared/utils/dedup-multi: make nm_dedup_multi_obj_unref() return void 2018-02-08 17:11:46 +01:00
nm-enum-utils.c shared: cast from/to argument to unsigned for GFlags in _nm_utils_enum_get_values() 2017-04-27 18:01:58 +02:00
nm-enum-utils.h libnm: move public nm_utils_enum_*() functions back to libnm-core 2017-04-05 18:38:31 +02:00
nm-glib.h all: require glib 2.40 2018-01-18 11:45:36 +01:00
nm-hash-utils.c build: include "siphash24.c" source in "nm-hash-utils.c" 2017-11-16 11:49:52 +01:00
nm-hash-utils.h shared: add nm_hash_static() to get a static hash key 2017-11-16 11:48:05 +01:00
nm-jansson.h all: require jansson 2.5 2018-01-18 11:45:24 +01:00
nm-macros-internal.h shared: add nm_clear_pointer() and implement existing nm_clear_*() based on it 2018-03-19 15:51:17 +01:00
nm-obj.h all: add base object type in "nm-obj.h" 2017-07-05 14:22:10 +02:00
nm-random-utils.c all: use nm_close() instead of close() 2017-11-14 15:10:42 +01:00
nm-random-utils.h shared: split random and hash utils 2017-10-17 20:02:59 +02:00
nm-shared-utils.c shared: add nm_utils_strv_make_deep_copied() helper 2017-12-18 12:10:11 +01:00
nm-shared-utils.h shared: add nm_g_variant_unref_floating() helper 2018-03-10 16:49:30 +01:00
nm-test-utils.h tests: fix test setup after requiring glib 2.40 2018-01-22 08:31:00 +01:00
nm-udev-utils.c all: fix -Wcast-function-type warnings 2018-02-08 17:11:46 +01:00
nm-udev-utils.h udev: add and use nm_udev_utils_property_decode() function 2017-03-22 12:41:06 +01:00
nm-vpn-editor-plugin-call.h shared: include "gsystem-local-alloc.h" from "nm-glib.h" 2016-06-16 10:45:54 +02:00
nm-vpn-plugin-macros.h shared: add nm_utils_syslog_coerce_from_nm() util 2016-09-19 15:35:33 +02:00
nm-vpn-plugin-utils.c shared: add "nm-utils/nm-vpn-plugin-utils.h" 2016-06-16 10:45:54 +02:00
nm-vpn-plugin-utils.h shared: add "nm-utils/nm-vpn-plugin-utils.h" 2016-06-16 10:45:54 +02:00
siphash24.c systemd: merge branch systemd into master 2017-12-13 10:41:18 +01:00
siphash24.h systemd: update code from upstream (2017-10-11) 2017-10-18 13:38:03 +02:00
unaligned.h systemd: update code from upstream (2018-02-14) 2018-02-14 17:52:02 +01:00