lib/: Use 'restrict' alongside [[gnu::access()]]
const + restrict imply read_only. Cc: Serge Hallyn <serge@hallyn.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
committed by
Serge Hallyn
parent
76e7de3fbb
commit
6bec1cf37c
+2
-1
@@ -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 *);
|
||||
|
||||
/*
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+4
-4
@@ -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 *);
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user