Re: Redundant validity check in stock code.

From: Thomas Arp (
Date: 07/26/02

From: "Daniel A. Koepke" <dkoepke@CIRCLEMUD.ORG>
> On Thu, 25 Jul 2002, Thomas Arp wrote:
> > You'll want to keep the size_t. As the docs state, snprintf returns
> > the amount of characters written, which is always >= 0.
> Pre-standard implementations of snprintf(3) (i.e., glibc 2.0.6's) return
> -1 to indicate the output was truncated.  Since we don't want to restrict
> CircleMUD to C99 conformant compilers, we don't want to use rely on the
> return value always being non-negative.
> At best, size_t causes an unnecessary unsigned cast; at worst, it breaks
> compatability.  Thus, we definitely want to change it.
That's what I get for believing the website (2.0.6), and not
This is an abstract from the glibc-2.2.5 manual at
Formatted-Output-Functions.html#Formatted%20Output%20Functions :

"Attention: In versions of the GNU C library prior to 2.1 the return value
is the number of characters stored, not including the terminating null;
unless there was not enough space in s to store the result in which case
-1 is returned. This was changed in order to comply with the ISO C99

Bookmark updated to newer glibc manual.


   | FAQ: |
   | Archives: |
   | Newbie List:   |

This archive was generated by hypermail 2b30 : 06/25/03 PDT