From: Jiri Kosina <jkosina@suse.cz>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Sachin Kamat <sachin.kamat@linaro.org>,
linux-input@vger.kernel.org, jic23@kernel.org,
patches@linaro.org
Subject: Re: [PATCH 1/2] hid: usbhid: Return -ENOMEM instead of -1 for memory allocation failure
Date: Mon, 26 Nov 2012 23:09:03 +0100 (CET) [thread overview]
Message-ID: <alpine.LNX.2.00.1211262308230.15521@pobox.suse.cz> (raw)
In-Reply-To: <20121126180530.GE14623@core.coreip.homeip.net>
On Mon, 26 Nov 2012, Dmitry Torokhov wrote:
> > > Silences the following smatch warning:
> > > drivers/hid/usbhid/hiddev.c:897 hiddev_connect() warn:
> > > returning -1 instead of -ENOMEM is sloppy
> > >
> > > Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> > > ---
> > > drivers/hid/usbhid/hiddev.c | 2 +-
> > > 1 files changed, 1 insertions(+), 1 deletions(-)
> > >
> > > diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
> > > index 14599e2..50e2ab8 100644
> > > --- a/drivers/hid/usbhid/hiddev.c
> > > +++ b/drivers/hid/usbhid/hiddev.c
> > > @@ -894,7 +894,7 @@ int hiddev_connect(struct hid_device *hid, unsigned int force)
> > > }
> > >
> > > if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL)))
> > > - return -1;
> > > + return -ENOMEM;
> > >
> > > init_waitqueue_head(&hiddev->wait);
> > > INIT_LIST_HEAD(&hiddev->list);
> >
> > Well, this would make sense only if the callers would be actualling doing
> > something useful with that return value. But the only check we are
> > performing at callsites is non-zero test ...
>
> It is chicken and egg problem - callers can't use the result unless it
> is meaningful and callee's do not bother to send anything meaningful
> because nobody uses it...
>
> If someone takes time to convert to proper return codes I think it would
> be a good thing.
Fully agree with you.
But I'd like to have both sides changed together once someone starts
taking care of fixing it.
Thanks,
--
Jiri Kosina
SUSE Labs
next prev parent reply other threads:[~2012-11-26 22:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-21 6:20 [PATCH 1/2] hid: usbhid: Return -ENOMEM instead of -1 for memory allocation failure Sachin Kamat
2012-11-21 6:20 ` [PATCH 2/2] hid: hid-sensor-hub: Move NULL check to beginning Sachin Kamat
2012-11-21 12:42 ` Alan Cox
2012-11-21 17:11 ` Srinivas Pandruvada
2012-11-21 22:26 ` Jiri Kosina
2012-11-22 21:03 ` [PATCH 1/2] hid: usbhid: Return -ENOMEM instead of -1 for memory allocation failure Jiri Kosina
2012-11-26 18:05 ` Dmitry Torokhov
2012-11-26 22:09 ` Jiri Kosina [this message]
2012-11-27 4:42 ` Sachin Kamat
2012-11-27 9:55 ` Jiri Kosina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LNX.2.00.1211262308230.15521@pobox.suse.cz \
--to=jkosina@suse.cz \
--cc=dmitry.torokhov@gmail.com \
--cc=jic23@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=patches@linaro.org \
--cc=sachin.kamat@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).