Date: Mon, 10 Jan 2005 13:13:16 +0000 From: Brian Somers <brian@FreeBSD.org> To: Giorgos Keramidas <keramida@FreeBSD.org> Cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/usr.sbin/ppp route.c Message-ID: <20050110131316.2d8d099f@dev.lan.Awfulhak.org> In-Reply-To: <20050110122225.GB2693@orion.daedalusnetworks.priv> References: <200501101112.j0ABCaEQ062701@repoman.freebsd.org> <20050110122225.GB2693@orion.daedalusnetworks.priv>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 10 Jan 2005 14:22:25 +0200, Giorgos Keramidas <keramida@freebsd.org> wrote: > On 2005-01-10 11:12, Brian Somers <brian@freebsd.org> wrote: > > > > Cast unsigned variables to int > > > > Revision Changes Path > > 1.94 +1 -1 src/usr.sbin/ppp/route.c > > % static void > % p_flags(struct prompt *prompt, u_int32_t f, unsigned max) > % { > % char name[33], *flags; > % register struct bits *p = bits; > % > % if (max > sizeof name - 1) > % max = sizeof name - 1; > % > % for (flags = name; p->b_mask && flags - name < (int)max; p++) > % if (p->b_mask & f) > % *flags++ = p->b_val; > % *flags = '\0'; > % - prompt_Printf(prompt, "%-*.*s", max, max, name); > % + prompt_Printf(prompt, "%-*.*s", (int)max, (int)max, name); > % } > > Hi Brian, > > Since p_flags is used only once in route.c can't we just fix the type > of `max' in the argument list of p_flags() to avoid the need for casts > altogether? Well, the problem then becomes (with high WARNS values) a warning that max is compared with an unsigned type. I chose to make the prototype unsigned as it seemed to make more sense to restrict the argument to what we expect... -- Brian Somers <brian@Awfulhak.org> Don't _EVER_ lose your sense of humour ! <brian@FreeBSD.org>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050110131316.2d8d099f>