linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ihex: restore missing default in switch statement
@ 2015-03-04 14:24 Nicolas Iooss
  2015-03-04 22:18 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Nicolas Iooss @ 2015-03-04 14:24 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, Nicolas Iooss

Commit 2473238eac95 ("ihex: add support for CS:IP/EIP records") removes
the "default:" statement in the switch block, making the "return
usage();" line dead code and ihex2fw silently ignoring unknown options.
Restore this statement.

This bug was found by building with HOSTCC=clang and adding
-Wunreachable-code-return to HOSTCFLAGS.

Fixes: 2473238eac95 ("ihex: add support for CS:IP/EIP records")
Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
---
 firmware/ihex2fw.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/firmware/ihex2fw.c b/firmware/ihex2fw.c
index cf38e159131a..08d90e25abf0 100644
--- a/firmware/ihex2fw.c
+++ b/firmware/ihex2fw.c
@@ -86,6 +86,7 @@ int main(int argc, char **argv)
 		case 'j':
 			include_jump = 1;
 			break;
+		default:
 			return usage();
 		}
 	}
-- 
2.3.1


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

* Re: [PATCH] ihex: restore missing default in switch statement
  2015-03-04 14:24 [PATCH] ihex: restore missing default in switch statement Nicolas Iooss
@ 2015-03-04 22:18 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2015-03-04 22:18 UTC (permalink / raw)
  To: Nicolas Iooss; +Cc: linux-kernel, Mark Brown, David Woodhouse

On Wed,  4 Mar 2015 22:24:10 +0800 Nicolas Iooss <nicolas.iooss_linux@m4x.org> wrote:

> Commit 2473238eac95 ("ihex: add support for CS:IP/EIP records") removes
> the "default:" statement in the switch block, making the "return
> usage();" line dead code and ihex2fw silently ignoring unknown options.
> Restore this statement.
> 
> This bug was found by building with HOSTCC=clang and adding
> -Wunreachable-code-return to HOSTCFLAGS.
> 
> ...
>
> --- a/firmware/ihex2fw.c
> +++ b/firmware/ihex2fw.c
> @@ -86,6 +86,7 @@ int main(int argc, char **argv)
>  		case 'j':
>  			include_jump = 1;
>  			break;
> +		default:
>  			return usage();
>  		}
>  	}

whee.  So if there's userspace out there which is passing bad options
to ihex2fw, this fix will break it.

Oh well, I expect we'll survive.

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

end of thread, other threads:[~2015-03-04 22:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-04 14:24 [PATCH] ihex: restore missing default in switch statement Nicolas Iooss
2015-03-04 22:18 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).