public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] eject: move unreachable code to preprocessor #else block [smatch scan]
@ 2014-10-15 21:19 Sami Kerola
  2014-10-15 21:19 ` [PATCH 2/4] setterm: fix dubious one-bit signed bitfield " Sami Kerola
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Sami Kerola @ 2014-10-15 21:19 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

eject.c:466 toggle_tray() info: ignoring unreachable code.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 sys-utils/eject.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys-utils/eject.c b/sys-utils/eject.c
index 91f1102..860610f 100644
--- a/sys-utils/eject.c
+++ b/sys-utils/eject.c
@@ -433,9 +433,6 @@ static int eject_cdrom(int fd)
  */
 static void toggle_tray(int fd)
 {
-	struct timeval time_start, time_stop;
-	int time_elapsed;
-
 #ifdef CDROM_DRIVE_STATUS
 	/* First ask the CDROM for info, otherwise fall back to manual.  */
 	switch (ioctl(fd, CDROM_DRIVE_STATUS)) {
@@ -457,7 +454,9 @@ static void toggle_tray(int fd)
 	default:
 		abort();
 	}
-#endif
+#else
+	struct timeval time_start, time_stop;
+	int time_elapsed;
 
 	/* Try to open the CDROM tray and measure the time therefor
 	 * needed.  In my experience the function needs less than 0.05
@@ -481,6 +480,7 @@ static void toggle_tray(int fd)
 	 * closed before. This would mean that we are done.  */
 	if (time_elapsed < TRAY_WAS_ALREADY_OPEN_USECS)
 		close_tray(fd);
+#endif
 }
 
 /*
-- 
2.1.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] setterm: fix dubious one-bit signed bitfield [smatch scan]
  2014-10-15 21:19 [PATCH 1/4] eject: move unreachable code to preprocessor #else block [smatch scan] Sami Kerola
@ 2014-10-15 21:19 ` Sami Kerola
  2014-10-15 21:19 ` [PATCH 3/4] ul: fix filter() indentation Sami Kerola
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Sami Kerola @ 2014-10-15 21:19 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

term-utils/setterm.c:165:24: error: dubious one-bit signed bitfield

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 term-utils/setterm.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/term-utils/setterm.c b/term-utils/setterm.c
index f21466e..fefb0a9 100644
--- a/term-utils/setterm.c
+++ b/term-utils/setterm.c
@@ -162,9 +162,10 @@ struct setterm_control {
 	/* colors */
 	int opt_fo_color:4, opt_ba_color:4, opt_ul_color:4, opt_hb_color:4;
 	/* boolean options */
-	int opt_cu_on:1, opt_li_on:1, opt_bo_on:1, opt_hb_on:1, opt_bl_on:1,
-	    opt_re_on:1, opt_un_on:1, opt_rep_on:1, opt_appck_on:1,
-	    opt_invsc_on:1, opt_msg_on:1, opt_cl_all:1, vcterm:1;
+	unsigned int opt_cu_on:1, opt_li_on:1, opt_bo_on:1, opt_hb_on:1,
+	    opt_bl_on:1, opt_re_on:1, opt_un_on:1, opt_rep_on:1,
+	    opt_appck_on:1, opt_invsc_on:1, opt_msg_on:1, opt_cl_all:1,
+	    vcterm:1;
 	/* Option flags.  Set when an option is invoked. */
 	uint64_t opt_term:1, opt_reset:1, opt_initialize:1, opt_cursor:1,
 	    opt_linewrap:1, opt_default:1, opt_foreground:1,
-- 
2.1.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] ul: fix filter() indentation
  2014-10-15 21:19 [PATCH 1/4] eject: move unreachable code to preprocessor #else block [smatch scan] Sami Kerola
  2014-10-15 21:19 ` [PATCH 2/4] setterm: fix dubious one-bit signed bitfield " Sami Kerola
