Quiet a few harmless cppcheck warnings.

This commit is contained in:
Todd C. Miller
2021-01-06 13:01:10 -07:00
parent 84b3a1dae1
commit 92c88d4105
9 changed files with 22 additions and 19 deletions

View File

@@ -123,7 +123,7 @@ resolve_editor(const char *ed, size_t edlen, int nfiles, char **files,
int *argc_out, char ***argv_out, char * const *allowlist)
{
char **nargv = NULL, *editor = NULL, *editor_path = NULL;
const char *cp, *ep, *tmp;
const char *tmp, *cp, *ep = NULL;
const char *edend = ed + edlen;
struct stat user_editor_sb;
int nargc;

View File

@@ -177,7 +177,7 @@ sudoers_defaults_list_to_tags(struct defaults_list *defs, struct cmndtag *tags)
struct defaults *d;
debug_decl(sudoers_defaults_list_to_tags, SUDOERS_DEBUG_UTIL);
TAGS_INIT(*tags);
TAGS_INIT(tags);
if (defs != NULL) {
TAILQ_FOREACH(d, defs, entries) {
if (!sudoers_defaults_to_tags(d->var, d->val, d->op, tags)) {

View File

@@ -2565,7 +2565,7 @@ yyreduce:
case 92: /* cmndtag: %empty */
#line 785 "gram.y"
{
TAGS_INIT((yyval.tag));
TAGS_INIT(&(yyval.tag));
}
#line 2565 "gram.c"
break;

View File

@@ -783,7 +783,7 @@ options : /* empty */ {
;
cmndtag : /* empty */ {
TAGS_INIT($$);
TAGS_INIT(&$$);
}
| cmndtag NOPASSWD {
$$.nopasswd = true;

View File

@@ -458,7 +458,7 @@ sudo_ldap_role_to_priv(const char *cn, void *hosts, void *runasusers,
TAILQ_INSERT_TAIL(&priv->cmndlist, cmndspec, entries);
/* Initialize cmndspec */
TAGS_INIT(cmndspec->tags);
TAGS_INIT(&cmndspec->tags);
cmndspec->notbefore = UNSPEC;
cmndspec->notafter = UNSPEC;
cmndspec->timeout = UNSPEC;

View File

@@ -42,13 +42,13 @@
* Initialize all tags to UNSPEC.
*/
#define TAGS_INIT(t) do { \
(t).follow = UNSPEC; \
(t).log_input = UNSPEC; \
(t).log_output = UNSPEC; \
(t).noexec = UNSPEC; \
(t).nopasswd = UNSPEC; \
(t).send_mail = UNSPEC; \
(t).setenv = UNSPEC; \
(t)->follow = UNSPEC; \
(t)->log_input = UNSPEC; \
(t)->log_output = UNSPEC; \
(t)->noexec = UNSPEC; \
(t)->nopasswd = UNSPEC; \
(t)->send_mail = UNSPEC; \
(t)->setenv = UNSPEC; \
} while (0)
/*

View File

@@ -98,7 +98,7 @@ get_starttime(pid_t pid, struct timespec *starttime)
mib[3] = (int)pid;
mib[4] = sizeof(*ki_proc);
mib[5] = 1;
do {
for (;;) {
struct sudo_kinfo_proc *kp;
size += size / 10;
@@ -108,7 +108,9 @@ get_starttime(pid_t pid, struct timespec *starttime)
}
ki_proc = kp;
rc = sysctl(mib, sudo_kp_namelen, ki_proc, &size, NULL, 0);
} while (rc == -1 && errno == ENOMEM);
if (rc != -1 || errno != ENOMEM)
break;
}
if (rc != -1) {
#if defined(HAVE_KINFO_PROC_FREEBSD)
/* FreeBSD and Dragonfly */

View File

@@ -356,8 +356,7 @@ sudo_getgrouplist2_v1(const char *name, GETGROUPS_T basegid,
GETGROUPS_T **groupsp, int *ngroupsp)
{
GETGROUPS_T *groups = *groupsp;
int grpsize = *ngroupsp;
int i, ngroups = 1;
int i, grpsize, ngroups = 1;
int ret = -1;
struct group *grp;
@@ -372,7 +371,7 @@ sudo_getgrouplist2_v1(const char *name, GETGROUPS_T basegid,
grpsize <<= 2;
} else {
/* Static group vector. */
if (grpsize < 1)
if ((grpsize = *ngroupsp) < 1)
return -1;
}

View File

@@ -111,7 +111,7 @@ get_process_ttyname(char *name, size_t namelen)
mib[3] = (int)getpid();
mib[4] = sizeof(*ki_proc);
mib[5] = 1;
do {
for (;;) {
struct sudo_kinfo_proc *kp;
size += size / 10;
@@ -121,7 +121,9 @@ get_process_ttyname(char *name, size_t namelen)
}
ki_proc = kp;
rc = sysctl(mib, sudo_kp_namelen, ki_proc, &size, NULL, 0);
} while (rc == -1 && errno == ENOMEM);
if (rc != -1 || errno != ENOMEM)
break;
}
errno = ENOENT;
if (rc != -1) {
if ((dev_t)ki_proc->sudo_kp_tdev != (dev_t)-1) {