From mboxrd@z Thu Jan 1 00:00:00 1970 From: Benjamin Tissoires Date: Thu, 09 Jul 2015 21:21:54 +0000 Subject: Re: i2c-HID: Delete unnecessary checks before the function call "gpiod_put" Message-Id: List-Id: References: <5307CAA2.8060406@users.sourceforge.net> <530A72AA.3000601@users.sourceforge.net> <530B5FB6.6010207@users.sourceforge.net> <530C5E18.1020800@users.sourceforge.net> <530CD2C4.4050903@users.sourceforge.net> <530CF8FF.8080600@users.sourceforge.net> <530DD06F.4090703@users.sourceforge.net> <5317A59D.4@users.sourceforge.net> <559D8874.7090407@users.sourceforge.net> <559EDE3D.1030409@users.sourceforge.net> <559EE338.4060107@users.sourceforge.net> In-Reply-To: <559EE338.4060107@users.sourceforge.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: SF Markus Elfring Cc: Jiri Kosina , Mika Westerberg , linux-input , Linux Kernel Mailing List , kernel-janitors@vger.kernel.org, Julia Lawall On Thu, Jul 9, 2015 at 5:10 PM, SF Markus Elfring wrote: >>> The proposed update candidates are contained in the source >>> file "drivers/hid/i2c-hid/i2c-hid.c" from Linux next-20150708. >>> >>> * i2c_hid_remove() function: >>> Can it be tolerated here that the pointer "ihid->desc" might be eventually null? >>> >>> * i2c_hid_probe() function: >>> Is this implementation structured in such a way that a pointer for valid data >>> will be usually passed for "ihid->desc" if the statements after the jump >>> label "err" will be reached? >>> >> >> Again, in both case it is completely normal to have "ihid->desc = >> NULL" given that this field is only retrieved in case of an ACPI >> device which does not declares an IRQ but a GPIO. Most ACPI devices I >> saw are using a simple IRQ, and the OF instantiations of the driver >> will definitively have ihid->desc null. So I do not want to have a >> warning for most of i2c-hid devices out there (because I will have to >> explain that this is completely normal again and again). > > Would it make sense to annotate checks before such function calls > as "unlikely" then? > I don't see the benefits of this right now. These calls are not time critical and it's not because today they are few devices with GPIOs rather than IRQs that it will be the case all the time. You can always submit a patch preventing coccinelle to raise this warning, but maybe a simple comment in the code would be enough. Cheers, Benjamin