Received: from eggs.gnu.org ([2001:4830:134:3::10]:48692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUtqg-0007Q2-Ba for qemu-devel@nongnu.org; Tue, 01 Apr 2014 04:15:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WUtqW-00083e-MD for qemu-devel@nongnu.org; Tue, 01 Apr 2014 04:15:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53872) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUtqW-00083T-Cr for qemu-devel@nongnu.org; Tue, 01 Apr 2014 04:15:00 -0400 From: Markus Armbruster References: <53382B89.9030301@gmail.com> <87zjk6fjwf.fsf@blackfin.pond.sub.org> <533A0442.2020606@gmail.com> Date: Tue, 01 Apr 2014 10:13:53 +0200 In-Reply-To: <533A0442.2020606@gmail.com> (Chen Gang's message of "Tue, 01 Apr 2014 08:11:46 +0800") Message-ID: <87wqf95uwu.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH trival] vl.c: clean up code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chen Gang Cc: QEMU Developers , aliguori@amazon.com Chen Gang writes: > On 03/31/2014 11:49 PM, Markus Armbruster wrote: >> Chen Gang writes: >> >>> in get_boot_device() >>> >>> - remove 'res' to simplify code >>> >>> in main(): >>> >>> - remove useless 'continue'. >>> >>> - in main switch(): >>> >>> - remove or adjust all useless 'break'. >>> >>> - remove useless '{' and '}'. >>> >>> - use assignment directly to replace useless 'args' >>> (which is defined in the middle of code block). >> >> Suggest to have one patch per item in this list. >> > > OK, thanks. I will/should send again in this week (within 2014-04-06). No rush :) > [...] >>> @@ -3204,11 +3201,11 @@ int main(int argc, char **argv, char **envp) >>> case QEMU_OPTION_curses: >>> #ifdef CONFIG_CURSES >>> display_type = DT_CURSES; >>> + break; >>> #else >>> fprintf(stderr, "Curses support is disabled\n"); >>> exit(1); >>> #endif >>> - break; >>> case QEMU_OPTION_portrait: >>> graphic_rotate = 90; >>> break; >> >> I'm not sure eliding the break after exit is worthwhile. >> >> In theory, it could cause false positives with tools smart enough to >> diagnose fall through without comment, but too stupid to see that exit() >> never returns. No idea whether such tools exist. >> >> The missing break might give human readers slight pause, until they >> recognize exit. Especially with such ifdeffery. >> > > That sounds reasonable to me. > > "removing 'break' after exit()" will not be good for C code readers: > exit() is not like 'return' which can get enough focus by C code readers > (especially in 'vim' or other latest editor). > > How about to let 'return' instead of exit() in main(), and also remove > useless 'break'? Welcome any additional suggestions, discussions or > completions, thanks. When main() is short, return instead of exit() is just fine with me. But when it's as long as this one, I prefer exit() to make the process termination locally obvious. I think the code is okay as it is. [...]