diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h index 6c5eba783709af969ec01abe313f363a43860f4a..5ad362e5697dbc8982e0ffe6541b88c438ad6529 100644 --- a/include/asterisk/strings.h +++ b/include/asterisk/strings.h @@ -52,19 +52,13 @@ static force_inline int ast_strlen_zero(const char *s) /*! \brief returns the equivalent of logic or for strings: * first one if not empty, otherwise second one. */ -static force_inline char *S_OR(const char *a, const char *b) -{ - return ast_strlen_zero(a) ? (char *) b : (char *) a; -} +#define S_OR(a, b) ({typeof(&((a)[0])) __x = (a); ast_strlen_zero(__x) ? (b) : __x;}) /*! \brief returns the equivalent of logic or for strings, with an additional boolean check: * second one if not empty and first one is true, otherwise third one. * example: S_COR(usewidget, widget, "<no widget>") */ -static force_inline char *S_COR(unsigned char a, const char *b, const char *c) -{ - return a && !ast_strlen_zero(b) ? (char *) b : (char *) c; -} +#define S_COR(a, b, c) ({typeof(&((b)[0])) __x = (b); (a) && !ast_strlen_zero(__x) ? (__x) : (c);}) /*! \brief Gets a pointer to the first non-whitespace character in a string.