[PATCH] Fix string to integer conversion
Jeremy Allison
jra at samba.org
Fri Feb 22 23:48:40 UTC 2019
On Fri, Feb 22, 2019 at 10:51:43PM +0100, Ralph Böhme via samba-technical wrote:
> On Fri, Feb 22, 2019 at 01:42:12PM -0800, Jeremy Allison via samba-technical wrote:
> > One small thing:
> >
> > In a couple of places you have:
> >
> > + int error;
> >
> > I'd prefer you initialize that to zero at declaration
> > time, i.e.:
> >
> > + int error = 0;
> >
> > Now I know both strtoul_err() and strtoull_err()
> > will return zero there on success (arguably
> > they shouldn't touch &error on success, but
> > I'm not going to fight that battle :-), but
> > it's good habits (and I think in the README.Coding)
> > standards that we initialize on declaration if
> > possible.
>
> this goes for pointers, not for non-pointers. Imho the latter should only be
> initialized when needed.
Yeah, but the code does:
int error;
stuff_call_here(var1, var2, &error);
if (error != 0) {
..
}
So just reading the code, you
would then have to go look inside
stuff_call_here()
to see exactly what gets done
on success.
If you just do:
int error = 0;
stuff_call_here(var1, var2, &error);
if (error != 0) {
..
}
then you don't need to look inside, the
code is obvious.
So I'm going to stick with my request, to make
future reviewers lives easier !
You could help by reviewing the patch :-) :-).
Jeremy.
More information about the samba-technical
mailing list