# HG changeset patch # User Mike Becker # Date 1663092686 -7200 # Node ID 184e9ebfc3cccac0bfa540664f470e2eab3ea237 # Parent 0f3c9662f9b522ce69ebd80929b3c2bea0b2c680 disallow NULL for cx_str() and cx_mutstr() diff -r 0f3c9662f9b5 -r 184e9ebfc3cc src/cx/string.h --- a/src/cx/string.h Fri Sep 09 20:19:08 2022 +0200 +++ b/src/cx/string.h Tue Sep 13 20:11:26 2022 +0200 @@ -96,19 +96,18 @@ * Wraps a mutable string that must be zero-terminated. * * The length is implicitly inferred by using a call to \c strlen(). - * As a special case, a \c NULL argument is treated like an empty string. * * \note the wrapped string will share the specified pointer to the string. * If you do want a copy, use cx_strdup() on the return value of this function. * * If you need to wrap a constant string, use cx_str(). * - * @param cstring the string to wrap, must be zero-terminated (or \c NULL) + * @param cstring the string to wrap, must be zero-terminated * @return the wrapped string * * @see cx_mutstrn() */ -__attribute__((__warn_unused_result__)) +__attribute__((__warn_unused_result__, __nonnull__)) cxmutstr cx_mutstr(char *cstring); /** @@ -121,7 +120,7 @@ * * If you need to wrap a constant string, use cx_strn(). * - * @param cstring the string to wrap (or \c NULL, if the length is zero) + * @param cstring the string to wrap (or \c NULL, only if the length is zero) * @param length the length of the string * @return the wrapped string * @@ -137,19 +136,18 @@ * Wraps a string that must be zero-terminated. * * The length is implicitly inferred by using a call to \c strlen(). - * As a special case, a \c NULL argument is treated like an empty string. * * \note the wrapped string will share the specified pointer to the string. * If you do want a copy, use cx_strdup() on the return value of this function. * * If you need to wrap a non-constant string, use cx_mutstr(). * - * @param cstring the string to wrap, must be zero-terminated (or \c NULL) + * @param cstring the string to wrap, must be zero-terminated * @return the wrapped string * * @see cx_strn() */ -__attribute__((__warn_unused_result__)) +__attribute__((__warn_unused_result__, __nonnull__)) cxstring cx_str(char const *cstring); @@ -163,7 +161,7 @@ * * If you need to wrap a non-constant string, use cx_mutstrn(). * - * @param cstring the string to wrap (or \c NULL, if the length is zero) + * @param cstring the string to wrap (or \c NULL, only if the length is zero) * @param length the length of the string * @return the wrapped string *