Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763451AbXH3Wox (ORCPT ); Thu, 30 Aug 2007 18:44:53 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1763468AbXH3WoO (ORCPT ); Thu, 30 Aug 2007 18:44:14 -0400 Received: from pentafluge.infradead.org ([213.146.154.40]:52216 "EHLO pentafluge.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1763408AbXH3WoM (ORCPT ); Thu, 30 Aug 2007 18:44:12 -0400 Date: Fri, 31 Aug 2007 04:27:13 +0530 (IST) From: Satyam Sharma X-X-Sender: satyam@enigma.security.iitk.ac.in To: Jesper Juhl cc: Dmitry Torokhov , Linux Kernel Mailing List , Vojtech Pavlik , Johann Deneux , dtor@mail.ru, linux-input@atrey.karlin.mff.cuni.cz, linux-joystick@atrey.karlin.mff.cuni.cz Subject: Re: [PATCH] input: Silence 'unused variable' warning in iforce joystick driver In-Reply-To: <200708310013.12347.jesper.juhl@gmail.com> Message-ID: References: <200708310013.12347.jesper.juhl@gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1835 Lines: 55 Hi, On Fri, 31 Aug 2007, Jesper Juhl wrote: > In the iforce driver we currently get this warning > > drivers/input/joystick/iforce/iforce-packets.c: In function 'iforce_get_id_packet': > drivers/input/joystick/iforce/iforce-packets.c:249: warning: unused variable 'status' > > if CONFIG_JOYSTICK_IFORCE_USB is not defined. > > The warning is easy to avoid by simply moving the variable inside > the only case in the switch that actually use it. > > > Signed-off-by: Jesper Juhl > --- > > diff --git a/drivers/input/joystick/iforce/iforce-packets.c b/drivers/input/joystick/iforce/iforce-packets.c > index 3154ccd..48d4a86 100644 > --- a/drivers/input/joystick/iforce/iforce-packets.c > +++ b/drivers/input/joystick/iforce/iforce-packets.c > @@ -246,13 +246,12 @@ void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data) > > int iforce_get_id_packet(struct iforce *iforce, char *packet) > { > - int status; > - > switch (iforce->bus) { > > case IFORCE_USB: > - > #ifdef CONFIG_JOYSTICK_IFORCE_USB > + int status; > + > iforce->cr.bRequest = packet[0]; > iforce->ctrl->dev = iforce->usbdev; Hmm, would this not still give a warning when JOYSTICK_IFORCE_USB=y? [ I didn't know mixing code and declarations (not at top of statement block) was accepted style in the kernel ... ] IMHO either you should at least wrap that case inside a {} of its own (so that the int status; is at top of a statement block), or else, preferably, just add "__maybe_unused" to the first declaration that you removed just now. Satyam - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/