From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KSp1s-0001Hn-N2 for qemu-devel@nongnu.org; Tue, 12 Aug 2008 04:14:56 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KSp1q-0001EC-LQ for qemu-devel@nongnu.org; Tue, 12 Aug 2008 04:14:55 -0400 Received: from [199.232.76.173] (port=43631 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KSp1q-0001Dv-HJ for qemu-devel@nongnu.org; Tue, 12 Aug 2008 04:14:54 -0400 Received: from ecfrec.frec.bull.fr ([129.183.4.8]:47467) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KSp1q-0007Es-Ft for qemu-devel@nongnu.org; Tue, 12 Aug 2008 04:14:54 -0400 Subject: Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmissing-prototypes From: Laurent Vivier In-Reply-To: <48A0EE09.90904@codemonkey.ws> 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> <48A0EE09.90904@codemonkey.ws> Content-Type: text/plain; charset=utf-8 Date: Tue, 12 Aug 2008 10:14:46 +0200 Message-Id: <1218528886.3871.3.camel@frecb07144> Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Blue Swirl , qemu-devel@nongnu.org Le lundi 11 ao=C3=BBt 2008 =C3=A0 20:57 -0500, Anthony Liguori a =C3=A9cr= it : > Laurent Vivier wrote: > > Le lundi 11 ao=C3=BBt 2008 =C3=A0 14:22 -0500, Anthony Liguori a =C3=A9= crit : > > =20 > > > > 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); > > =20 >=20 > And then every monitor command changes from: >=20 > void do_eject(int force, char *device) > { > ... > } >=20 > to: >=20 > void do_eject(int argc, char **argv) > { > char *device; > int force =3D 0; >=20 > if (argc =3D=3D 2) { > if (strcmp(argv[0], "-f") =3D=3D 0) { > force =3D 1; > device =3D argv[1]; > } else { > term_printf("bad option %s\n", argv[0]); > return; > } > } else if (argc =3D=3D 1) { > device =3D argv[0]; > } else { > term_printf("bad number of options\n"); > return; > } >=20 > ... > } Yes > Consider multiplying that by all of the possible monitor commands, and=20 > it's totally not worth it. it's cleaner and more flexible... and from an artistic point of view, it's beautiful ;-) Laurent --=20 ----------------- Laurent.Vivier@bull.net ------------------ "La perfection est atteinte non quand il ne reste rien =C3=A0 ajouter mais quand il ne reste rien =C3=A0 enlever." Saint Exup=C3=A9ry