From: Tobias Brunner Date: Fri, 14 Sep 2012 10:06:02 +0000 (+0200) Subject: Make streq() and strcaseeq() static inline functions so they can be used as callbacks X-Git-Tag: 5.0.1~73 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a2a28d90ac72cd53136801aef0aadf80a049df8d;p=thirdparty%2Fstrongswan.git Make streq() and strcaseeq() static inline functions so they can be used as callbacks --- diff --git a/src/charon-nm/nm/nm_service.c b/src/charon-nm/nm/nm_service.c index fd96f436b4..b7155b44bd 100644 --- a/src/charon-nm/nm/nm_service.c +++ b/src/charon-nm/nm/nm_service.c @@ -624,7 +624,7 @@ static gboolean need_secrets(NMVPNPlugin *plugin, NMConnection *connection, } } } - else if streq(method, "smartcard") + else if (streq(method, "smartcard")) { if (nm_setting_vpn_get_secret(settings, "password")) { diff --git a/src/libstrongswan/utils.h b/src/libstrongswan/utils.h index ec7173953e..f47c65ac13 100644 --- a/src/libstrongswan/utils.h +++ b/src/libstrongswan/utils.h @@ -52,9 +52,33 @@ #define BUF_LEN 512 /** - * Macro compares two strings for equality + * General purpose boolean type. */ -#define streq(x,y) (strcmp(x, y) == 0) +#ifdef HAVE_STDBOOL_H +# include +#else +# ifndef HAVE__BOOL +# define _Bool signed char +# endif /* HAVE__BOOL */ +# define bool _Bool +# define false 0 +# define true 1 +# define __bool_true_false_are_defined 1 +#endif /* HAVE_STDBOOL_H */ +#ifndef FALSE +# define FALSE false +#endif /* FALSE */ +#ifndef TRUE +# define TRUE true +#endif /* TRUE */ + +/** + * Helper function that compares two strings for equality + */ +static inline bool streq(const char *x, const char *y) +{ + return strcmp(x, y) == 0; +} /** * Macro compares two strings for equality, length limited @@ -62,9 +86,12 @@ #define strneq(x,y,len) (strncmp(x, y, len) == 0) /** - * Macro compares two strings for equality ignoring case + * Helper function that compares two strings for equality ignoring case */ -#define strcaseeq(x,y) (strcasecmp(x, y) == 0) +static inline bool strcaseeq(const char *x, const char *y) +{ + return strcasecmp(x, y) == 0; +} /** * Macro compares two strings for equality ignoring case, length limited @@ -202,27 +229,6 @@ static inline char *strdupnull(const char *s) */ #define TIME_32_BIT_SIGNED_MAX 0x7fffffff -/** - * General purpose boolean type. - */ -#ifdef HAVE_STDBOOL_H -# include -#else -# ifndef HAVE__BOOL -# define _Bool signed char -# endif /* HAVE__BOOL */ -# define bool _Bool -# define false 0 -# define true 1 -# define __bool_true_false_are_defined 1 -#endif /* HAVE_STDBOOL_H */ -#ifndef FALSE -# define FALSE false -#endif /* FALSE */ -#ifndef TRUE -# define TRUE true -#endif /* TRUE */ - /** * define some missing fixed width int types on OpenSolaris. * TODO: since the uintXX_t types are defined by the C99 standard we should