Skip to content

Commit a636267

Browse files
committed
Fixed missing reference to strchrnul on macOS
``` logging.c:651:28: error: 'strchrnul' is only available on macOS 15.4 or newer [-Werror,-Wunguarded-availability-new] 651 | char *next_token = strchrnul(token, ','); | ^~~~~~~~~ /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_string.h:198:9: note: 'strchrnul' has been marked as being introduced in macOS 15.4 here, but the deployment target is macOS 15.0.0 198 | strchrnul(const char *__s, int __c); | ^ logging.c:651:28: note: enclose 'strchrnul' in a __builtin_available check to silence this warning 651 | char *next_token = strchrnul(token, ','); | ^~~~~~~~~ 1 error generated. ``` Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent 1d26c08 commit a636267

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

libutils/platform.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,19 @@ ULONGLONG WINAPI GetTickCount64(void);
229229

230230
#endif
231231

232+
#if !HAVE_STRCHRNUL
233+
/**
234+
* @brief The strchrnul() function is like strchr() except that if c is not
235+
* found in s, then it returns a pointer to the null byte at the end of s,
236+
* rather than NULL.
237+
*/
238+
static inline char *strchrnul(const char *s, int c)
239+
{
240+
const char *r = strchr(s, c);
241+
return (r == NULL) ? (s + (strlen(s) - 1)) : r;
242+
}
243+
#endif
244+
232245
#if !HAVE_DECL_DIRFD
233246
int dirfd(DIR *dirp);
234247
#endif

0 commit comments

Comments
 (0)