From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KSj9F-00007M-1w for qemu-devel@nongnu.org; Mon, 11 Aug 2008 21:58:09 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KSj9E-000070-E3 for qemu-devel@nongnu.org; Mon, 11 Aug 2008 21:58:08 -0400 Received: from [199.232.76.173] (port=45058 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KSj9E-00006u-AK for qemu-devel@nongnu.org; Mon, 11 Aug 2008 21:58:08 -0400 Received: from ag-out-0708.google.com ([72.14.246.240]:32977) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KSj9E-0002Y4-4W for qemu-devel@nongnu.org; Mon, 11 Aug 2008 21:58:08 -0400 Received: by ag-out-0708.google.com with SMTP id 31so191740agc.5 for ; Mon, 11 Aug 2008 18:58:07 -0700 (PDT) Message-ID: <48A0EE09.90904@codemonkey.ws> Date: Mon, 11 Aug 2008 20:57:29 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmissing-prototypes References: <489DE0C7.9000505@codemonkey.ws> <48A04ACD.5090900@codemonkey.ws> <48A05150.2040405@qumranet.com> <48A0533A.9020707@codemonkey.ws> <48A06B12.5000701@qumranet.com> <48A06D07.60103@codemonkey.ws> <48A09168.6000301@codemonkey.ws> <1218485013.3865.2.camel@frecb07144> In-Reply-To: <1218485013.3865.2.camel@frecb07144> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laurent Vivier Cc: Blue Swirl , qemu-devel@nongnu.org Laurent Vivier wrote: > Le lundi 11 août 2008 à 14:22 -0500, Anthony Liguori a écrit : > > > but using "void (*handler)(int argc, char** argv)" avoids the switch: > > switch(nb_args) { > case 0: > cmd->handler(); > break; > case 1: > cmd->handler(args[0]); > break; > ... > } > > becomes > > cmd->handler(nb_args, args); > And then every monitor command changes from: void do_eject(int force, char *device) { ... } to: void do_eject(int argc, char **argv) { char *device; int force = 0; if (argc == 2) { if (strcmp(argv[0], "-f") == 0) { force = 1; device = argv[1]; } else { term_printf("bad option %s\n", argv[0]); return; } } else if (argc == 1) { device = argv[0]; } else { term_printf("bad number of options\n"); return; } ... } Consider multiplying that by all of the possible monitor commands, and it's totally not worth it. Regards, Anthony Liguori > Laurent > >