NetBSD Problem Report #49640

From www@NetBSD.org  Wed Feb  4 23:17:52 2015
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id B4B33A5B2E
	for <gnats-bugs@gnats.NetBSD.org>; Wed,  4 Feb 2015 23:17:52 +0000 (UTC)
Message-Id: <20150204231751.A466DA65B6@mollari.NetBSD.org>
Date: Wed,  4 Feb 2015 23:17:51 +0000 (UTC)
From: n54@gmx.com
Reply-To: n54@gmx.com
To: gnats-bugs@NetBSD.org
Subject: Improve example of strto[iu](3)
X-Send-Pr-Version: www-1.0

>Number:         49640
>Category:       lib
>Synopsis:       Improve example of strto[iu](3)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          closed
>Class:          doc-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Feb 04 23:20:00 +0000 2015
>Closed-Date:    Sat Jul 11 10:01:50 +0000 2015
>Last-Modified:  Sat Jul 11 10:01:50 +0000 2015
>Originator:     Kamil Rytarowski
>Release:        current
>Organization:
>Environment:
N/A
>Description:
In the example usage of strtoi(3) and strtou(3) there is reused warn(3), which takes a value of errno. errno for the string conversion calls is guaranteed to be unchanged so warn(3) prints trash.
>How-To-Repeat:
man strtoi
man strtou
>Fix:
diff --git a/libc/stdlib/strtol.3 b/libc/stdlib/strtol.3
index 5eb586b..a1f3834 100644
--- a/libc/stdlib/strtol.3
+++ b/libc/stdlib/strtol.3
@@ -243,8 +243,8 @@ function is the simplest to use:
 int e;
 intmax_t lval = strtoi(buf, NULL, 0, 1, 99, &e);
 if (e)
-	warn("conversion of `%s' to a number failed, using %jd",
-	    buf, lval);
+	warnx("conversion of `%s' to a number failed, using %jd: %s",
+	    buf, lval, strerror(3));
 .Ed
 .Pp
 This will always return a number in
diff --git a/libc/stdlib/strtoul.3 b/libc/stdlib/strtoul.3
index ee0ebde..d3a59fa 100644
--- a/libc/stdlib/strtoul.3
+++ b/libc/stdlib/strtoul.3
@@ -240,8 +240,8 @@ function is the simplest to use:
 int e;
 uintmax_t lval = strtou(buf, NULL, 0, 1, 99, &e);
 if (e)
-	warn("conversion of `%s' to a number failed, using %ju",
-	    buf, lval);
+	warnx("conversion of `%s' to a number failed, using %ju: %s",
+	    buf, lval, strerror(e));
 .Ed
 .Pp
 This will always return a number in

>Release-Note:

