mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-11-05 19:03:31 +00:00
63ca07f492
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. |
||
---|---|---|
.. | ||
nm-utils | ||
meson.build | ||
nm-common-macros.h | ||
nm-dbus-compat.h | ||
nm-default.h | ||
nm-dispatcher-api.h | ||
nm-meta-setting.c | ||
nm-meta-setting.h | ||
nm-test-libnm-utils.h | ||
nm-test-utils-impl.c | ||
nm-version-macros.h.in |