Messages in this thread | | | Date | Wed, 3 Oct 2012 12:06:47 +0100 | From | Mark Brown <> | Subject | Re: [PATCH] regmap: silence GCC warning |
| |
On Wed, Oct 03, 2012 at 09:23:36AM +0200, Paul Bolle wrote: > On Tue, 2012-10-02 at 20:11 -0400, Valdis.Kletnieks@vt.edu wrote: > > On Mon, 01 Oct 2012 11:03:21 +0100, Mark Brown said:
> > > > That implies that 'ret' will be set in the if-branch. ('val_count' could > > > > be zero if 'val_len' is, for example, zero. That would be useless input, > > > > however.)
> > But gcc doesn't know what "useless input" means, semantically.
> Correct. When this function is compiled gcc has to take into account > that 'val_len' will be called with useless input, like zero.
> By the way, GCC doesn't warn if I add an early check whether 'val_count' > is non-zero:
That's a much more useful fix, bodging things by just forcing things to be assigned (especially with the way you were converting the immediate returns) is generally terrible - it's just shutting up the errors without actually fixing any issues that really exist and means that if the compiler ever notices actual issues we won't see them.
| |