From nobody@FreeBSD.org  Thu Jan 28 22:42:31 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 33013106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 28 Jan 2010 22:42:31 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 21E038FC0A
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 28 Jan 2010 22:42:31 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o0SMgUpp074250
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 28 Jan 2010 22:42:30 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o0SMgUpn074249;
	Thu, 28 Jan 2010 22:42:30 GMT
	(envelope-from nobody)
Message-Id: <201001282242.o0SMgUpn074249@www.freebsd.org>
Date: Thu, 28 Jan 2010 22:42:30 GMT
From: Efstratios Karatzas <gpf.kira@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] strtonum(3) does undocumented clobbering of errno
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         143330
>Category:       docs
>Synopsis:       [patch] strtonum(3) does undocumented clobbering of errno
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bcr
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 28 22:50:11 UTC 2010
>Closed-Date:    Fri Oct 22 08:58:45 UTC 2010
>Last-Modified:  Fri Oct 22 08:58:45 UTC 2010
>Originator:     Efstratios Karatzas
>Release:        FreeBSD 8.0-STABLE i386
>Organization:
>Environment:
FreeBSD Eternal_Crusader 8.0-STABLE FreeBSD 8.0-STABLE #0: Thu Jan 21 17:46:20 EET 2010     root@Eternal_Crusader:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
As noted by commiter Bruce Evans in the pr trail of bin/142911,
strtonum() sets errno to 0 when no error is found.
Checked the source myself and this seems to be the case.
This behavior is undocumented.
>How-To-Repeat:

>Fix:
Take a look at the patch below.
I just added this information in the "return value" 
section of the man page.
First time editing a man page, hope this is ok.

Patch attached with submission follows:

--- strtonum.orig.3	2010-01-29 00:17:25.000000000 +0200
+++ strtonum.3	2010-01-29 00:27:31.000000000 +0200
@@ -84,6 +84,8 @@
 .Fa errstr
 will point to an error message.
 On success,
+.Va errno
+is set to 0 and
 .Fa *errstr
 will be set to
 .Dv NULL ;


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-doc->bcr  
Responsible-Changed-By: bcr 
Responsible-Changed-When: Fri Oct 8 14:17:17 UTC 2010 
Responsible-Changed-Why:  
I'll work on it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=143330 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: docs/143330: commit references a PR
Date: Thu, 21 Oct 2010 18:30:55 +0000 (UTC)

 Author: bcr (doc committer)
 Date: Thu Oct 21 18:30:48 2010
 New Revision: 214148
 URL: http://svn.freebsd.org/changeset/base/214148
 
 Log:
   Document strtonum()s behavior of setting errno to 0 when no error is found.
   
   PR:             docs/143330
   Submitted by:   Efstratios Karatzas (gpf dot kira at gmail dot com)
   Discussed with: ru@
   MFC after:      7 days
 
 Modified:
   head/lib/libc/stdlib/strtonum.3
 
 Modified: head/lib/libc/stdlib/strtonum.3
 ==============================================================================
 --- head/lib/libc/stdlib/strtonum.3	Thu Oct 21 18:21:19 2010	(r214147)
 +++ head/lib/libc/stdlib/strtonum.3	Thu Oct 21 18:30:48 2010	(r214148)
 @@ -83,6 +83,8 @@ is set, and
  .Fa errstr
  will point to an error message.
  On success,
 +.Va errno
 +is set to 0 and
  .Fa *errstr
  will be set to
  .Dv NULL ;
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: bcr 
State-Changed-When: Thu Oct 21 18:43:09 UTC 2010 
State-Changed-Why:  
Your patch was committed to HEAD. Until the MFC is done,  
this PR remains in patched state. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=143330 
State-Changed-From-To: patched->closed 
State-Changed-By: bcr 
State-Changed-When: Fri Oct 22 08:55:58 UTC 2010 
State-Changed-Why:  
A small test program by jh@ proves that this is not the case: 
#include <err.h> 
#include <errno.h> 
#include <stdio.h> 
#include <stdlib.h> 

int 
main() 
{ 

errno = EDOOFUS; 
if (strtonum("1", 1, 10, NULL) == 0) 
err(1, "failed"); 

printf("%dn", errno); 

return (0); 
} 

The original commit was reverted in r214200. PR closed. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=143330 
>Unformatted:
