From: atull <atull@opensource.altera.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: mark.rutland@arm.com, linux-doc@vger.kernel.org,
linus.walleij@linaro.org, pantelis.antoniou@konsulko.com,
hpa@zytor.com, s.trumtrar@pengutronix.de,
devel@driverdev.osuosl.org, sameo@linux.intel.com,
nico@linaro.org, iws@ovro.caltech.edu, michal.simek@xilinx.com,
kyle.teske@ni.com, jgunthorpe@obsidianresearch.com,
grant.likely@linaro.org, davidb@codeaurora.org, rubini@gnudd.com,
cesarb@cesarb.net, devicetree@vger.kernel.org,
jason@lakedaemon.net, pawel.moll@arm.com,
ijc+devicetree@hellion.org.uk, Josh Cartwright <joshc@ni.com>,
broonie@kernel.org, gregkh@linuxfoundation.org,
philip@balister.org, Petr Cvek <petr.cvek@tul.cz>,
dinguyen@opensource.altera.com, monstr@monstr.eu,
Pavel Machek <pavel@denx.de>,
linux-kernel@vger.kernel.org, balbi@ti.com,
delicious.quinoa@gmail.com, robh+dt@kernel.org, rob@landley.net,
galak@codeaurora.org, akpm@linux-foundation.org, davem@daveml
Subject: Re: [PATCH v11 3/4] add FPGA manager core
Date: Thu, 24 Sep 2015 15:47:26 -0500 [thread overview]
Message-ID: <alpine.DEB.2.02.1509241526380.5173@linuxheads99> (raw)
In-Reply-To: <20150924074953.GI4953@mwanda>
On Thu, 24 Sep 2015, Dan Carpenter wrote:
> Of course, the maintainer gets the last word regardless of what anyone
> else thinks.
>
> Generally, minimal code is better. Trying to future proof code is a
> waste of time because you can't predict what will happen in the future.
> It's way more likely that some pointer you never expected to be NULL
> will be NULL instead of the few checked at the beginning of a function.
> Adding useless code uses RAM and makes the function slower. It's a bit
> confusing for users as well because they will wonder when the NULL check
> is used. A lot of times this sort of error handling is a bit fake and
> what I mean is that it looks correct but the system will just crash in a
> later function.
>
> Also especially with a simple NULL dereferences like this theoretical
> one, it's better to just get the oops. It kills the module but you get
> a good message in the log and it's normally straight forward to debug.
>
> We spent a surprising amount of time discussing useless code. I made
> someone redo a patch yesterday because they had incomplete error
> handling for a situation which could never happen.
>
> regards,
> dan carpenter
>
>
Thanks for the discussion.
Interesting. The amount of code bloat here compiles down to about two
machine instructions (in two places). Actually a little more since I should
be using IS_ERR_OR_NULL. But the main question is whether I should do
it at all.
The behaviour I should drive here is that the user will do their own error
checking. After they get a pointer to a FPGA manager using
of_fpga_mgr_get(), they should check it and not assume that
fpga_mgr_firmware_load() will do it for them, i.e.
mgr = of_fpga_mgr_get(mgr_node);
if (IS_ERR(mgr))
return PTR_ERR(mgr);
fpga_mgr_firmware_load(mgr, flags, path);
I could take out these NULL pointer checks and it won't hurt anything unless
someone is just using the functions badly, in which case: kablooey.
Alan
next prev parent reply other threads:[~2015-09-24 20:47 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-22 15:21 [PATCH v11 0/4] FPGA Manager Framework atull
2015-09-22 15:21 ` [PATCH v11 1/4] usage documentation for FPGA manager core atull
2015-09-23 0:50 ` Moritz Fischer
2015-09-22 15:21 ` [PATCH v11 2/4] fpga manager: add sysfs interface document atull
[not found] ` <1442935271-10375-3-git-send-email-atull-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org>
2015-09-23 0:52 ` Moritz Fischer
2015-09-22 15:21 ` [PATCH v11 3/4] add FPGA manager core atull
[not found] ` <1442935271-10375-4-git-send-email-atull-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org>
2015-09-22 22:29 ` Josh Cartwright
2015-09-23 13:23 ` Pavel Machek
2015-09-23 14:11 ` Dan Carpenter
2015-09-23 16:15 ` atull
2015-09-24 7:49 ` Dan Carpenter
2015-09-24 20:47 ` atull [this message]
2015-09-24 21:13 ` Pavel Machek
2015-09-25 10:00 ` Dan Carpenter
2015-09-23 17:10 ` atull
2015-09-23 23:03 ` Josh Cartwright
2015-09-24 20:24 ` atull
2015-09-22 15:21 ` [PATCH v11 4/4] fpga manager: add driver for socfpga fpga manager atull
2015-09-22 22:47 ` Josh Cartwright
-- strict thread matches above, loose matches on Subject: below --
2015-10-07 15:36 [PATCH v11 0/4] FPGA Manager Framework atull
2015-10-07 15:36 ` [PATCH v11 3/4] add FPGA manager core atull
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.DEB.2.02.1509241526380.5173@linuxheads99 \
--to=atull@opensource.altera.com \
--cc=akpm@linux-foundation.org \
--cc=balbi@ti.com \
--cc=broonie@kernel.org \
--cc=cesarb@cesarb.net \
--cc=dan.carpenter@oracle.com \
--cc=davem@daveml \
--cc=davidb@codeaurora.org \
--cc=delicious.quinoa@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=devicetree@vger.kernel.org \
--cc=dinguyen@opensource.altera.com \
--cc=galak@codeaurora.org \
--cc=grant.likely@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=ijc+devicetree@hellion.org.uk \
--cc=iws@ovro.caltech.edu \
--cc=jason@lakedaemon.net \
--cc=jgunthorpe@obsidianresearch.com \
--cc=joshc@ni.com \
--cc=kyle.teske@ni.com \
--cc=linus.walleij@linaro.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=michal.simek@xilinx.com \
--cc=monstr@monstr.eu \
--cc=nico@linaro.org \
--cc=pantelis.antoniou@konsulko.com \
--cc=pavel@denx.de \
--cc=pawel.moll@arm.com \
--cc=petr.cvek@tul.cz \
--cc=philip@balister.org \
--cc=rob@landley.net \
--cc=robh+dt@kernel.org \
--cc=rubini@gnudd.com \
--cc=s.trumtrar@pengutronix.de \
--cc=sameo@linux.intel.com \
/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