delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/06/11/10:01:51

Date: Mon, 11 Jun 2001 17:02:58 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
cc: djgpp-workers AT delorie DOT com
Subject: Re: Compiler options for djdev build
In-Reply-To: <Pine.LNX.4.10.10106111321190.966-100000@acp3bf>
Message-ID: <Pine.SUN.3.91.1010611170100.20317B-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Mon, 11 Jun 2001, Hans-Bernhard Broeker wrote:

> > @@ -327,7 +327,7 @@ _doprnt(const char *fmt0, va_list argp, 
> >          */
> >         char *p                 /*, *memchr() */;
> >  
> > -       if ((p = memchr(t, 0, prec)))
> > +       if ((p = memchr(t, 0, (size_t)prec)))
> 
> Casting a variable on passing to a function is almost always a sign of
> trouble. It may make more sense to turn 'prec' into an unsigned variable
> (size_t or unsigned int), here. OTOH, 'prec' has a signalling value of
> -1 for "undefined", in this routin, so I guess this is OK.

That was my line of reasoning as well.

P.S. The value of the warning is that it forces you to think about each 
such case and make the decisions how to code each case conciously rather 
than letting them happen by default.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019