Re: fix uname.3 manpage.
Sorry - I responded to the wrong email! Rob
Re: fix uname.3 manpage.
Ok, thanks for the response. I will review your diff and see what I can do. Original Message From: Ingo Schwarze Sent: Sunday, October 9, 2016 2:26 PM To: Gleydson Soares Cc: tech@openbsd.org; j...@kerhand.co.uk Subject: Re: fix uname.3 manpage. Hi Gleydson, Gleydson Soares wrote on Sat, Oct 08, 2016 at 05:50:00PM -0300: > uname(3) function returns 0 on successful and -1 on failure. > "non-negative value" is wrong here. It is not wrong. When uname(3) succeeds, it does return a non-negative value, even though that may always be 0 depending on the particular implementation. The patch is not OK. POSIX allows implementations of uname(3) to return values greater than 0 on success. So your patch might goad the unwary into writing non-portable code. Yours, Ingo > Index: uname.3 > === > RCS file: /cvs/src/lib/libc/gen/uname.3,v > retrieving revision 1.15 > diff -u -p -r1.15 uname.3 > --- uname.3 21 Jan 2014 03:15:45 - 1.15 > +++ uname.3 9 Oct 2016 17:50:16 - > @@ -65,7 +65,7 @@ Machine hardware platform. > .Sh RETURN VALUES > The > .Fn uname > -function returns a non-negative value if successful; > +function returns 0 if successful; > otherwise the value -1 is returned and the global variable > .Va errno > is set to indicate the error.
Re: fix uname.3 manpage.
On Sat, 8 Oct 2016, Gleydson Soares wrote: > I stlumbled upon it, while reading uname(1) code. ... > --- uname.c 24 Dec 2015 15:01:24 - 1.17 > +++ uname.c 9 Oct 2016 18:41:31 - > @@ -101,7 +101,7 @@ main(int argc, char *argv[]) > print_mask = PRINT_SYSNAME; > } > > - if (uname(&u)) > + if (uname(&u) == -1) > err(1, NULL); ok guenther@ Looks like eigrpd needs fixing too.
Re: fix uname.3 manpage.
Philip Guenther writes: > > On Sat, 8 Oct 2016, Gleydson Soares wrote: > > uname(3) function returns 0 on successful and -1 on failure. > > "non-negative value" is wrong here. > > Hmm, that's a direct quote from the standard. While our implementation > only returns zero on success, an application which checked for a return > value of exactly zero would be non-portable. > > > Philip I stlumbled upon it, while reading uname(1) code. src/usr.bin/uname/uname.c:104 if (uname(&u)) err(1, NULL); Index: uname.c === RCS file: /cvs/src/usr.bin/uname/uname.c,v retrieving revision 1.17 diff -u -p -r1.17 uname.c --- uname.c 24 Dec 2015 15:01:24 - 1.17 +++ uname.c 9 Oct 2016 18:41:31 - @@ -101,7 +101,7 @@ main(int argc, char *argv[]) print_mask = PRINT_SYSNAME; } - if (uname(&u)) + if (uname(&u) == -1) err(1, NULL); if (print_mask & PRINT_SYSNAME) {
Re: fix uname.3 manpage.
On Sat, 8 Oct 2016, Gleydson Soares wrote: > uname(3) function returns 0 on successful and -1 on failure. > "non-negative value" is wrong here. Hmm, that's a direct quote from the standard. While our implementation only returns zero on success, an application which checked for a return value of exactly zero would be non-portable. Philip
Re: fix uname.3 manpage.
Hi Gleydson, Gleydson Soares wrote on Sat, Oct 08, 2016 at 05:50:00PM -0300: > uname(3) function returns 0 on successful and -1 on failure. > "non-negative value" is wrong here. It is not wrong. When uname(3) succeeds, it does return a non-negative value, even though that may always be 0 depending on the particular implementation. The patch is not OK. POSIX allows implementations of uname(3) to return values greater than 0 on success. So your patch might goad the unwary into writing non-portable code. Yours, Ingo > Index: uname.3 > === > RCS file: /cvs/src/lib/libc/gen/uname.3,v > retrieving revision 1.15 > diff -u -p -r1.15 uname.3 > --- uname.3 21 Jan 2014 03:15:45 - 1.15 > +++ uname.3 9 Oct 2016 17:50:16 - > @@ -65,7 +65,7 @@ Machine hardware platform. > .Sh RETURN VALUES > The > .Fn uname > -function returns a non-negative value if successful; > +function returns 0 if successful; > otherwise the value -1 is returned and the global variable > .Va errno > is set to indicate the error.
fix uname.3 manpage.
uname(3) function returns 0 on successful and -1 on failure. "non-negative value" is wrong here. Index: uname.3 === RCS file: /cvs/src/lib/libc/gen/uname.3,v retrieving revision 1.15 diff -u -p -r1.15 uname.3 --- uname.3 21 Jan 2014 03:15:45 - 1.15 +++ uname.3 9 Oct 2016 17:50:16 - @@ -65,7 +65,7 @@ Machine hardware platform. .Sh RETURN VALUES The .Fn uname -function returns a non-negative value if successful; +function returns 0 if successful; otherwise the value -1 is returned and the global variable .Va errno is set to indicate the error.