@ 2014-10-15 21:19 ` Sami Kerola
  2014-10-15 21:19 ` [PATCH 4/4] sfdisk: fix compiler warnings about uninitialized variables Sami Kerola
  2014-10-20 12:10 ` [PATCH 1/4] eject: move unreachable code to preprocessor #else block [smatch scan] Karel Zak
  3 siblings, 0 replies; 5+ messages in thread
From: Sami Kerola @ 2014-10-15 21:19 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Content of the while() loop missed one indentation step.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 text-utils/ul.c | 160 ++++++++++++++++++++++++++------------------------------
 1 file changed, 75 insertions(+), 85 deletions(-)

diff --git a/text-utils/ul.c b/text-utils/ul.c
index 054f7b9..20a0551 100644
--- a/text-utils/ul.c
+++ b/text-utils/ul.c
@@ -281,94 +281,84 @@ static void filter(FILE *f)
 	wint_t c;
 	int i, w;
 
-	while ((c = getwc(f)) != WEOF)
-	switch (c) {
-
-	case '\b':
-		setcol(col - 1);
-		continue;
-
-	case '\t':
-		setcol((col+8) & ~07);
-		continue;
-
-	case '\r':
-		setcol(0);
-		continue;
-
-	case SO:
-		mode |= ALTSET;
-		continue;
-
-	case SI:
-		mode &= ~ALTSET;
-		continue;
-
-	case IESC:
-		if(handle_escape(f)) {
-			c = getwc(f);
-			errx(EXIT_FAILURE,
-				_("unknown escape sequence in input: %o, %o"),
-				IESC, c);
-		}
-		continue;
-
-	case '_':
-		if (obuf[col].c_char || obuf[col].c_width < 0) {
-			while(col > 0 && obuf[col].c_width < 0)
-				col--;
-			w = obuf[col].c_width;
-			for (i = 0; i < w; i++)
-				obuf[col++].c_mode |= UNDERL | mode;
-			setcol(col);
+	while ((c = getwc(f)) != WEOF) {
+		switch (c) {
+		case '\b':
+			setcol(col - 1);
 			continue;
-		}
-		obuf[col].c_char = '_';
-		obuf[col].c_width = 1;
-		/* fall through */
-	case ' ':
-		setcol(col + 1);
-		continue;
-
-	case '\n':
-		flushln();
-		continue;
-
-	case '\f':
-		flushln();
-		putwchar('\f');
-		continue;
-
-	default:
-		if (!iswprint(c))
-			/* non printable */
+		case '\t':
+			setcol((col + 8) & ~07);
+			continue;
+		case '\r':
+			setcol(0);
+			continue;
+		case SO:
+			mode |= ALTSET;
+			continue;
+		case SI:
+			mode &= ~ALTSET;
+			continue;
+		case IESC:
+			if (handle_escape(f)) {
+				c = getwc(f);
+				errx(EXIT_FAILURE,
+				     _("unknown escape sequence in input: %o, %o"), IESC, c);
+			}
+			continue;
+		case '_':
+			if (obuf[col].c_char || obuf[col].c_width < 0) {
+				while (col > 0 && obuf[col].c_width < 0)
+					col--;
+				w = obuf[col].c_width;
+				for (i = 0; i < w; i++)
+					obuf[col++].c_mode |= UNDERL | mode;
+				setcol(col);
+				continue;
+			}
+			obuf[col].c_char = '_';
+			obuf[col].c_width = 1;
+			/* fall through */
+		case ' ':
+			setcol(col + 1);
+			continue;
+		case '\n':
+			flushln();
+			continue;
+		case '\f':
+			flushln();
+			putwchar('\f');
+			continue;
+		default:
+			if (!iswprint(c))
+				/* non printable */
+				continue;
+			w = wcwidth(c);
+			needcol(col + w);
+			if (obuf[col].c_char == '\0') {
+				obuf[col].c_char = c;
+				for (i = 0; i < w; i++)
+					obuf[col + i].c_mode = mode;
+				obuf[col].c_width = w;
+				for (i = 1; i < w; i++)
+					obuf[col + i].c_width = -1;
+			} else if (obuf[col].c_char == '_') {
+				obuf[col].c_char = c;
+				for (i = 0; i < w; i++)
+					obuf[col + i].c_mode |= UNDERL | mode;
+				obuf[col].c_width = w;
+				for (i = 1; i < w; i++)
+					obuf[col + i].c_width = -1;
+			} else if ((wint_t) obuf[col].c_char == c) {
+				for (i = 0; i < w; i++)
+					obuf[col + i].c_mode |= BOLD | mode;
+			} else {
+				w = obuf[col].c_width;
+				for (i = 0; i < w; i++)
+					obuf[col + i].c_mode = mode;
+			}
+			setcol(col + w);
 			continue;
-		w = wcwidth(c);
-		needcol(col + w);
-		if (obuf[col].c_char == '\0') {
-			obuf[col].c_char = c;
-			for (i = 0; i < w; i++)
-				obuf[col+i].c_mode = mode;
-			obuf[col].c_width = w;
-			for (i = 1; i < w; i++)
-				obuf[col+i].c_width = -1;
-		} else if (obuf[col].c_char == '_') {
-			obuf[col].c_char = c;
-			for (i = 0; i < w; i++)
-				obuf[col+i].c_mode |= UNDERL|mode;
-			obuf[col].c_width = w;
-			for (i = 1; i < w; i++)
-				obuf[col+i].c_width = -1;
-		} else if ((wint_t) obuf[col].c_char == c) {
-			for (i = 0; i < w; i++)
-				obuf[col+i].c_mode |= BOLD|mode;
-		} else {
-			w = obuf[col].c_width;
-			for (i = 0; i < w; i++)
-				obuf[col+i].c_mode = mode;
 		}
-		setcol(col + w);
-		continue;
 	}
 	if (maxcol)
 		flushln();
-- 
2.1.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] sfdisk: fix compiler warnings about uninitialized variables
  2014-10-15 21:19 [PATCH 1/4] eject: move unreachable code to preprocessor #else block [smatch scan] Sami Kerola
  2014-10-15 21:19 ` [PATCH 2/4] setterm: fix dubious one-bit signed bitfield " Sami Kerola
  2014-10-15 21:19 ` [PATCH 3/4] ul: fix filter() indentation Sami Kerola
@ 2014-10-15 21:19 ` Sami Kerola
  2014-10-20 12:10 ` [PATCH 1/4] eject: move unreachable code to preprocessor #else block [smatch scan] Karel Zak
  3 siblings, 0 replies; 5+ messages in thread
From: Sami Kerola @ 2014-10-15 21:19 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

warning: 'str' may be used uninitialized in this function [-Wmaybe-uninitialized]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 disk-utils/sfdisk.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c
index ad0e17e..49369bd 100644
--- a/disk-utils/sfdisk.c
+++ b/disk-utils/sfdisk.c
@@ -756,7 +756,7 @@ static int command_partuuid(struct sfdisk *sf, int argc, char **argv)
 
 	/* print partition uuid */
 	if (!uuid) {
-		const char *str;
+		const char *str = NULL;
 
 		if (fdisk_get_partition(sf->cxt, partno - 1, &pa) == 0)
 			str = fdisk_partition_get_uuid(pa);
@@ -811,7 +811,7 @@ static int command_partlabel(struct sfdisk *sf, int argc, char **argv)
 
 	/* print partition name */
 	if (!name) {
-		const char *str;
+		const char *str = NULL;
 
 		if (fdisk_get_partition(sf->cxt, partno - 1, &pa) == 0)
 			str = fdisk_partition_get_name(pa);
@@ -867,7 +867,7 @@ static int command_partattrs(struct sfdisk *sf, int argc, char **argv)
 
 	/* print partition name */
 	if (!attrs) {
-		const char *str;
+		const char *str = NULL;
 
 		if (fdisk_get_partition(sf->cxt, partno - 1, &pa) == 0)
 			str = fdisk_partition_get_attrs(pa);
-- 
2.1.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/4] eject: move unreachable code to preprocessor #else block [smatch scan]
  2014-10-15 21:19 [PATCH 1/4] eject: move unreachable code to preprocessor #else block [smatch scan] Sami Kerola
                   ` (2 preceding siblings ...)
  2014-10-15 21:19 ` [PATCH 4/4] sfdisk: fix compiler warnings about uninitialized variables Sami Kerola
@ 2014-10-20 12:10 ` Karel Zak
  3 siblings, 0 replies; 5+ messages in thread
From: Karel Zak @ 2014-10-20 12:10 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Wed, Oct 15, 2014 at 10:19:25PM +0100, Sami Kerola wrote:
> eject.c:466 toggle_tray() info: ignoring unreachable code.

 All 4 patches applied. Thanks.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-10-20 12:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-15 21:19 [PATCH 1/4] eject: move unreachable code to preprocessor #else block [smatch scan] Sami Kerola
2014-10-15 21:19 ` [PATCH 2/4] setterm: fix dubious one-bit signed bitfield " Sami Kerola
2014-10-15 21:19 ` [PATCH 3/4] ul: fix filter() indentation Sami Kerola
2014-10-15 21:19 ` [PATCH 4/4] sfdisk: fix compiler warnings about uninitialized variables Sami Kerola
2014-10-20 12:10 ` [PATCH 1/4] eject: move unreachable code to preprocessor #else block [smatch scan] Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox