From: Alejandro Colomar Date: Sat, 6 Jan 2024 12:41:16 +0000 (+0100) Subject: lib/: Use 'restrict' alongside [[gnu::access()]] X-Git-Tag: 4.15.0-rc1~41 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6bec1cf37c352463a0363027234929cc6564bf5d;p=thirdparty%2Fshadow.git lib/: Use 'restrict' alongside [[gnu::access()]] const + restrict imply read_only. Cc: Serge Hallyn Signed-off-by: Alejandro Colomar --- diff --git a/lib/commonio.h b/lib/commonio.h index 7cd4f2031..fedbefa3d 100644 --- a/lib/commonio.h +++ b/lib/commonio.h @@ -65,7 +65,8 @@ struct commonio_ops { * understand line continuation conventions). */ ATTR_ACCESS(write_only, 1, 2) - /*@null@*/char *(*fgets)(/*@returned@*/char *s, int n, FILE *stream); + /*@null@*/char *(*fgets)(/*@returned@*/char *restrict s, int n, + FILE *restrict stream); int (*fputs) (const char *, FILE *); /* diff --git a/lib/fputsx.c b/lib/fputsx.c index 0f8aeaa26..056531010 100644 --- a/lib/fputsx.c +++ b/lib/fputsx.c @@ -17,7 +17,7 @@ /*@null@*/char * -fgetsx(/*@returned@*/char *buf, int cnt, FILE * f) +fgetsx(/*@returned@*/char *restrict buf, int cnt, FILE *restrict f) { char *cp = buf; char *ep; diff --git a/lib/getlong.c b/lib/getlong.c index 4c6e376c5..4f393fe30 100644 --- a/lib/getlong.c +++ b/lib/getlong.c @@ -21,7 +21,7 @@ * It supports decimal, hexadecimal or octal representations. */ int -getlong(const char *numstr, long *result) +getlong(const char *restrict numstr, long *restrict result) { char *endptr; long val; diff --git a/lib/getulong.c b/lib/getulong.c index 690525551..2e730e6e8 100644 --- a/lib/getulong.c +++ b/lib/getulong.c @@ -21,7 +21,7 @@ * It supports decimal, hexadecimal or octal representations. */ int -getulong(const char *numstr, unsigned long *result) +getulong(const char *restrict numstr, unsigned long *restrict result) { char *endptr; unsigned long val; diff --git a/lib/prototypes.h b/lib/prototypes.h index 4ba943645..0f709bdd6 100644 --- a/lib/prototypes.h +++ b/lib/prototypes.h @@ -154,7 +154,7 @@ extern /*@only@*//*@null@*/struct group *getgr_nam_gid (/*@null@*/const char *gr /* getlong.c */ ATTR_ACCESS(write_only, 2) -extern int getlong(const char *numstr, long *result); +extern int getlong(const char *restrict numstr, long *restrict result); /* get_pid.c */ extern int get_pid (const char *pidstr, pid_t *pid); @@ -174,11 +174,11 @@ extern int get_uid (const char *uidstr, uid_t *uid); /* getulong.c */ ATTR_ACCESS(write_only, 2) -extern int getulong(const char *numstr, unsigned long *result); +extern int getulong(const char *restrict numstr, unsigned long *restrict result); /* fputsx.c */ ATTR_ACCESS(write_only, 1, 2) -extern /*@null@*/char *fgetsx(/*@returned@*/char *, int, FILE *); +extern /*@null@*/char *fgetsx(/*@returned@*/char *restrict, int, FILE *restrict); extern int fputsx (const char *, FILE *); /* groupio.c */ @@ -438,7 +438,7 @@ extern int shell (const char *file, /*@null@*/const char *arg, char *const envp[ /* spawn.c */ ATTR_ACCESS(write_only, 4) extern int run_command(const char *cmd, const char *argv[], - /*@null@*/const char *envp[], int *status); + /*@null@*/const char *envp[], int *restrict status); /* strtoday.c */ extern long strtoday (const char *); diff --git a/lib/spawn.c b/lib/spawn.c index 2f930ca0a..57a412199 100644 --- a/lib/spawn.c +++ b/lib/spawn.c @@ -19,7 +19,7 @@ int run_command(const char *cmd, const char *argv[], - /*@null@*/const char *envp[], int *status) + /*@null@*/const char *envp[], int *restrict status) { pid_t pid, wpid;