Module Name:    src
Committed By:   christos
Date:           Tue Aug 18 19:18:06 UTC 2020

Modified Files:
        src/lib/libc/gen: dehumanize_number.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/gen/dehumanize_number.c

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

Modified files:

Index: src/lib/libc/gen/dehumanize_number.c
diff -u src/lib/libc/gen/dehumanize_number.c:1.7 src/lib/libc/gen/dehumanize_number.c:1.8
--- src/lib/libc/gen/dehumanize_number.c:1.7	Wed Oct  1 09:53:04 2014
+++ src/lib/libc/gen/dehumanize_number.c	Tue Aug 18 15:18:06 2020
@@ -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 @@ dehumanize_number(const char *str, int64
 
 	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. */
 

Reply via email to