Module Name: src Committed By: riastradh Date: Fri Feb 14 04:38:36 UTC 2020
Modified Files: src/sys/external/bsd/common/include/linux: kernel.h src/sys/external/bsd/drm2/dist/drm: drm_modes.c Log Message: Implement (obsolete) simple_strtol stub; reduce diff. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/external/bsd/common/include/linux/kernel.h cvs rdiff -u -r1.7 -r1.8 src/sys/external/bsd/drm2/dist/drm/drm_modes.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/external/bsd/common/include/linux/kernel.h diff -u src/sys/external/bsd/common/include/linux/kernel.h:1.23 src/sys/external/bsd/common/include/linux/kernel.h:1.24 --- src/sys/external/bsd/common/include/linux/kernel.h:1.23 Mon Sep 30 12:20:54 2019 +++ src/sys/external/bsd/common/include/linux/kernel.h Fri Feb 14 04:38:36 2020 @@ -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 @@ kstrtol(const char *s, unsigned base, lo 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) { Index: src/sys/external/bsd/drm2/dist/drm/drm_modes.c diff -u src/sys/external/bsd/drm2/dist/drm/drm_modes.c:1.7 src/sys/external/bsd/drm2/dist/drm/drm_modes.c:1.8 --- src/sys/external/bsd/drm2/dist/drm/drm_modes.c:1.7 Mon Aug 27 04:58:19 2018 +++ src/sys/external/bsd/drm2/dist/drm/drm_modes.c Fri Feb 14 04:38:36 2020 @@ -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 @@ bool drm_mode_parse_command_line_for_con 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 @@ bool drm_mode_parse_command_line_for_con 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 @@ bool drm_mode_parse_command_line_for_con } 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