Using strcmp() to test for string equality is a well known pattern. However the inverse logic still hurts my brain every single time, especially in more complex expressions.
nm_streq() should be preferred over strcmp(). And there is a counterpart nm_streq0() which uses g_strcmp0(). Kernel and systemd have also streq() macros. --- shared/nm-macros-internal.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/shared/nm-macros-internal.h b/shared/nm-macros-internal.h index 4b43b58..2612cff 100644 --- a/shared/nm-macros-internal.h +++ b/shared/nm-macros-internal.h @@ -242,6 +242,11 @@ _NM_IN_STRSET_streq (const char *x, const char *s) /*****************************************************************************/ +#define nm_streq(s1, s2) (strcmp (s1, s2) == 0) +#define nm_streq0(s1, s2) (g_strcmp0 (s1, s2) == 0) + +/*****************************************************************************/ + #define NM_PRINT_FMT_QUOTED(cond, prefix, str, suffix, str_else) \ (cond) ? (prefix) : "", \ (cond) ? (str) : (str_else), \ -- 2.5.0 _______________________________________________ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list