Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd Implement (obsolete) simple_strtol stub; re...
details: https://anonhg.NetBSD.org/src/rev/fc420e5b3506
branches: trunk
changeset: 744845:fc420e5b3506
user: riastradh <riastradh%NetBSD.org@localhost>
date: Fri Feb 14 04:38:36 2020 +0000
description:
Implement (obsolete) simple_strtol stub; reduce diff.
diffstat:
sys/external/bsd/common/include/linux/kernel.h | 14 +++++++++-
sys/external/bsd/drm2/dist/drm/drm_modes.c | 37 +++++++++----------------
2 files changed, 27 insertions(+), 24 deletions(-)
diffs (111 lines):
diff -r 5ccee9dedd49 -r fc420e5b3506 sys/external/bsd/common/include/linux/kernel.h
--- a/sys/external/bsd/common/include/linux/kernel.h Fri Feb 14 04:38:23 2020 +0000
+++ b/sys/external/bsd/common/include/linux/kernel.h Fri Feb 14 04:38:36 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kernel.h,v 1.23 2019/09/30 12:20:54 christos Exp $ */
+/* $NetBSD: kernel.h,v 1.24 2020/02/14 04:38:36 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -196,6 +196,18 @@
return 0;
}
+static inline long
+simple_strtol(const char *s, char **endp, unsigned base)
+{
+ long v;
+
+ *endp = NULL; /* paranoia */
+ v = strtoll(s, endp, base);
+ if (v < LONG_MIN || LONG_MAX < v)
+ return 0;
+ return v;
+}
+
static __inline char * __printflike(2, 0)
kvasprintf(gfp_t gfp, const char *fmt, va_list va)
{
diff -r 5ccee9dedd49 -r fc420e5b3506 sys/external/bsd/drm2/dist/drm/drm_modes.c
--- a/sys/external/bsd/drm2/dist/drm/drm_modes.c Fri Feb 14 04:38:23 2020 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_modes.c Fri Feb 14 04:38:36 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: drm_modes.c,v 1.7 2018/08/27 04:58:19 riastradh Exp $ */
+/* $NetBSD: drm_modes.c,v 1.8 2020/02/14 04:38:36 riastradh Exp $ */
/*
* Copyright © 1997-2003 by The XFree86 Project, Inc.
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_modes.c,v 1.7 2018/08/27 04:58:19 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_modes.c,v 1.8 2020/02/14 04:38:36 riastradh Exp $");
#include <linux/list.h>
#include <linux/list_sort.h>
@@ -1236,7 +1236,7 @@
const char *name;
unsigned int namelen;
bool res_specified = false, bpp_specified = false, refresh_specified = false;
- long xres = 0, yres = 0, bpp = 32, refresh = 0;
+ unsigned int xres = 0, yres = 0, bpp = 32, refresh = 0;
bool yres_specified = false, cvt = false, rb = false;
bool interlace = false, margins = false, was_digit = false;
int i;
@@ -1261,35 +1261,26 @@
case '@':
if (!refresh_specified && !bpp_specified &&
!yres_specified && !cvt && !rb && was_digit) {
- if (kstrtol(&name[i+1], 10, &refresh) == 0) {
- refresh_specified = true;
- was_digit = false;
- } else {
- goto done;
- }
+ refresh = simple_strtol(&name[i+1], NULL, 10);
+ refresh_specified = true;
+ was_digit = false;
} else
goto done;
break;
case '-':
if (!bpp_specified && !yres_specified && !cvt &&
!rb && was_digit) {
- if (kstrtol(&name[i+1], 10, &bpp) == 0) {
- bpp_specified = true;
- was_digit = false;
- } else {
- goto done;
- }
+ bpp = simple_strtol(&name[i+1], NULL, 10);
+ bpp_specified = true;
+ was_digit = false;
} else
goto done;
break;
case 'x':
if (!yres_specified && was_digit) {
- if (kstrtol(&name[i+1], 10, &yres) == 0) {
- yres_specified = true;
- was_digit = false;
- } else {
- goto done;
- }
+ yres = simple_strtol(&name[i+1], NULL, 10);
+ yres_specified = true;
+ was_digit = false;
} else
goto done;
break;
@@ -1347,8 +1338,8 @@
}
if (i < 0 && yres_specified) {
- char *ch = NULL;
- xres = strtoll(name, &ch, 10);
+ char *ch;
+ xres = simple_strtol(name, &ch, 10);
if ((ch != NULL) && (*ch == 'x'))
res_specified = true;
else
Home |
Main Index |
Thread Index |
Old Index