mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-01-25 10:12:13 +03:00
everywhere: misc unnecessary var init/update
These are all cases where we initialise or update a variable, and then never use it. None of them particularly matter, as the compiler should optimise them all away during dead store elimination, but some static analysers complain about them and they are extra work for casual readers to follow, so worth removing. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Signed-off-by: Rob Norris <robn@despairlabs.com> Sponsored-by: https://despairlabs.com/sponsor/ Closes #17551
This commit is contained in:
parent
d2b9e66b88
commit
bf38c15071
@ -1991,7 +1991,7 @@ dump_ddt_log(ddt_t *ddt)
|
|||||||
c += strlcpy(&flagstr[c], " UNKNOWN",
|
c += strlcpy(&flagstr[c], " UNKNOWN",
|
||||||
sizeof (flagstr) - c);
|
sizeof (flagstr) - c);
|
||||||
flagstr[1] = '[';
|
flagstr[1] = '[';
|
||||||
flagstr[c++] = ']';
|
flagstr[c] = ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t count = avl_numnodes(&ddl->ddl_tree);
|
uint64_t count = avl_numnodes(&ddl->ddl_tree);
|
||||||
@ -8800,7 +8800,6 @@ zdb_decompress_block(abd_t *pabd, void *buf, void *lbuf, uint64_t lsize,
|
|||||||
(void) buf;
|
(void) buf;
|
||||||
uint64_t orig_lsize = lsize;
|
uint64_t orig_lsize = lsize;
|
||||||
boolean_t tryzle = ((getenv("ZDB_NO_ZLE") == NULL));
|
boolean_t tryzle = ((getenv("ZDB_NO_ZLE") == NULL));
|
||||||
boolean_t found = B_FALSE;
|
|
||||||
/*
|
/*
|
||||||
* We don't know how the data was compressed, so just try
|
* We don't know how the data was compressed, so just try
|
||||||
* every decompress function at every inflated blocksize.
|
* every decompress function at every inflated blocksize.
|
||||||
@ -8843,20 +8842,19 @@ zdb_decompress_block(abd_t *pabd, void *buf, void *lbuf, uint64_t lsize,
|
|||||||
for (cfuncp = cfuncs; *cfuncp; cfuncp++) {
|
for (cfuncp = cfuncs; *cfuncp; cfuncp++) {
|
||||||
if (try_decompress_block(pabd, lsize, psize, flags,
|
if (try_decompress_block(pabd, lsize, psize, flags,
|
||||||
*cfuncp, lbuf, lbuf2)) {
|
*cfuncp, lbuf, lbuf2)) {
|
||||||
found = B_TRUE;
|
tryzle = B_FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*cfuncp != 0)
|
if (*cfuncp != 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!found && tryzle) {
|
if (tryzle) {
|
||||||
for (lsize = orig_lsize; lsize <= maxlsize;
|
for (lsize = orig_lsize; lsize <= maxlsize;
|
||||||
lsize += SPA_MINBLOCKSIZE) {
|
lsize += SPA_MINBLOCKSIZE) {
|
||||||
if (try_decompress_block(pabd, lsize, psize, flags,
|
if (try_decompress_block(pabd, lsize, psize, flags,
|
||||||
ZIO_COMPRESS_ZLE, lbuf, lbuf2)) {
|
ZIO_COMPRESS_ZLE, lbuf, lbuf2)) {
|
||||||
*cfuncp = ZIO_COMPRESS_ZLE;
|
*cfuncp = ZIO_COMPRESS_ZLE;
|
||||||
found = B_TRUE;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,7 +110,7 @@ zed_event_fini(struct zed_conf *zcp)
|
|||||||
static void
|
static void
|
||||||
_bump_event_queue_length(void)
|
_bump_event_queue_length(void)
|
||||||
{
|
{
|
||||||
int zzlm = -1, wr;
|
int zzlm, wr;
|
||||||
char qlen_buf[12] = {0}; /* parameter is int => max "-2147483647\n" */
|
char qlen_buf[12] = {0}; /* parameter is int => max "-2147483647\n" */
|
||||||
long int qlen, orig_qlen;
|
long int qlen, orig_qlen;
|
||||||
|
|
||||||
|
|||||||
@ -1974,9 +1974,8 @@ fill_dataset_info(nvlist_t *list, zfs_handle_t *zhp, boolean_t as_int)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type == ZFS_TYPE_SNAPSHOT) {
|
if (type == ZFS_TYPE_SNAPSHOT) {
|
||||||
char *ds, *snap;
|
char *snap = strdup(zfs_get_name(zhp));
|
||||||
ds = snap = strdup(zfs_get_name(zhp));
|
char *ds = strsep(&snap, "@");
|
||||||
ds = strsep(&snap, "@");
|
|
||||||
fnvlist_add_string(list, "dataset", ds);
|
fnvlist_add_string(list, "dataset", ds);
|
||||||
fnvlist_add_string(list, "snapshot_name", snap);
|
fnvlist_add_string(list, "snapshot_name", snap);
|
||||||
free(ds);
|
free(ds);
|
||||||
@ -2019,8 +2018,7 @@ get_callback(zfs_handle_t *zhp, void *data)
|
|||||||
nvlist_t *user_props = zfs_get_user_props(zhp);
|
nvlist_t *user_props = zfs_get_user_props(zhp);
|
||||||
zprop_list_t *pl = cbp->cb_proplist;
|
zprop_list_t *pl = cbp->cb_proplist;
|
||||||
nvlist_t *propval;
|
nvlist_t *propval;
|
||||||
nvlist_t *item, *d, *props;
|
nvlist_t *item, *d = NULL, *props = NULL;
|
||||||
item = d = props = NULL;
|
|
||||||
const char *strval;
|
const char *strval;
|
||||||
const char *sourceval;
|
const char *sourceval;
|
||||||
boolean_t received = is_recvd_column(cbp);
|
boolean_t received = is_recvd_column(cbp);
|
||||||
@ -5879,7 +5877,7 @@ parse_fs_perm_set(fs_perm_set_t *fspset, nvlist_t *nvl)
|
|||||||
static inline const char *
|
static inline const char *
|
||||||
deleg_perm_comment(zfs_deleg_note_t note)
|
deleg_perm_comment(zfs_deleg_note_t note)
|
||||||
{
|
{
|
||||||
const char *str = "";
|
const char *str;
|
||||||
|
|
||||||
/* subcommands */
|
/* subcommands */
|
||||||
switch (note) {
|
switch (note) {
|
||||||
|
|||||||
@ -379,8 +379,8 @@ process_unique_cmd_columns(vdev_cmd_data_list_t *vcdl)
|
|||||||
static int
|
static int
|
||||||
vdev_process_cmd_output(vdev_cmd_data_t *data, char *line)
|
vdev_process_cmd_output(vdev_cmd_data_t *data, char *line)
|
||||||
{
|
{
|
||||||
char *col = NULL;
|
char *col;
|
||||||
char *val = line;
|
char *val;
|
||||||
char *equals;
|
char *equals;
|
||||||
char **tmp;
|
char **tmp;
|
||||||
|
|
||||||
@ -397,6 +397,7 @@ vdev_process_cmd_output(vdev_cmd_data_t *data, char *line)
|
|||||||
col = line;
|
col = line;
|
||||||
val = equals + 1;
|
val = equals + 1;
|
||||||
} else {
|
} else {
|
||||||
|
col = NULL;
|
||||||
val = line;
|
val = line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1788,7 +1788,7 @@ zpool_do_labelclear(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
char vdev[MAXPATHLEN];
|
char vdev[MAXPATHLEN];
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
int c, fd = -1, ret = 0;
|
int c, fd, ret = 0;
|
||||||
nvlist_t *config;
|
nvlist_t *config;
|
||||||
pool_state_t state;
|
pool_state_t state;
|
||||||
boolean_t inuse = B_FALSE;
|
boolean_t inuse = B_FALSE;
|
||||||
@ -6157,7 +6157,6 @@ static void
|
|||||||
get_interval_count_filter_guids(int *argc, char **argv, float *interval,
|
get_interval_count_filter_guids(int *argc, char **argv, float *interval,
|
||||||
unsigned long *count, iostat_cbdata_t *cb)
|
unsigned long *count, iostat_cbdata_t *cb)
|
||||||
{
|
{
|
||||||
char **tmpargv = argv;
|
|
||||||
int argc_for_interval = 0;
|
int argc_for_interval = 0;
|
||||||
|
|
||||||
/* Is the last arg an interval value? Or a guid? */
|
/* Is the last arg an interval value? Or a guid? */
|
||||||
@ -6181,7 +6180,7 @@ get_interval_count_filter_guids(int *argc, char **argv, float *interval,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Point to our list of possible intervals */
|
/* Point to our list of possible intervals */
|
||||||
tmpargv = &argv[*argc - argc_for_interval];
|
char **tmpargv = &argv[*argc - argc_for_interval];
|
||||||
|
|
||||||
*argc = *argc - argc_for_interval;
|
*argc = *argc - argc_for_interval;
|
||||||
get_interval_count(&argc_for_interval, tmpargv,
|
get_interval_count(&argc_for_interval, tmpargv,
|
||||||
@ -6377,7 +6376,6 @@ zpool_do_iostat(int argc, char **argv)
|
|||||||
int npools;
|
int npools;
|
||||||
float interval = 0;
|
float interval = 0;
|
||||||
unsigned long count = 0;
|
unsigned long count = 0;
|
||||||
int winheight = 24;
|
|
||||||
zpool_list_t *list;
|
zpool_list_t *list;
|
||||||
boolean_t verbose = B_FALSE;
|
boolean_t verbose = B_FALSE;
|
||||||
boolean_t latency = B_FALSE, l_histo = B_FALSE, rq_histo = B_FALSE;
|
boolean_t latency = B_FALSE, l_histo = B_FALSE, rq_histo = B_FALSE;
|
||||||
@ -6673,7 +6671,7 @@ zpool_do_iostat(int argc, char **argv)
|
|||||||
* even when terminal window has its height
|
* even when terminal window has its height
|
||||||
* changed.
|
* changed.
|
||||||
*/
|
*/
|
||||||
winheight = terminal_height();
|
int winheight = terminal_height();
|
||||||
/*
|
/*
|
||||||
* Are we connected to TTY? If not, headers_once
|
* Are we connected to TTY? If not, headers_once
|
||||||
* should be true, to avoid breaking scripts.
|
* should be true, to avoid breaking scripts.
|
||||||
@ -10706,7 +10704,6 @@ status_callback_json(zpool_handle_t *zhp, void *data)
|
|||||||
uint_t c;
|
uint_t c;
|
||||||
vdev_stat_t *vs;
|
vdev_stat_t *vs;
|
||||||
nvlist_t *item, *d, *load_info, *vds;
|
nvlist_t *item, *d, *load_info, *vds;
|
||||||
item = d = NULL;
|
|
||||||
|
|
||||||
/* If dedup stats were requested, also fetch dedupcached. */
|
/* If dedup stats were requested, also fetch dedupcached. */
|
||||||
if (cbp->cb_dedup_stats > 1)
|
if (cbp->cb_dedup_stats > 1)
|
||||||
|
|||||||
@ -574,7 +574,6 @@ get_replication(nvlist_t *nvroot, boolean_t fatal)
|
|||||||
nvlist_t *cnv = child[c];
|
nvlist_t *cnv = child[c];
|
||||||
const char *path;
|
const char *path;
|
||||||
struct stat64 statbuf;
|
struct stat64 statbuf;
|
||||||
int64_t size = -1LL;
|
|
||||||
const char *childtype;
|
const char *childtype;
|
||||||
int fd, err;
|
int fd, err;
|
||||||
|
|
||||||
@ -656,7 +655,7 @@ get_replication(nvlist_t *nvroot, boolean_t fatal)
|
|||||||
statbuf.st_size == MAXOFFSET_T)
|
statbuf.st_size == MAXOFFSET_T)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
size = statbuf.st_size;
|
int64_t size = statbuf.st_size;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Also make sure that devices and
|
* Also make sure that devices and
|
||||||
@ -1365,7 +1364,7 @@ is_grouping(const char *type, int *mindev, int *maxdev)
|
|||||||
static int
|
static int
|
||||||
draid_config_by_type(nvlist_t *nv, const char *type, uint64_t children)
|
draid_config_by_type(nvlist_t *nv, const char *type, uint64_t children)
|
||||||
{
|
{
|
||||||
uint64_t nparity = 1;
|
uint64_t nparity;
|
||||||
uint64_t nspares = 0;
|
uint64_t nspares = 0;
|
||||||
uint64_t ndata = UINT64_MAX;
|
uint64_t ndata = UINT64_MAX;
|
||||||
uint64_t ngroups = 1;
|
uint64_t ngroups = 1;
|
||||||
|
|||||||
@ -919,7 +919,7 @@ ztest_parse_name_value(const char *input, ztest_shared_opts_t *zo)
|
|||||||
{
|
{
|
||||||
char name[32];
|
char name[32];
|
||||||
char *value;
|
char *value;
|
||||||
int state = ZTEST_VDEV_CLASS_RND;
|
int state;
|
||||||
|
|
||||||
(void) strlcpy(name, input, sizeof (name));
|
(void) strlcpy(name, input, sizeof (name));
|
||||||
|
|
||||||
|
|||||||
@ -102,7 +102,7 @@ static inline void *
|
|||||||
umem_alloc_aligned(size_t size, size_t align, int flags)
|
umem_alloc_aligned(size_t size, size_t align, int flags)
|
||||||
{
|
{
|
||||||
void *ptr = NULL;
|
void *ptr = NULL;
|
||||||
int rc = EINVAL;
|
int rc;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
rc = posix_memalign(&ptr, align, size);
|
rc = posix_memalign(&ptr, align, size);
|
||||||
|
|||||||
@ -584,7 +584,7 @@ get_key_material_https(libzfs_handle_t *hdl, const char *uri,
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
int kfd = -1;
|
int kfd;
|
||||||
#ifdef O_TMPFILE
|
#ifdef O_TMPFILE
|
||||||
kfd = open(getenv("TMPDIR") ?: "/tmp",
|
kfd = open(getenv("TMPDIR") ?: "/tmp",
|
||||||
O_RDWR | O_TMPFILE | O_EXCL | O_CLOEXEC, 0600);
|
O_RDWR | O_TMPFILE | O_EXCL | O_CLOEXEC, 0600);
|
||||||
|
|||||||
@ -896,7 +896,7 @@ int
|
|||||||
zpool_set_prop(zpool_handle_t *zhp, const char *propname, const char *propval)
|
zpool_set_prop(zpool_handle_t *zhp, const char *propname, const char *propval)
|
||||||
{
|
{
|
||||||
zfs_cmd_t zc = {"\0"};
|
zfs_cmd_t zc = {"\0"};
|
||||||
int ret = -1;
|
int ret;
|
||||||
char errbuf[ERRBUFLEN];
|
char errbuf[ERRBUFLEN];
|
||||||
nvlist_t *nvl = NULL;
|
nvlist_t *nvl = NULL;
|
||||||
nvlist_t *realprops;
|
nvlist_t *realprops;
|
||||||
@ -4310,7 +4310,7 @@ zpool_set_guid(zpool_handle_t *zhp, const uint64_t *guid)
|
|||||||
libzfs_handle_t *hdl = zhp->zpool_hdl;
|
libzfs_handle_t *hdl = zhp->zpool_hdl;
|
||||||
nvlist_t *nvl = NULL;
|
nvlist_t *nvl = NULL;
|
||||||
zfs_cmd_t zc = {"\0"};
|
zfs_cmd_t zc = {"\0"};
|
||||||
int error = -1;
|
int error;
|
||||||
|
|
||||||
if (guid != NULL) {
|
if (guid != NULL) {
|
||||||
if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, 0) != 0)
|
if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, 0) != 0)
|
||||||
|
|||||||
@ -1067,8 +1067,8 @@ zvol_rename_minors(spa_t *spa, const char *oldname, const char *newname,
|
|||||||
int
|
int
|
||||||
zfs_file_open(const char *path, int flags, int mode, zfs_file_t **fpp)
|
zfs_file_open(const char *path, int flags, int mode, zfs_file_t **fpp)
|
||||||
{
|
{
|
||||||
int fd = -1;
|
int fd;
|
||||||
int dump_fd = -1;
|
int dump_fd;
|
||||||
int err;
|
int err;
|
||||||
int old_umask = 0;
|
int old_umask = 0;
|
||||||
zfs_file_t *fp;
|
zfs_file_t *fp;
|
||||||
|
|||||||
@ -1304,7 +1304,7 @@ zap_increment_int(objset_t *os, uint64_t obj, uint64_t key, int64_t delta,
|
|||||||
int
|
int
|
||||||
fzap_cursor_retrieve(zap_t *zap, zap_cursor_t *zc, zap_attribute_t *za)
|
fzap_cursor_retrieve(zap_t *zap, zap_cursor_t *zc, zap_attribute_t *za)
|
||||||
{
|
{
|
||||||
int err = ENOENT;
|
int err;
|
||||||
zap_entry_handle_t zeh;
|
zap_entry_handle_t zeh;
|
||||||
zap_leaf_t *l;
|
zap_leaf_t *l;
|
||||||
|
|
||||||
|
|||||||
@ -4408,7 +4408,7 @@ int
|
|||||||
zio_alloc_zil(spa_t *spa, objset_t *os, uint64_t txg, blkptr_t *new_bp,
|
zio_alloc_zil(spa_t *spa, objset_t *os, uint64_t txg, blkptr_t *new_bp,
|
||||||
uint64_t size, boolean_t *slog)
|
uint64_t size, boolean_t *slog)
|
||||||
{
|
{
|
||||||
int error = 1;
|
int error;
|
||||||
zio_alloc_list_t io_alloc_list;
|
zio_alloc_list_t io_alloc_list;
|
||||||
|
|
||||||
ASSERT(txg > spa_syncing_txg(spa));
|
ASSERT(txg > spa_syncing_txg(spa));
|
||||||
|
|||||||
@ -569,11 +569,10 @@ zfs_zstd_compress_buf(void *s_start, void *d_start, size_t s_len, size_t d_len,
|
|||||||
size_t actual_abort_size = zstd_abort_size;
|
size_t actual_abort_size = zstd_abort_size;
|
||||||
if (zstd_earlyabort_pass > 0 && zstd_level >= zstd_cutoff_level &&
|
if (zstd_earlyabort_pass > 0 && zstd_level >= zstd_cutoff_level &&
|
||||||
s_len >= actual_abort_size) {
|
s_len >= actual_abort_size) {
|
||||||
int pass_len = 1;
|
|
||||||
abd_t sabd, dabd;
|
abd_t sabd, dabd;
|
||||||
abd_get_from_buf_struct(&sabd, s_start, s_len);
|
abd_get_from_buf_struct(&sabd, s_start, s_len);
|
||||||
abd_get_from_buf_struct(&dabd, d_start, d_len);
|
abd_get_from_buf_struct(&dabd, d_start, d_len);
|
||||||
pass_len = zfs_lz4_compress(&sabd, &dabd, s_len, d_len, 0);
|
int pass_len = zfs_lz4_compress(&sabd, &dabd, s_len, d_len, 0);
|
||||||
abd_free(&dabd);
|
abd_free(&dabd);
|
||||||
abd_free(&sabd);
|
abd_free(&sabd);
|
||||||
if (pass_len < d_len) {
|
if (pass_len < d_len) {
|
||||||
|
|||||||
@ -301,7 +301,7 @@ static int
|
|||||||
write_idmap(pid_t pid, char *buf, size_t buf_size, idmap_type_t type)
|
write_idmap(pid_t pid, char *buf, size_t buf_size, idmap_type_t type)
|
||||||
{
|
{
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
int fd = -EBADF;
|
int fd;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
(void) snprintf(path, sizeof (path), "/proc/%d/%cid_map",
|
(void) snprintf(path, sizeof (path), "/proc/%d/%cid_map",
|
||||||
|
|||||||
@ -152,7 +152,7 @@ getfdname(char *pdir, char type, int level, int dir, int file)
|
|||||||
static void
|
static void
|
||||||
crtfile(char *pname)
|
crtfile(char *pname)
|
||||||
{
|
{
|
||||||
int fd = -1;
|
int fd;
|
||||||
int i, size;
|
int i, size;
|
||||||
const char *context = "0123456789ABCDF";
|
const char *context = "0123456789ABCDF";
|
||||||
char *pbuf;
|
char *pbuf;
|
||||||
|
|||||||
@ -59,7 +59,7 @@ static void *
|
|||||||
normal_writer(void *filename)
|
normal_writer(void *filename)
|
||||||
{
|
{
|
||||||
char *file_path = filename;
|
char *file_path = filename;
|
||||||
int fd = -1;
|
int fd;
|
||||||
ssize_t write_num = 0;
|
ssize_t write_num = 0;
|
||||||
int page_size = getpagesize();
|
int page_size = getpagesize();
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ normal_writer(void *filename)
|
|||||||
static void *
|
static void *
|
||||||
map_writer(void *filename)
|
map_writer(void *filename)
|
||||||
{
|
{
|
||||||
int fd = -1;
|
int fd;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
int page_size = getpagesize();
|
int page_size = getpagesize();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user