Email List: Xaustin-group-lX
[All Lists]

Re: [1003.1(2008)/Issue 7 0000177]: mismatch between example description

To: wollman+austin-group@xxxxxxxxxxx
Subject: Re: [1003.1(2008)/Issue 7 0000177]: mismatch between example descriptionand code
From: shwaresyst@xxxxxxx
Date: Thu, 05 Nov 2009 12:27:52 -0500
Cc: austin-group-l@xxxxxxxxxxxxx
References: <ee3ffd5cb61c11046aea665c63c5adbd@xxxxxx><8CC2B9DD22E07E8-AF4-14C01@webmail-m088.sysops.aol.com><20091105102458.GA11253@xxxxxx><8CC2C4B8D552A03-2DFC-9667@webmail-m095.sysops.aol.com> <19186.65472.928078.103195@xxxxxx>
Yes, but then the malloc() call would most likely fail and the function would error exit anyways. I believe that most of those values in limits.h are there so applications can be optimized to deal with definite cases, not indefinite ones, so using impractical values would in effect defeat their intended purpose.

Can switch it to, so the function exits gracefully:

/* get implementation instance's max expectable line length */
line_max = sysconf(_SC_LINE_MAX);
/* account as practical for fgets() appending a NULL char */
if (line_max = LONG_MAX) return EOVERFLOW;
line_max ++;

but I was more trying to show the NULL as being accounted for so glossed that test over to keep the example brief.

Cheers,
Mark
-----Original Message-----
From: wollman+austin-group@xxxxxx
To: shwaresyst@xxxxxx
Cc: gwc@xxxxxx; austin-group-l@xxxxxx
Sent: Thu, Nov 5, 2009 11:39 am
Subject: Re: [1003.1(2008)/Issue 7 0000177]: mismatch between example description and code










<<On Thu, 05 Nov 2009 11:24:15 -0500, shwaresyst@xxxxxx said:

  /* get implementation instance's max expectable line length and
account for fgets() appending a NULL char */
    line_max = sysconf(_SC_LINE_MAX) + 1;
If the implementation defines {LINE_MAX} to be {LONG_MAX}, this will
overflow.  (I could see some implementors wanting to do that, in lieu
of saying "unlimited".)

-GAWollman





<Prev in Thread] Current Thread [Next in Thread>