strlcpy_expand_host, sudo_getdelim, sudo_realpath: add restrict qualifier
This commit is contained in:
@@ -342,7 +342,7 @@ sudo_dso_public int sudo_getgrouplist(const char *name, GETGROUPS_T basegid, GET
|
||||
# define getgrouplist(_a, _b, _c, _d) sudo_getgrouplist((_a), (_b), (_c), (_d))
|
||||
#endif /* GETGROUPLIST */
|
||||
#if !defined(HAVE_GETDELIM)
|
||||
sudo_dso_public ssize_t sudo_getdelim(char **bufp, size_t *bufsizep, int delim, FILE *fp);
|
||||
sudo_dso_public ssize_t sudo_getdelim(char ** restrict bufp, size_t * restrict bufsizep, int delim, FILE * restrict fp);
|
||||
# undef getdelim
|
||||
# define getdelim(_a, _b, _c, _d) sudo_getdelim((_a), (_b), (_c), (_d))
|
||||
#elif defined(HAVE_DECL_GETDELIM) && !HAVE_DECL_GETDELIM
|
||||
@@ -533,7 +533,7 @@ sudo_dso_public void *sudo_reallocarray(void *ptr, size_t nmemb, size_t size);
|
||||
# define reallocarray(_a, _b, _c) sudo_reallocarray((_a), (_b), (_c))
|
||||
#endif /* HAVE_REALLOCARRAY */
|
||||
#ifndef HAVE_REALPATH
|
||||
sudo_dso_public char *sudo_realpath(const char *path, char *resolved);
|
||||
sudo_dso_public char *sudo_realpath(const char * restrict path, char * restrict resolved);
|
||||
# undef realpath
|
||||
# define realpath(_a, _b) sudo_realpath((_a), (_b))
|
||||
#endif /* HAVE_REALPATH */
|
||||
|
@@ -33,7 +33,8 @@
|
||||
#include <sudo_compat.h>
|
||||
|
||||
ssize_t
|
||||
sudo_getdelim(char **buf, size_t *bufsize, int delim, FILE *fp)
|
||||
sudo_getdelim(char ** restrict buf, size_t * restrict bufsize, int delim,
|
||||
FILE * restrict fp)
|
||||
{
|
||||
char *cp, *ep;
|
||||
int ch;
|
||||
|
@@ -53,7 +53,7 @@
|
||||
* in which case the path which caused trouble is left in (resolved).
|
||||
*/
|
||||
char *
|
||||
sudo_realpath(const char *path, char *resolved)
|
||||
sudo_realpath(const char * restrict path, char * restrict resolved)
|
||||
{
|
||||
struct stat sb;
|
||||
int idx = 0, nlnk = 0;
|
||||
|
@@ -38,7 +38,8 @@
|
||||
|
||||
sudo_dso_public int main(int argc, char *argv[]);
|
||||
|
||||
ssize_t sudo_getdelim(char **bufp, size_t *bufsizep, int delim, FILE *fp);
|
||||
ssize_t sudo_getdelim(char ** restrict bufp, size_t * restrict bufsizep,
|
||||
int delim, FILE * restrict fp);
|
||||
|
||||
/*
|
||||
* Test that sudo_getdelim() works as expected.
|
||||
|
@@ -5897,7 +5897,8 @@ init_lexer(void)
|
||||
* Like strlcpy() but expand %h escapes.
|
||||
*/
|
||||
static size_t
|
||||
strlcpy_expand_host(char *dst, const char *src, const char *host, size_t size)
|
||||
strlcpy_expand_host(char * restrict dst, const char * restrict src,
|
||||
const char * restrict host, size_t size)
|
||||
{
|
||||
size_t len = 0;
|
||||
char ch;
|
||||
|
@@ -1118,7 +1118,8 @@ init_lexer(void)
|
||||
* Like strlcpy() but expand %h escapes.
|
||||
*/
|
||||
static size_t
|
||||
strlcpy_expand_host(char *dst, const char *src, const char *host, size_t size)
|
||||
strlcpy_expand_host(char * restrict dst, const char * restrict src,
|
||||
const char * restrict host, size_t size)
|
||||
{
|
||||
size_t len = 0;
|
||||
char ch;
|
||||
|
Reference in New Issue
Block a user