From: Greg KH <gregkh@suse.de>
To: Linas Vepstas <linas@austin.ibm.com>
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org,
linux-pci@atrey.karlin.mff.cuni.cz
Subject: Re: [PATCH 1/2]: Renumber PCI error enums to start at zero
Date: Tue, 12 Dec 2006 13:42:52 -0800 [thread overview]
Message-ID: <20061212214252.GC2580@suse.de> (raw)
In-Reply-To: <20061212213542.GK4329@austin.ibm.com>
On Tue, Dec 12, 2006 at 03:35:42PM -0600, Linas Vepstas wrote:
> On Tue, Dec 12, 2006 at 12:35:43PM -0800, Greg KH wrote:
> > On Tue, Dec 12, 2006 at 01:55:24PM -0600, Linas Vepstas wrote:
> > >
> > > Subject: [PATCH 1/2]: Renumber PCI error enums to start at zero
> > >
> > > Renumber the PCI error enums to start at zero for "normal/online".
> > > This allows un-initialized pci channel state (which defaults to zero)
> > > to be interpreted as "normal". Add very simple routine to check
> > > state, just in case this ever has to be fiddled with again.
> >
> > No, as you have a specific type for this state, never test it against
> > "zero". That just defeats the whole issue of having a special type for
> > this state.
>
> Yes, well, I guess that was my initial thinking, which is why it got
> coded that way. But "in real life", the value in the struct isn't
> initialized (thus taking a value of zero). Its not initialized
> in deference to the traditional idea that "just saying bzero()
> should be enough".
Then properly initialize the thing.
> However, that turned the test for error into a dorky double test:
> if(pdev->error_state && pdev->error_state != pci_channel_io_normal)
> which struck me as lame.
Again, don't test an explicit enumerated type against "0", that's just
foolish. Why have the explicit type if you are going to do that? Does
sparse complain about it? It should if it doesn't...
> So, I'll ask: is it better to test for (state!=0 && state!=1) or,
> to initialize pdev->error_state = pci_channel_io_normal; in the driver
> probe code?
Initialize the state in the probe. Then check against the enumerated
type, not an integer value. Sparse should complain if you try to do
that.
Or, if you really want to test against integers, rip out those types,
otherwise they are useless as you keep trying to go around them...
thanks,
greg k-h
next prev parent reply other threads:[~2006-12-12 21:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-12 19:55 [PATCH 1/2]: Renumber PCI error enums to start at zero Linas Vepstas
2006-12-12 20:01 ` [PATCH 2/2]: Use newly defined PCI channel offline routine Linas Vepstas
2006-12-12 21:27 ` Auke Kok
2006-12-12 20:35 ` [PATCH 1/2]: Renumber PCI error enums to start at zero Greg KH
2006-12-12 21:35 ` Linas Vepstas
2006-12-12 21:42 ` Greg KH [this message]
-- strict thread matches above, loose matches on Subject: below --
2006-11-01 23:54 Linas Vepstas
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=20061212214252.GC2580@suse.de \
--to=gregkh@suse.de \
--cc=akpm@osdl.org \
--cc=linas@austin.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@atrey.karlin.mff.cuni.cz \
/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