[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <469D3E66.3010502@garzik.org>
Date: Tue, 17 Jul 2007 18:10:46 -0400
From: Jeff Garzik <jeff@...zik.org>
To: Roland Dreier <rdreier@...co.com>
CC: akpm@...ux-foundation.org, torvalds@...ux-foundation.org,
linux-kernel@...r.kernel.org, linux-ide@...r.kernel.org,
chas@....nrl.navy.mil, rolandd@...co.com, dwmw2@...radead.org,
gregkh@...e.de
Subject: Re: [git patches 1/2] warnings: attack valid cases spotted by warnings
Roland Dreier wrote:
> > drivers/infiniband/hw/mthca/mthca_qp: kill uninit'd var warning
> >
> > drivers/infiniband/hw/mthca/mthca_qp.c: In function
> > ‘mthca_tavor_post_send’:
> > drivers/infiniband/hw/mthca/mthca_qp.c:1594: warning: ‘f0’ may be used
> > uninitialized in this function
> > drivers/infiniband/hw/mthca/mthca_qp.c: In function
> > ‘mthca_arbel_post_send’:
> > drivers/infiniband/hw/mthca/mthca_qp.c:1949: warning: ‘f0’ may be used
> > uninitialized in this function
> >
> > Initializing 'f0' is not strictly necessary in either case, AFAICS.
> >
> > I was considering use of uninitialized_var(), but looking at the
> > complex flow of control in each function, I feel it is wiser and
> > safer to simply zero the var and be certain of ourselves.
> >
> > Signed-off-by: Jeff Garzik <jeff@...zik.org>
>
> I don't really like this. These functions are in the hottest, most
> latency-sensitive code path of this driver, which is used by people
> who care about nanoseconds. I'm quite confident that the code is
> correct as written, and it really feels wrong to me to add bloat to
> the fastpath just to cover up a shortcoming of gcc.
I don't buy that performance argument, in this case. You are already
dirtying the same cacheline with other variable initializations.
Like I noted in the changeset description (hey, this is precisely why I
included it, so that we could have this discussion), IMO the flow of
control makes it not only impossible for the compiler to understand the
full value range of 'f0', but also difficult for humans as well.
I could perhaps understand initializing the variable to some poison
value rather than zero, but IMO the code is stronger with f0 set to a
sane value.
It's poorly readable, poorly commented code as-is.
Jeff
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists