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))
|
# define getgrouplist(_a, _b, _c, _d) sudo_getgrouplist((_a), (_b), (_c), (_d))
|
||||||
#endif /* GETGROUPLIST */
|
#endif /* GETGROUPLIST */
|
||||||
#if !defined(HAVE_GETDELIM)
|
#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
|
# undef getdelim
|
||||||
# define getdelim(_a, _b, _c, _d) sudo_getdelim((_a), (_b), (_c), (_d))
|
# define getdelim(_a, _b, _c, _d) sudo_getdelim((_a), (_b), (_c), (_d))
|
||||||
#elif defined(HAVE_DECL_GETDELIM) && !HAVE_DECL_GETDELIM
|
#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))
|
# define reallocarray(_a, _b, _c) sudo_reallocarray((_a), (_b), (_c))
|
||||||
#endif /* HAVE_REALLOCARRAY */
|
#endif /* HAVE_REALLOCARRAY */
|
||||||
#ifndef HAVE_REALPATH
|
#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
|
# undef realpath
|
||||||
# define realpath(_a, _b) sudo_realpath((_a), (_b))
|
# define realpath(_a, _b) sudo_realpath((_a), (_b))
|
||||||
#endif /* HAVE_REALPATH */
|
#endif /* HAVE_REALPATH */
|
||||||
|
@@ -33,7 +33,8 @@
|
|||||||
#include <sudo_compat.h>
|
#include <sudo_compat.h>
|
||||||
|
|
||||||
ssize_t
|
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;
|
char *cp, *ep;
|
||||||
int ch;
|
int ch;
|
||||||
|
@@ -53,7 +53,7 @@
|
|||||||
* in which case the path which caused trouble is left in (resolved).
|
* in which case the path which caused trouble is left in (resolved).
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
sudo_realpath(const char *path, char *resolved)
|
sudo_realpath(const char * restrict path, char * restrict resolved)
|
||||||
{
|
{
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
int idx = 0, nlnk = 0;
|
int idx = 0, nlnk = 0;
|
||||||
|
@@ -38,7 +38,8 @@
|
|||||||
|
|
||||||
sudo_dso_public int main(int argc, char *argv[]);
|
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.
|
* Test that sudo_getdelim() works as expected.
|
||||||
|
@@ -5897,7 +5897,8 @@ init_lexer(void)
|
|||||||
* Like strlcpy() but expand %h escapes.
|
* Like strlcpy() but expand %h escapes.
|
||||||
*/
|
*/
|
||||||
static size_t
|
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;
|
size_t len = 0;
|
||||||
char ch;
|
char ch;
|
||||||
|
@@ -1118,7 +1118,8 @@ init_lexer(void)
|
|||||||
* Like strlcpy() but expand %h escapes.
|
* Like strlcpy() but expand %h escapes.
|
||||||
*/
|
*/
|
||||||
static size_t
|
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;
|
size_t len = 0;
|
||||||
char ch;
|
char ch;
|
||||||
|
Reference in New Issue
Block a user