Skip to content

Commit

Permalink
lib/: Use ATTR_STRING() on stpecpy() and strtcpy()
Browse files Browse the repository at this point in the history
These function 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 <[email protected]>
  • Loading branch information
alejandro-colomar committed Nov 26, 2023
1 parent a1a1b13 commit 3bfd1c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/stpecpy.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
#include <stddef.h>
#include <string.h>

#include "defines.h"


ATTR_STRING(3)
inline char *stpecpy(char *dst, char *end, const char *restrict src);


Expand Down
2 changes: 2 additions & 0 deletions lib/strtcpy.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <string.h>
#include <sys/types.h>

#include "defines.h"
#include "sizeof.h"


Expand Down Expand Up @@ -47,6 +48,7 @@
#define STRTCPY(dst, src) strtcpy(dst, src, SIZEOF_ARRAY(dst))


ATTR_STRING(2)
inline ssize_t strtcpy(char *restrict dst, const char *restrict src,
size_t dsize);

Expand Down

0 comments on commit 3bfd1c0

Please sign in to comment.