]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/: Use ATTR_STRING() on stpecpy() and strtcpy()
authorAlejandro Colomar <alx@kernel.org>
Sun, 26 Nov 2023 17:52:56 +0000 (18:52 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Mon, 4 Dec 2023 11:22:47 +0000 (12:22 +0100)
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 <alx@kernel.org>
lib/string/stpecpy.h
lib/string/strtcpy.h

index 640d19c2e35f8e5799aeea9a0a59ce8c6a23426b..2324baa56fdc91d8d25049348d1101f738aed04d 100644 (file)
 #include <stddef.h>
 #include <string.h>
 
+#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);
  *
index 5da62cd59e695f4dbf1b9d1373d765120b17b421..4ff6e1110690b0ed4313fae64fb3869a0ef0dc18 100644 (file)
 #include <string.h>
 #include <sys/types.h>
 
+#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);