From: David Brownell <david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
To: Trent Piepho <xyzzy-zY4eFNvK5D+xbKUeIHjxjQ@public.gmane.org>
Cc: i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
Subject: Re: [patch 2.6.26-rc1] i2c_use_client() defends against NULL
Date: Sat, 17 May 2008 11:53:04 -0700 [thread overview]
Message-ID: <200805171153.04995.david-b@pacbell.net> (raw)
In-Reply-To: <Pine.LNX.4.58.0805171048070.4196-13q4cmjDBaTP3RPoUHIrnuTW4wlIGRCZ@public.gmane.org>
On Saturday 17 May 2008, Trent Piepho wrote:
> > > Passing NULL to the current functions would just crash, it wouldn't
> > > morph anything.
> >
> > That's only if you assume an MMU set up to cause oopsing on reference
> > to the first and last pages of memory. Not the best of assumptions...
>
> Maybe BUG_ON(!client) would be better? It seems more likely to catch
> a programming error.
BUG_ON() is almost always the wrong answer though ... it's only
appropriate when there's no way for the system to continue.
And in fact, here it's *not* a bug...
Passing NULL around is more often OK than not. Example, it's
expected that passing it to a "free this object" routine will
work, saving callers a NULL check. Similarly, refcount calls.
_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c
prev parent reply other threads:[~2008-05-17 18:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-04 20:06 [patch 2.6.26-rc1] i2c_use_client() defends against NULL David Brownell
[not found] ` <200805041306.21074.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-05-17 12:40 ` Jean Delvare
[not found] ` <20080517144007.7611ab32-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-05-17 13:57 ` David Brownell
[not found] ` <200805170657.56833.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-05-17 17:53 ` Trent Piepho
[not found] ` <Pine.LNX.4.58.0805171048070.4196-13q4cmjDBaTP3RPoUHIrnuTW4wlIGRCZ@public.gmane.org>
2008-05-17 18:53 ` David Brownell [this message]
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=200805171153.04995.david-b@pacbell.net \
--to=david-b-ybekhbn/0ldr7s880joybq@public.gmane.org \
--cc=i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org \
--cc=xyzzy-zY4eFNvK5D+xbKUeIHjxjQ@public.gmane.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