all: merge branch 'th/clean-includes'

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1205
This commit is contained in:
Thomas Haller 2022-05-09 19:20:28 +02:00
commit 8b9e52b9ce
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
5 changed files with 74 additions and 76 deletions

View file

@ -12,10 +12,6 @@
/*****************************************************************************/
#include "libnm-glib-aux/nm-shared-utils.h"
/*****************************************************************************/
#define NM_KEYFILE_GROUP_VPN_SECRETS "vpn-secrets"
#define NM_KEYFILE_GROUPPREFIX_WIREGUARD_PEER "wireguard-peer."

View file

@ -33,27 +33,27 @@
#if NM_MORE_ASSERTS == 0
#ifndef G_DISABLE_CAST_CHECKS
/* Unless compiling with G_DISABLE_CAST_CHECKS, glib performs type checking
* during G_VARIANT_TYPE() via g_variant_type_checked_(). This is not necessary
* because commonly this cast is needed during something like
*
* g_variant_builder_init (&props, G_VARIANT_TYPE ("a{sv}"));
*
* Note that in if the variant type would be invalid, the check still
* wouldn't make the buggy code magically work. Instead of passing a
* bogus type string (bad), it would pass %NULL to g_variant_builder_init()
* (also bad).
*
* Also, a function like g_variant_builder_init() already validates
* the input type via something like
*
* g_return_if_fail (g_variant_type_is_container (type));
*
* So, by having G_VARIANT_TYPE() also validate the type, we validate
* twice, whereas the first validation is rather pointless because it
* doesn't prevent the function to be called with invalid arguments.
*
* Just patch G_VARIANT_TYPE() to perform no check.
*/
* during G_VARIANT_TYPE() via g_variant_type_checked_(). This is not necessary
* because commonly this cast is needed during something like
*
* g_variant_builder_init (&props, G_VARIANT_TYPE ("a{sv}"));
*
* Note that in if the variant type would be invalid, the check still
* wouldn't make the buggy code magically work. Instead of passing a
* bogus type string (bad), it would pass %NULL to g_variant_builder_init()
* (also bad).
*
* Also, a function like g_variant_builder_init() already validates
* the input type via something like
*
* g_return_if_fail (g_variant_type_is_container (type));
*
* So, by having G_VARIANT_TYPE() also validate the type, we validate
* twice, whereas the first validation is rather pointless because it
* doesn't prevent the function to be called with invalid arguments.
*
* Just patch G_VARIANT_TYPE() to perform no check.
*/
#undef G_VARIANT_TYPE
#define G_VARIANT_TYPE(type_string) ((const GVariantType *) (type_string))
#endif
@ -63,8 +63,6 @@
#include "nm-gassert-patch.h"
#include "libnm-std-aux/nm-std-aux.h"
#include "libnm-std-aux/nm-std-utils.h"
#include "libnm-glib-aux/nm-macros-internal.h"
#include "libnm-glib-aux/nm-shared-utils.h"
#include "libnm-glib-aux/nm-errno.h"

View file

@ -42,52 +42,52 @@
#if NM_MORE_ASSERTS == 0
/* The cast macros like NM_TYPE() are implemented via G_TYPE_CHECK_INSTANCE_CAST()
* and _G_TYPE_CIC(). The latter, by default performs runtime checks of the type
* by calling g_type_check_instance_cast().
* This check has a certain overhead without being helpful.
*
* Example 1:
* static void foo (NMType *obj)
* {
* access_obj_without_check (obj);
* }
* foo ((NMType *) obj);
* // There is no runtime check and passing an invalid pointer
* // leads to a crash.
*
* Example 2:
* static void foo (NMType *obj)
* {
* access_obj_without_check (obj);
* }
* foo (NM_TYPE (obj));
* // There is a runtime check which prints a g_warning(), but that doesn't
* // avoid the crash as NM_TYPE() cannot do anything then passing on the
* // invalid pointer.
*
* Example 3:
* static void foo (NMType *obj)
* {
* g_return_if_fail (NM_IS_TYPE (obj));
* access_obj_without_check (obj);
* }
* foo ((NMType *) obj);
* // There is a runtime check which prints a g_critical() which also avoids
* // the crash. That is actually helpful to catch bugs and avoid crashes.
*
* Example 4:
* static void foo (NMType *obj)
* {
* g_return_if_fail (NM_IS_TYPE (obj));
* access_obj_without_check (obj);
* }
* foo (NM_TYPE (obj));
* // The runtime check is performed twice, with printing a g_warning() and
* // a g_critical() and avoiding the crash.
*
* Example 3 is how it should be done. Type checks in NM_TYPE() are pointless.
* Disable them for our production builds.
*/
* and _G_TYPE_CIC(). The latter, by default performs runtime checks of the type
* by calling g_type_check_instance_cast().
* This check has a certain overhead without being helpful.
*
* Example 1:
* static void foo (NMType *obj)
* {
* access_obj_without_check (obj);
* }
* foo ((NMType *) obj);
* // There is no runtime check and passing an invalid pointer
* // leads to a crash.
*
* Example 2:
* static void foo (NMType *obj)
* {
* access_obj_without_check (obj);
* }
* foo (NM_TYPE (obj));
* // There is a runtime check which prints a g_warning(), but that doesn't
* // avoid the crash as NM_TYPE() cannot do anything then passing on the
* // invalid pointer.
*
* Example 3:
* static void foo (NMType *obj)
* {
* g_return_if_fail (NM_IS_TYPE (obj));
* access_obj_without_check (obj);
* }
* foo ((NMType *) obj);
* // There is a runtime check which prints a g_critical() which also avoids
* // the crash. That is actually helpful to catch bugs and avoid crashes.
*
* Example 4:
* static void foo (NMType *obj)
* {
* g_return_if_fail (NM_IS_TYPE (obj));
* access_obj_without_check (obj);
* }
* foo (NM_TYPE (obj));
* // The runtime check is performed twice, with printing a g_warning() and
* // a g_critical() and avoiding the crash.
*
* Example 3 is how it should be done. Type checks in NM_TYPE() are pointless.
* Disable them for our production builds.
*/
#ifndef G_DISABLE_CAST_CHECKS
#define G_DISABLE_CAST_CHECKS
#endif
@ -99,4 +99,9 @@
/*****************************************************************************/
#include "libnm-std-aux/nm-std-aux.h"
#include "libnm-std-aux/nm-std-utils.h"
/*****************************************************************************/
#endif /* __NM_DEFAULT_STD_H__ */

View file

@ -2,6 +2,8 @@
/* Copyright (C) 2021 Red Hat, Inc. */
#include "libnm-std-aux/nm-default-std.h"
#include <stdio.h>
#include <stdlib.h>
#include <arpa/inet.h>
@ -10,8 +12,6 @@
#include <nss.h>
#endif
#include "libnm-std-aux/nm-std-aux.h"
enum {
RETURN_SUCCESS = 0,
RETURN_INVALID_CMD = 1,

View file

@ -9,7 +9,6 @@
#include "libnm-glib-aux/nm-dbus-aux.h"
#include "libnm-glib-aux/nm-io-utils.h"
#include "libnm-glib-aux/nm-logging-base.h"
#include "libnm-glib-aux/nm-shared-utils.h"
#include "libnm-glib-aux/nm-time-utils.h"
/* nm-priv-helper doesn't link with libnm-core nor libnm-base, but these