Module Name: src Committed By: rillig Date: Sun Sep 10 10:18:05 UTC 2023
Modified Files: src/usr.bin/make: main.c Log Message: make: fix lint warning about strchr main.c(416): warning: call to 'strchr' effectively discards 'const' from argument [346] Even though C23 turns strchr into a const-generic function, it doesn't do the same for strtol, so use separate pointers for the current parsing position and the end of a number, as their constness differs. To generate a diff of this commit: cvs rdiff -u -r1.596 -r1.597 src/usr.bin/make/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.596 src/usr.bin/make/main.c:1.597 --- src/usr.bin/make/main.c:1.596 Sat Sep 9 16:41:04 2023 +++ src/usr.bin/make/main.c Sun Sep 10 10:18:05 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.596 2023/09/09 16:41:04 sjg Exp $ */ +/* $NetBSD: main.c,v 1.597 2023/09/10 10:18:05 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -111,7 +111,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.596 2023/09/09 16:41:04 sjg Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.597 2023/09/10 10:18:05 rillig Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -395,13 +395,15 @@ MainParseArgJobsInternal(const char *arg } static void -MainParseArgJobs(const char *argvalue) +MainParseArgJobs(const char *arg) { - char *p; + const char *p; + char *end; char v[12]; forceJobs = true; - opts.maxJobs = (int)strtol(argvalue, &p, 0); + opts.maxJobs = (int)strtol(arg, &end, 0); + p = arg + (end - arg); #ifdef _SC_NPROCESSORS_ONLN if (*p != '\0') { double d; @@ -409,11 +411,12 @@ MainParseArgJobs(const char *argvalue) if (*p == 'C') { d = (opts.maxJobs > 0) ? opts.maxJobs : 1; } else if (*p == '.') { - d = strtod(argvalue, &p); + d = strtod(arg, &end); + p = arg + (end - arg); } else d = 0; if (d > 0) { - p = strchr(argvalue, 0); + p = ""; opts.maxJobs = (int)sysconf(_SC_NPROCESSORS_ONLN); opts.maxJobs = (int)(d * (double)opts.maxJobs); }