mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 14:18:12 +02:00
code-style: fix wrong indentation for code comments
This commit is contained in:
parent
c6e41b2df3
commit
80a19958dc
2 changed files with 67 additions and 67 deletions
|
|
@ -33,27 +33,27 @@
|
||||||
#if NM_MORE_ASSERTS == 0
|
#if NM_MORE_ASSERTS == 0
|
||||||
#ifndef G_DISABLE_CAST_CHECKS
|
#ifndef G_DISABLE_CAST_CHECKS
|
||||||
/* Unless compiling with G_DISABLE_CAST_CHECKS, glib performs type checking
|
/* Unless compiling with G_DISABLE_CAST_CHECKS, glib performs type checking
|
||||||
* during G_VARIANT_TYPE() via g_variant_type_checked_(). This is not necessary
|
* during G_VARIANT_TYPE() via g_variant_type_checked_(). This is not necessary
|
||||||
* because commonly this cast is needed during something like
|
* because commonly this cast is needed during something like
|
||||||
*
|
*
|
||||||
* g_variant_builder_init (&props, G_VARIANT_TYPE ("a{sv}"));
|
* g_variant_builder_init (&props, G_VARIANT_TYPE ("a{sv}"));
|
||||||
*
|
*
|
||||||
* Note that in if the variant type would be invalid, the check still
|
* 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
|
* 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()
|
* bogus type string (bad), it would pass %NULL to g_variant_builder_init()
|
||||||
* (also bad).
|
* (also bad).
|
||||||
*
|
*
|
||||||
* Also, a function like g_variant_builder_init() already validates
|
* Also, a function like g_variant_builder_init() already validates
|
||||||
* the input type via something like
|
* the input type via something like
|
||||||
*
|
*
|
||||||
* g_return_if_fail (g_variant_type_is_container (type));
|
* g_return_if_fail (g_variant_type_is_container (type));
|
||||||
*
|
*
|
||||||
* So, by having G_VARIANT_TYPE() also validate the type, we validate
|
* So, by having G_VARIANT_TYPE() also validate the type, we validate
|
||||||
* twice, whereas the first validation is rather pointless because it
|
* twice, whereas the first validation is rather pointless because it
|
||||||
* doesn't prevent the function to be called with invalid arguments.
|
* doesn't prevent the function to be called with invalid arguments.
|
||||||
*
|
*
|
||||||
* Just patch G_VARIANT_TYPE() to perform no check.
|
* Just patch G_VARIANT_TYPE() to perform no check.
|
||||||
*/
|
*/
|
||||||
#undef G_VARIANT_TYPE
|
#undef G_VARIANT_TYPE
|
||||||
#define G_VARIANT_TYPE(type_string) ((const GVariantType *) (type_string))
|
#define G_VARIANT_TYPE(type_string) ((const GVariantType *) (type_string))
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -42,52 +42,52 @@
|
||||||
|
|
||||||
#if NM_MORE_ASSERTS == 0
|
#if NM_MORE_ASSERTS == 0
|
||||||
/* The cast macros like NM_TYPE() are implemented via G_TYPE_CHECK_INSTANCE_CAST()
|
/* 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
|
* and _G_TYPE_CIC(). The latter, by default performs runtime checks of the type
|
||||||
* by calling g_type_check_instance_cast().
|
* by calling g_type_check_instance_cast().
|
||||||
* This check has a certain overhead without being helpful.
|
* This check has a certain overhead without being helpful.
|
||||||
*
|
*
|
||||||
* Example 1:
|
* Example 1:
|
||||||
* static void foo (NMType *obj)
|
* static void foo (NMType *obj)
|
||||||
* {
|
* {
|
||||||
* access_obj_without_check (obj);
|
* access_obj_without_check (obj);
|
||||||
* }
|
* }
|
||||||
* foo ((NMType *) obj);
|
* foo ((NMType *) obj);
|
||||||
* // There is no runtime check and passing an invalid pointer
|
* // There is no runtime check and passing an invalid pointer
|
||||||
* // leads to a crash.
|
* // leads to a crash.
|
||||||
*
|
*
|
||||||
* Example 2:
|
* Example 2:
|
||||||
* static void foo (NMType *obj)
|
* static void foo (NMType *obj)
|
||||||
* {
|
* {
|
||||||
* access_obj_without_check (obj);
|
* access_obj_without_check (obj);
|
||||||
* }
|
* }
|
||||||
* foo (NM_TYPE (obj));
|
* foo (NM_TYPE (obj));
|
||||||
* // There is a runtime check which prints a g_warning(), but that doesn't
|
* // 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
|
* // avoid the crash as NM_TYPE() cannot do anything then passing on the
|
||||||
* // invalid pointer.
|
* // invalid pointer.
|
||||||
*
|
*
|
||||||
* Example 3:
|
* Example 3:
|
||||||
* static void foo (NMType *obj)
|
* static void foo (NMType *obj)
|
||||||
* {
|
* {
|
||||||
* g_return_if_fail (NM_IS_TYPE (obj));
|
* g_return_if_fail (NM_IS_TYPE (obj));
|
||||||
* access_obj_without_check (obj);
|
* access_obj_without_check (obj);
|
||||||
* }
|
* }
|
||||||
* foo ((NMType *) obj);
|
* foo ((NMType *) obj);
|
||||||
* // There is a runtime check which prints a g_critical() which also avoids
|
* // 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.
|
* // the crash. That is actually helpful to catch bugs and avoid crashes.
|
||||||
*
|
*
|
||||||
* Example 4:
|
* Example 4:
|
||||||
* static void foo (NMType *obj)
|
* static void foo (NMType *obj)
|
||||||
* {
|
* {
|
||||||
* g_return_if_fail (NM_IS_TYPE (obj));
|
* g_return_if_fail (NM_IS_TYPE (obj));
|
||||||
* access_obj_without_check (obj);
|
* access_obj_without_check (obj);
|
||||||
* }
|
* }
|
||||||
* foo (NM_TYPE (obj));
|
* foo (NM_TYPE (obj));
|
||||||
* // The runtime check is performed twice, with printing a g_warning() and
|
* // The runtime check is performed twice, with printing a g_warning() and
|
||||||
* // a g_critical() and avoiding the crash.
|
* // a g_critical() and avoiding the crash.
|
||||||
*
|
*
|
||||||
* Example 3 is how it should be done. Type checks in NM_TYPE() are pointless.
|
* Example 3 is how it should be done. Type checks in NM_TYPE() are pointless.
|
||||||
* Disable them for our production builds.
|
* Disable them for our production builds.
|
||||||
*/
|
*/
|
||||||
#ifndef G_DISABLE_CAST_CHECKS
|
#ifndef G_DISABLE_CAST_CHECKS
|
||||||
#define G_DISABLE_CAST_CHECKS
|
#define G_DISABLE_CAST_CHECKS
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue