Compiling with -Wall
Russ Allbery
rra at stanford.edu
Sat Feb 23 20:22:14 UTC 2002
Jeffrey M Vinocur <jeff at litech.org> writes:
> I was trying to compile some bits of CURRENT with -Wall this morning,
> and was sufficiently bored to go through and try to fix some of the
> warnings.
Thank you!
> Anyway, I touched a lot of things I don't fully understand, so I'm not
> comfortable committing this until somebody at least glances at it.
This patch looks fine to me. Please go ahead and commit it. All of the
changes look like things that we'll catch quickly if they're problematic.
You don't need to change this before committing, but for future reference,
code like:
> --- ckpasswd.c 2002/01/16 14:16:51 1.14
> +++ ckpasswd.c 2002/02/23 17:54:55
> @@ -114,7 +114,7 @@
> if (!found)
> return(0);
> iter = colon+1;
> - if (colon = strchr(iter, ':'))
> + if ((colon = strchr(iter, ':')) != NULL)
> *colon = 0;
> strcpy(pass, iter);
> return(pass);
can be rewritten as:
colon = strchr(iter, ':');
if (colon != NULL)
*colon = 0;
wherever you see it. We should probably stick to the fairly widespread C
coding convention of avoiding assignments inside if statements where
possible. (They're somewhat more legitimate inside while conditions,
where avoiding them can make the code uglier and slower.)
--
Russ Allbery (rra at stanford.edu) <http://www.eyrie.org/~eagle/>
More information about the inn-patches
mailing list