From 30352032a6a5602bae3930ec4db97503d5ece558 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 10 Feb 2023 13:14:42 +0000 Subject: [PATCH 1/2] gstrfuncs: Use separate preprocessor conditionals for g-i and gtk-doc GObject-Introspection and gtk-doc both parse C headers using regular expressions, so they can easily be confused by non-trivial conditions. GObject-Introspection warns about this: .../gstrfuncs.h:151: the __GI_SCANNER__ constant should only be used with simple #ifdef or #endif: #if !defined (__GTK_DOC_IGNORE__) && !defined (__GI_SCANNER__) In this case it's very easy to convert the compound expression into nesting. Signed-off-by: Simon McVittie --- glib/gstrfuncs.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/glib/gstrfuncs.h b/glib/gstrfuncs.h index 569f96977..8a6830294 100644 --- a/glib/gstrfuncs.h +++ b/glib/gstrfuncs.h @@ -147,7 +147,8 @@ gboolean (g_str_has_prefix) (const gchar *str, const gchar *prefix); #if G_GNUC_CHECK_VERSION (2, 0) -#if !defined (__GTK_DOC_IGNORE__) && !defined (__GI_SCANNER__) +#ifndef __GTK_DOC_IGNORE__ +#ifndef __GI_SCANNER__ /* This macro is defeat a false -Wnonnull warning in GCC. * Without it, it thinks strlen and memcmp may be getting passed NULL @@ -220,7 +221,8 @@ gboolean (g_str_has_prefix) (const gchar *str, (g_strdup) ((STR)) \ ) -#endif /* !defined (__GTK_DOC_IGNORE__) && !defined (__GI_SCANNER__) */ +#endif /* !defined (__GI_SCANNER__) */ +#endif /* !defined (__GTK_DOC_IGNORE__) */ #endif /* G_GNUC_CHECK_VERSION (2, 0) */ /* String to/from double conversion functions */ From ee223e8ec80866646f6e9d7d6dab427bbb277803 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 10 Feb 2023 13:16:01 +0000 Subject: [PATCH 2/2] gtimezone: Avoid a nested preprocessor conditional to be nice to g-i GObject-Introspection seems to become confused by the nested conditional followed by an `#elif` clause for the outer conditional, and issues this warning: .../gtimezone.c:830: mismatched #elif defined (G_OS_WIN32) Signed-off-by: Simon McVittie --- glib/gtimezone.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/glib/gtimezone.c b/glib/gtimezone.c index 20f99a621..4a4a2d010 100644 --- a/glib/gtimezone.c +++ b/glib/gtimezone.c @@ -445,9 +445,7 @@ zone_for_constant_offset (GTimeZone *gtz, const gchar *name) gtz->transitions = NULL; } -#ifdef G_OS_UNIX - -#if defined(__sun) && defined(__SVR4) +#if defined(G_OS_UNIX) && defined(__sun) && defined(__SVR4) /* * only used by Illumos distros or Solaris < 11: parse the /etc/default/init * text file looking for TZ= followed by the timezone, possibly quoted @@ -513,6 +511,7 @@ zone_identifier_illumos (void) } #endif /* defined(__sun) && defined(__SRVR) */ +#ifdef G_OS_UNIX /* * returns the path to the top of the Olson zoneinfo timezone hierarchy. */