From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KScym-0003XD-TW for qemu-devel@nongnu.org; Mon, 11 Aug 2008 15:22:56 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KScym-0003WL-70 for qemu-devel@nongnu.org; Mon, 11 Aug 2008 15:22:56 -0400 Received: from [199.232.76.173] (port=56738 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KScyl-0003WC-Ov for qemu-devel@nongnu.org; Mon, 11 Aug 2008 15:22:55 -0400 Received: from wr-out-0506.google.com ([64.233.184.235]:13546) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KScyl-0006Za-MI for qemu-devel@nongnu.org; Mon, 11 Aug 2008 15:22:55 -0400 Received: by wr-out-0506.google.com with SMTP id c46so1738925wra.18 for ; Mon, 11 Aug 2008 12:22:54 -0700 (PDT) Message-ID: <48A09168.6000301@codemonkey.ws> Date: Mon, 11 Aug 2008 14:22:16 -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> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Blue Swirl , Laurent Vivier Laurent Vivier wrote: > >> >> I vote for this. The other solutions do not improve type safety >> (except for union) and they are more complex. > > But I think to call the function you have to cast the pointer, this > doesn't improve type safety too... Right now, the monitor works by taking a generic function pointer "void (*)()" which is treated specially by the C standard (although it's now deprecated). Any function pointer can be cast to a generic function pointer. The dispatch loop basically looks like: void dispatch(void (*func)(), int n_args, void *args) { switch (n_args) { case 1: ((void (*)(void *))func)(args[0]); break; case 1: ((void (*)(void *, void *))func)(args[0]); break; ... } But this tosses a warning since void (*)() is deprecated. So, if we use: void dispatch(void *func, int n_args, void *args) It'll work just like it did before. Regards, Anthony Liguori > > Regards, > Laurent > ----------------------- Laurent Vivier ---------------------- > "The best way to predict the future is to invent it." > - Alan Kay > > > > > > >