[PATCH 2/2] misc: fix redundant assignment and reassignments before use [cppcheck]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 lib/procutils.c        | 2 +-
 sys-utils/blkdiscard.c | 2 +-
 sys-utils/fstrim.c     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/procutils.c b/lib/procutils.c
index 00b977c..48ee7cf 100644
--- a/lib/procutils.c
+++ b/lib/procutils.c
@@ -103,7 +103,7 @@ char *proc_get_command(pid_t pid)
 	char buf[BUFSIZ], *res = NULL;
 	ssize_t sz = 0;
 	size_t i;
-	int fd = -1;
+	int fd;
 
 	snprintf(buf, sizeof(buf), "/proc/%d/cmdline", (int) pid);
 	fd = open(buf, O_RDONLY);
diff --git a/sys-utils/blkdiscard.c b/sys-utils/blkdiscard.c
index 3ee0b5d..150689a 100644
--- a/sys-utils/blkdiscard.c
+++ b/sys-utils/blkdiscard.c
@@ -185,7 +185,7 @@ int main(int argc, char **argv)
 	stats[0] = range[0], stats[1] = 0;
 	gettime_monotonic(&last);
 
-	for (range[0] = range[0]; range[0] < end; range[0] += range[1]) {
+	for (/* nothing */; range[0] < end; range[0] += range[1]) {
 		if (range[0] + range[1] > end)
 			range[1] = end - range[0];
 
diff --git a/sys-utils/fstrim.c b/sys-utils/fstrim.c
index c91141e..6bbf1c9 100644
--- a/sys-utils/fstrim.c
+++ b/sys-utils/fstrim.c
@@ -60,7 +60,7 @@ struct fstrim_range {
 static int fstrim_filesystem(const char *path, struct fstrim_range *rangetpl,
 			    int verbose)
 {
-	int fd = -1, rc;
+	int fd, rc;
 	struct stat sb;
 	struct fstrim_range range;
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux