Eliminate a few harmless dead stores.

Quiets warnings from Infer.
This commit is contained in:
Todd C. Miller
2022-11-22 11:18:24 -07:00
parent 2f97da316e
commit f066ff9e01
13 changed files with 19 additions and 19 deletions

View File

@@ -156,7 +156,7 @@ json_append_string(struct json_container *jsonc, const char *str)
break;
}
*cp++ = ch;
*cp++ = '\0';
*cp = '\0';
if (!json_append_buf(jsonc, buf))
debug_return_bool(false);
}

View File

@@ -150,7 +150,7 @@ next_entry:
gr.gr_mem[n] = cp;
cp = strtok_r(NULL, ",", &last);
}
gr.gr_mem[n++] = NULL;
gr.gr_mem[n] = NULL;
} else
gr.gr_mem = NULL;
return &gr;

View File

@@ -328,7 +328,7 @@ alias_make_unique(const char *old_name, int type,
struct sudoers_parse_tree *parse_tree0,
struct sudoers_parse_tree *merged_tree)
{
struct sudoers_parse_tree *parse_tree = parse_tree0;
struct sudoers_parse_tree *parse_tree;
char *cp, *new_name = NULL;
struct alias *a;
long long suffix;

View File

@@ -692,7 +692,7 @@ matches_env_check(const char *var, bool *full_match)
} else {
const char *val = strchr(var, '=');
if (val != NULL)
keepit = !strpbrk(++val, "/%");
keepit = !strpbrk(val + 1, "/%");
}
}
debug_return_int(keepit);

View File

@@ -787,10 +787,8 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation,
}
}
if (!sudoers_debug_register(plugin_path, &debug_files)) {
ret = -1;
if (!sudoers_debug_register(plugin_path, &debug_files))
goto done;
}
/* If we have no command (because -V was specified) just return. */
if (argc == 0)

View File

@@ -204,7 +204,7 @@ static int
sudo_ldap_init(LDAP **ldp, const char *host, int port)
{
LDAP *ld;
int ret = LDAP_CONNECT_ERROR;
int ret;
debug_decl(sudo_ldap_init, SUDOERS_DEBUG_LDAP);
#ifdef HAVE_LDAPSSL_INIT
@@ -281,8 +281,10 @@ sudo_ldap_init(LDAP **ldp, const char *host, int port)
ret = ldap_set_option(ld, LDAP_OPT_HOST_NAME, host);
#else
DPRINTF2("ldap_init(%s, %d)", host, port);
if ((ld = ldap_init((char *)host, port)) == NULL)
if ((ld = ldap_init((char *)host, port)) == NULL) {
ret = LDAP_LOCAL_ERROR;
goto done;
}
ret = LDAP_SUCCESS;
#endif
}

View File

@@ -509,7 +509,7 @@ sudo_krb5_ccname_path(const char *old_ccname)
static bool
sudo_check_krb5_ccname(const char *ccname)
{
int fd = -1;
int fd;
const char *ccname_path;
debug_decl(sudo_check_krb5_ccname, SUDOERS_DEBUG_LDAP);

View File

@@ -1085,7 +1085,7 @@ done:
static bool
fmt_initial_message(struct client_closure *closure)
{
bool ret = true;
bool ret = false;
debug_decl(fmt_initial_message, SUDOERS_DEBUG_UTIL);
closure->state = closure->initial_state;
@@ -1116,7 +1116,6 @@ fmt_initial_message(struct client_closure *closure)
break;
default:
sudo_warnx(U_("%s: unexpected state %d"), __func__, closure->state);
ret = false;
break;
}
debug_return_bool(ret);

View File

@@ -185,7 +185,7 @@ static bool
open_cmnd(const char *path, const char *runchroot,
const struct command_digest_list *digests, int *fdp)
{
int fd = -1;
int fd;
char pathbuf[PATH_MAX];
debug_decl(open_cmnd, SUDOERS_DEBUG_MATCH);

View File

@@ -68,7 +68,7 @@ strvec_join(char *const argv[], char sep, size_t (*cpy)(char *, const char *, si
*dst++ = sep;
size--;
}
*--dst = '\0';
dst[-1] = '\0';
debug_return_str(result);
}

View File

@@ -300,7 +300,7 @@ next_entry:
gr.gr_mem[n] = cp;
cp = strtok_r(NULL, ",", &last);
}
gr.gr_mem[n++] = NULL;
gr.gr_mem[n] = NULL;
} else
gr.gr_mem = NULL;
return &gr;

View File

@@ -540,7 +540,7 @@ edit_sudoers(struct sudoersfile *sp, char *editor, int editor_argc,
}
editor_argv[ac++] = (char *)"--";
editor_argv[ac++] = sp->tpath;
editor_argv[ac++] = NULL;
editor_argv[ac] = NULL;
/*
* Do the edit:

View File

@@ -355,7 +355,7 @@ os_init_common(int argc, char *argv[], char *envp[])
static void
fix_fds(void)
{
int miss[3], devnull = -1;
int miss[3];
debug_decl(fix_fds, SUDO_DEBUG_UTIL);
/*
@@ -366,7 +366,8 @@ fix_fds(void)
miss[STDOUT_FILENO] = fcntl(STDOUT_FILENO, F_GETFL, 0) == -1;
miss[STDERR_FILENO] = fcntl(STDERR_FILENO, F_GETFL, 0) == -1;
if (miss[STDIN_FILENO] || miss[STDOUT_FILENO] || miss[STDERR_FILENO]) {
devnull = open(_PATH_DEVNULL, O_RDWR, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
int devnull =
open(_PATH_DEVNULL, O_RDWR, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
if (devnull == -1)
sudo_fatal(U_("unable to open %s"), _PATH_DEVNULL);
if (miss[STDIN_FILENO] && dup2(devnull, STDIN_FILENO) == -1)
@@ -1105,7 +1106,7 @@ format_plugin_settings(struct plugin_container *plugin)
goto bad;
}
}
plugin_settings[++i] = NULL;
plugin_settings[i + 1] = NULL;
/* Add to list of vectors to be garbage collected at exit. */
if (!gc_add(GC_VECTOR, plugin_settings))