cvs commit: src/usr.sbin/ppp route.c

Brian Somers brian at FreeBSD.org
Mon Jan 10 05:13:26 PST 2005


On Mon, 10 Jan 2005 14:22:25 +0200, Giorgos Keramidas <keramida at freebsd.org> wrote:
> On 2005-01-10 11:12, Brian Somers <brian at 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 at Awfulhak.org>
Don't _EVER_ lose your sense of humour !               <brian at FreeBSD.org>


More information about the cvs-src mailing list