delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/02/12/15:01:25

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f
Sender: rich AT phekda DOT freeserve DOT co DOT uk
Message-ID: <3C697479.BFBA3B01@phekda.freeserve.co.uk>
Date: Tue, 12 Feb 2002 20:00:57 +0000
From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.19 i586)
X-Accept-Language: de,fr
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
Subject: Re: GCC-3.1 related patches for DJGPP CVS version
References: <Pine DOT A41 DOT 4 DOT 05 DOT 10202120820360 DOT 10676-100000 AT ieva06>
Reply-To: djgpp-workers AT delorie DOT com

Hello.

Andris Pavenis wrote:
> 
> On Mon, 11 Feb 2002, Richard Dawe wrote:
> 
[snip]
> > pavenis AT lanet DOT lv wrote:
> > > diff -ur3 djgpp.orig/src/libc/posix/unistd/confstr.c
> > > djgpp/src/libc/posix/unistd/confstr.c
> > > --- djgpp.orig/src/libc/posix/unistd/confstr.c  Wed Jun 20 02:00:46 2001
> > > +++ djgpp/src/libc/posix/unistd/confstr.c       Mon Feb 11 18:17:28 2002
> > > @@ -43,7 +43,9 @@
> > >      case _CS_POSIX_V6_ILP32_OFF32_LDFLAGS:
> > >      case _CS_POSIX_V6_ILP32_OFF32_LIBS:
> > >      {
> > > -      out_len = snprintf(buf, len, "");
> > > +/*      out_len = snprintf(buf, len, "");  */
> > > +      if (len>0) *buf=0;
> > > +      out_len=0;
> > >        ++out_len;
> > >        break;
> > >      }
> >
> > Why not just set out_len to 1? Also, presumably the comment will be
> > removed too?
> 
> snprintf should output number of outputted chars not including trailing \0
> AFAIK, so 0 is correct. gcc-3.1 20020210 emitted warning about empty
> format string. Maybe it will not be so later, so I left snprintf in
> comment. We could also revert this change when (if) we'll need some real
> snprintf there.

What I meant was this: the codes sets out_len to zero, then increments it. Why
not just set it to 1? I hope/expect the compiler could optimise this case.

Bye, Rich =]

-- 
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]

- Raw text -


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