>Audit-Trail:
From: "Kamil Rytarowski" <n54@gmx.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: lib/49640
Date: Fri, 20 Feb 2015 21:55:04 +0100

 Ping!

 The currently public set of patches regarding strtoi(3):

 Bugs in tests:
 http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=49632

 Bugs in man pages:
 http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=49640
 Side comments, there is a new function in the API: warnc(3), it should replace warn(3), not the warnx(3) one.

 New ATF tests:
 http://mail-index.netbsd.org/tech-userlevel/2015/02/03/msg008903.html

 Proposed improvement to cat(1):
 http://mail-index.netbsd.org/tech-userlevel/2015/01/31/msg008900.html

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/49640 CVS commit: src/lib/libc/stdlib
Date: Tue, 10 Mar 2015 09:00:58 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Tue Mar 10 13:00:58 UTC 2015

 Modified Files:
 	src/lib/libc/stdlib: strtol.3 strtoul.3

 Log Message:
 PR/49640: Kamil Rytarowski: Improve error printing


 To generate a diff of this commit:
 cvs rdiff -u -r1.29 -r1.30 src/lib/libc/stdlib/strtol.3
 cvs rdiff -u -r1.28 -r1.29 src/lib/libc/stdlib/strtoul.3

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/49640 CVS commit: [netbsd-7] src
Date: Wed, 22 Apr 2015 07:18:59 +0000

 Module Name:	src
 Committed By:	snj
 Date:		Wed Apr 22 07:18:58 UTC 2015

 Modified Files:
 	src/distrib/sets/lists/base [netbsd-7]: ad.aarch64 ad.arm ad.mips
 	    ad.powerpc md.amd64 md.sparc64 shl.mi
 	src/distrib/sets/lists/comp [netbsd-7]: mi
 	src/distrib/sets/lists/debug [netbsd-7]: ad.aarch64 ad.arm ad.mips
 	    ad.powerpc md.amd64 md.sparc64 shl.mi
 	src/include [netbsd-7]: inttypes.h
 	src/lib/libc [netbsd-7]: shlib_version
 	src/lib/libc/stdlib [netbsd-7]: Makefile.inc strtol.3 strtoul.3
 	src/sys/lib/libkern [netbsd-7]: Makefile.libkern libkern.h
 	src/tools/compat [netbsd-7]: Makefile compat_defs.h configure
 	    configure.ac nbtool_config.h.in
 Added Files:
 	src/common/lib/libc/stdlib [netbsd-7]: _strtoi.h strtoi.c strtou.c

 Log Message:
 Pull up following revision(s) (requested by roy in ticket #648):
 	common/lib/libc/stdlib/_strtoi.h: revisions 1.1, 1.2
 	common/lib/libc/stdlib/strtoi.c: revision 1.1
 	common/lib/libc/stdlib/strtou.c: revision 1.1
 	distrib/sets/lists/base/ad.aarch64: patch
 	distrib/sets/lists/base/ad.arm: patch
 	distrib/sets/lists/base/ad.mips: patch
 	distrib/sets/lists/base/ad.powerpc: patch
 	distrib/sets/lists/base/md.amd64: patch
 	distrib/sets/lists/base/md.sparc64: patch
 	distrib/sets/lists/base/shl.mi: patch
 	distrib/sets/lists/comp/mi: revision 1.1939
 	distrib/sets/lists/debug/ad.aarch64: patch
 	distrib/sets/lists/debug/ad.arm: patch
 	distrib/sets/lists/debug/ad.mips: patch
 	distrib/sets/lists/debug/ad.powerpc: patch
 	distrib/sets/lists/debug/md.amd64: patch
 	distrib/sets/lists/debug/md.sparc64: patch
 	distrib/sets/lists/debug/shl.mi: patch
 	include/inttypes.h: revision 1.11
 	lib/libc/shlib_version: patch
 	lib/libc/stdlib/Makefile.inc: revision 1.84
 	lib/libc/stdlib/strtol.3: revisions 1.27-1.31
 	lib/libc/stdlib/strtoul.3: revisions 1.26-1.29
 	sys/lib/libkern/Makefile.libkern: revision 1.37
 	sys/lib/libkern/libkern.h: revision 1.117
 	tools/compat/Makefile: revision 1.73
 	tools/compat/compat_defs.h: revision 1.101
 	tools/compat/configure.ac: revision 1.83
 	tools/compat/configure: revision 1.82
 	tools/compat/nbtool_config.h.in: revision 1.36
 add strto{i,u} from Kamil Rytarowski as discussed in tech-userlevel.
 --
 strtoi and strtou additions
 --
 strtoi and strtou for the kernel
 --
 strtoi and strtou additions
 --
 strtoi and strtou man pages
 --
 strto{i,u}
 --
 regen
 --
 Remove trailing whitespace.
 --
 match variable names with man page (Kamil Rytarowski)
 --
 cleanups from (Kamil Rytarowski)
 --
 add strtoi strtou (Kamil Rytarowski)
 --
 PR/49640: Kamil Rytarowski: Improve error printing
 --
 Use existing month for Dd.


 To generate a diff of this commit:
 cvs rdiff -u -r0 -r1.2.2.2 src/common/lib/libc/stdlib/_strtoi.h
 cvs rdiff -u -r0 -r1.1.2.2 src/common/lib/libc/stdlib/strtoi.c \
     src/common/lib/libc/stdlib/strtou.c
 cvs rdiff -u -r1.2.2.3 -r1.2.2.4 src/distrib/sets/lists/base/ad.aarch64
 cvs rdiff -u -r1.54.2.5 -r1.54.2.6 src/distrib/sets/lists/base/ad.arm
 cvs rdiff -u -r1.48.2.5 -r1.48.2.6 src/distrib/sets/lists/base/ad.mips
 cvs rdiff -u -r1.17.2.4 -r1.17.2.5 src/distrib/sets/lists/base/ad.powerpc
 cvs rdiff -u -r1.244.2.5 -r1.244.2.6 src/distrib/sets/lists/base/md.amd64
 cvs rdiff -u -r1.232.2.5 -r1.232.2.6 src/distrib/sets/lists/base/md.sparc64
 cvs rdiff -u -r1.712.2.5 -r1.712.2.6 src/distrib/sets/lists/base/shl.mi
 cvs rdiff -u -r1.1906.2.4 -r1.1906.2.5 src/distrib/sets/lists/comp/mi
 cvs rdiff -u -r1.2.2.4 -r1.2.2.5 src/distrib/sets/lists/debug/ad.aarch64
 cvs rdiff -u -r1.42.2.5 -r1.42.2.6 src/distrib/sets/lists/debug/ad.arm
 cvs rdiff -u -r1.38.2.5 -r1.38.2.6 src/distrib/sets/lists/debug/ad.mips
 cvs rdiff -u -r1.18.2.5 -r1.18.2.6 src/distrib/sets/lists/debug/ad.powerpc
 cvs rdiff -u -r1.63.2.5 -r1.63.2.6 src/distrib/sets/lists/debug/md.amd64
 cvs rdiff -u -r1.61.2.5 -r1.61.2.6 src/distrib/sets/lists/debug/md.sparc64
 cvs rdiff -u -r1.71.2.9 -r1.71.2.10 src/distrib/sets/lists/debug/shl.mi
 cvs rdiff -u -r1.10 -r1.10.6.1 src/include/inttypes.h
 cvs rdiff -u -r1.254 -r1.254.2.1 src/lib/libc/shlib_version
 cvs rdiff -u -r1.82 -r1.82.2.1 src/lib/libc/stdlib/Makefile.inc
 cvs rdiff -u -r1.26 -r1.26.24.1 src/lib/libc/stdlib/strtol.3
 cvs rdiff -u -r1.25 -r1.25.24.1 src/lib/libc/stdlib/strtoul.3
 cvs rdiff -u -r1.35 -r1.35.2.1 src/sys/lib/libkern/Makefile.libkern
 cvs rdiff -u -r1.115 -r1.115.2.1 src/sys/lib/libkern/libkern.h
 cvs rdiff -u -r1.72 -r1.72.4.1 src/tools/compat/Makefile
 cvs rdiff -u -r1.97.2.1 -r1.97.2.2 src/tools/compat/compat_defs.h
 cvs rdiff -u -r1.81 -r1.81.2.1 src/tools/compat/configure
 cvs rdiff -u -r1.82 -r1.82.2.1 src/tools/compat/configure.ac
 cvs rdiff -u -r1.35 -r1.35.2.1 src/tools/compat/nbtool_config.h.in

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: kamil@NetBSD.org
State-Changed-When: Sat, 11 Jul 2015 12:01:50 +0200
State-Changed-Why:
Patch applied.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.