Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin clear errno before strto(u)l() if we're going to test i...



details:   https://anonhg.NetBSD.org/src/rev/7039635737ce
branches:  trunk
changeset: 545860:7039635737ce
user:      lukem <lukem%NetBSD.org@localhost>
date:      Thu Apr 17 04:01:56 2003 +0000

description:
clear errno before strto(u)l() if we're going to test it for ERANGE afterwards

diffstat:

 sbin/fsirand/fsirand.c |  5 +++--
 sbin/mknod/mknod.c     |  5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diffs (52 lines):

diff -r ba44296d40a7 -r 7039635737ce sbin/fsirand/fsirand.c
--- a/sbin/fsirand/fsirand.c    Thu Apr 17 03:25:56 2003 +0000
+++ b/sbin/fsirand/fsirand.c    Thu Apr 17 04:01:56 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fsirand.c,v 1.20 2003/04/02 10:39:29 fvdl Exp $        */
+/*     $NetBSD: fsirand.c,v 1.21 2003/04/17 04:01:56 lukem Exp $       */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: fsirand.c,v 1.20 2003/04/02 10:39:29 fvdl Exp $");
+__RCSID("$NetBSD: fsirand.c,v 1.21 2003/04/17 04:01:56 lukem Exp $");
 #endif /* lint */
 
 #include <sys/param.h>
@@ -256,6 +256,7 @@
                        pflag++;
                        break;
                case 'x':
+                       errno = 0;
                        xorval = strtol(optarg, &ep, 0);
                        if ((xorval == LONG_MIN || xorval == LONG_MAX) &&
                            errno == ERANGE)
diff -r ba44296d40a7 -r 7039635737ce sbin/mknod/mknod.c
--- a/sbin/mknod/mknod.c        Thu Apr 17 03:25:56 2003 +0000
+++ b/sbin/mknod/mknod.c        Thu Apr 17 04:01:56 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mknod.c,v 1.24 2001/10/08 04:45:29 lukem Exp $ */
+/*     $NetBSD: mknod.c,v 1.25 2003/04/17 04:01:57 lukem Exp $ */
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include <sys/cdefs.h>
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1998 The NetBSD Foundation, Inc.  All rights reserved.\n");
-__RCSID("$NetBSD: mknod.c,v 1.24 2001/10/08 04:45:29 lukem Exp $");
+__RCSID("$NetBSD: mknod.c,v 1.25 2003/04/17 04:01:57 lukem Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -133,6 +133,7 @@
        }
 
        for (n = 0; n < argc; n++) {
+               errno = 0;
                numbers[n] = strtoul(argv[n], &p, 0);
                if ((p && *p != '\0') ||
                    (numbers[n] == ULONG_MAX && errno == ERANGE))



Home | Main Index | Thread Index | Old Index