From 08016b31854e031ee42dd841fe0e717927210397 Mon Sep 17 00:00:00 2001 From: Mariusz Zaborski Date: Thu, 21 Sep 2017 10:00:16 +0000 Subject: [PATCH] Remove redundant initialization. Don't use variable - just return the value. Make scan-build happy by casting to 'void *' instead of 'void **'. Submitted by: pjd@ MFC after: 1 month Found by: scan-build and cppcheck Sponsored by: Wheel Systems --- lib/libnv/msgio.c | 1 - sys/contrib/libnv/nvlist.c | 14 +++++--------- sys/contrib/libnv/nvpair.c | 1 - 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/libnv/msgio.c b/lib/libnv/msgio.c index 27620a184f9a..283ddccbdd79 100644 --- a/lib/libnv/msgio.c +++ b/lib/libnv/msgio.c @@ -299,7 +299,6 @@ fd_package_recv(int sock, int *fds, size_t nfds) PJDLOG_ASSERT(nfds > 0); PJDLOG_ASSERT(fds != NULL); - i = 0; bzero(&msg, sizeof(msg)); bzero(&iov, sizeof(iov)); diff --git a/sys/contrib/libnv/nvlist.c b/sys/contrib/libnv/nvlist.c index 1481515bba00..8fcc24e40458 100644 --- a/sys/contrib/libnv/nvlist.c +++ b/sys/contrib/libnv/nvlist.c @@ -280,8 +280,7 @@ nvlist_get_pararr(const nvlist_t *nvl, void **cookiep) return (ret); } - ret = nvlist_get_parent(nvl, cookiep); - return (ret); + return (nvlist_get_parent(nvl, cookiep)); } bool @@ -709,7 +708,6 @@ static int * nvlist_xdescriptors(const nvlist_t *nvl, int *descs) { nvpair_t *nvp; - const char *name; int type; NVLIST_ASSERT(nvl); @@ -717,7 +715,7 @@ nvlist_xdescriptors(const nvlist_t *nvl, int *descs) nvp = NULL; do { - while ((name = nvlist_next(nvl, &type, (void**)&nvp)) != NULL) { + while (nvlist_next(nvl, &type, (void *)&nvp) != NULL) { switch (type) { case NV_TYPE_DESCRIPTOR: *descs = nvpair_get_descriptor(nvp); @@ -756,7 +754,7 @@ nvlist_xdescriptors(const nvlist_t *nvl, int *descs) } } } - } while ((nvl = nvlist_get_pararr(nvl, (void**)&nvp)) != NULL); + } while ((nvl = nvlist_get_pararr(nvl, (void *)&nvp)) != NULL); return (descs); } @@ -787,7 +785,6 @@ nvlist_ndescriptors(const nvlist_t *nvl) { #ifndef _KERNEL nvpair_t *nvp; - const char *name; size_t ndescs; int type; @@ -797,7 +794,7 @@ nvlist_ndescriptors(const nvlist_t *nvl) ndescs = 0; nvp = NULL; do { - while ((name = nvlist_next(nvl, &type, (void**)&nvp)) != NULL) { + while (nvlist_next(nvl, &type, (void *)&nvp) != NULL) { switch (type) { case NV_TYPE_DESCRIPTOR: ndescs++; @@ -830,7 +827,7 @@ nvlist_ndescriptors(const nvlist_t *nvl) } } } - } while ((nvl = nvlist_get_pararr(nvl, (void**)&nvp)) != NULL); + } while ((nvl = nvlist_get_pararr(nvl, (void *)&nvp)) != NULL); return (ndescs); #else @@ -1258,7 +1255,6 @@ nvlist_send(int sock, const nvlist_t *nvl) return (-1); ret = -1; - data = NULL; fdidx = 0; data = nvlist_xpack(nvl, &fdidx, &datasize); diff --git a/sys/contrib/libnv/nvpair.c b/sys/contrib/libnv/nvpair.c index ae7c9bf04a0e..a2128706d258 100644 --- a/sys/contrib/libnv/nvpair.c +++ b/sys/contrib/libnv/nvpair.c @@ -1412,7 +1412,6 @@ nvpair_create_nvlist_array(const char *name, const nvlist_t * const *value, nvp = NULL; nvls = NULL; - ii = 0; if (value == NULL || nitems == 0) { ERRNO_SET(EINVAL);