Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/gen make sure errno is always set when we return -1...



details:   https://anonhg.NetBSD.org/src/rev/db3ccc3aa46c
branches:  trunk
changeset: 974973:db3ccc3aa46c
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Aug 18 19:18:06 2020 +0000

description:
make sure errno is always set when we return -1 (Anon Ymous)

diffstat:

 lib/libc/gen/dehumanize_number.c |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (30 lines):

diff -r 316adc2219ee -r db3ccc3aa46c lib/libc/gen/dehumanize_number.c
--- a/lib/libc/gen/dehumanize_number.c  Tue Aug 18 17:08:05 2020 +0000
+++ b/lib/libc/gen/dehumanize_number.c  Tue Aug 18 19:18:06 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dehumanize_number.c,v 1.7 2014/10/01 13:53:04 apb Exp $        */
+/*     $NetBSD: dehumanize_number.c,v 1.8 2020/08/18 19:18:06 christos Exp $   */
 
 /*
  * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: dehumanize_number.c,v 1.7 2014/10/01 13:53:04 apb Exp $");
+__RCSID("$NetBSD: dehumanize_number.c,v 1.8 2020/08/18 19:18:06 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -104,8 +104,10 @@
 
        errno = 0;
        tmp = strtoll(str, &ep, 10);
-       if (str[0] == '\0' || (ep != delimit && *ep != '\0'))
+       if (str[0] == '\0' || (ep != delimit && *ep != '\0')) {
+               errno = EINVAL;
                return -1; /* Not a number. */
+       }
        else if (errno == ERANGE && (tmp == LLONG_MAX || tmp == LLONG_MIN))
                return -1; /* Out of range. */
 



Home | Main Index | Thread Index | Old Index