From: Alejandro Colomar Date: Sun, 26 Nov 2023 17:52:56 +0000 (+0100) Subject: lib/: Use ATTR_STRING() on stpecpy() and strtcpy() X-Git-Tag: 4.15.0-rc1~88 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93a5c47c2cb91cb79b3ae991d3ab70c6cba9fa86;p=thirdparty%2Fshadow.git lib/: Use ATTR_STRING() on stpecpy() and strtcpy() These functions consume a source string. Document that. There's no way to mark that they also produce a string in dst, though. That will be up to the static analyzer to guess. Signed-off-by: Alejandro Colomar --- diff --git a/lib/string/stpecpy.h b/lib/string/stpecpy.h index 640d19c2e..2324baa56 100644 --- a/lib/string/stpecpy.h +++ b/lib/string/stpecpy.h @@ -17,12 +17,16 @@ #include #include +#include "attr.h" + +ATTR_STRING(3) inline char *stpecpy(char *dst, char *end, const char *restrict src); /* * SYNOPSIS + * [[gnu::null_terminated_string_arg(3)]] * char *_Nullable stpecpy(char *_Nullable dst, char end[0], * const char *restrict src); * diff --git a/lib/string/strtcpy.h b/lib/string/strtcpy.h index 5da62cd59..4ff6e1110 100644 --- a/lib/string/strtcpy.h +++ b/lib/string/strtcpy.h @@ -15,11 +15,14 @@ #include #include +#include "attr.h" +#include "defines.h" #include "sizeof.h" /* * SYNOPSIS + * [[gnu::null_terminated_string_arg(2)]] * int STRTCPY(char dst[restrict], const char *restrict src); * * ARGUMENTS @@ -47,6 +50,7 @@ #define STRTCPY(dst, src) strtcpy(dst, src, NITEMS(dst)) +ATTR_STRING(2) inline ssize_t strtcpy(char *restrict dst, const char *restrict src, size_t dsize);