* lib/nproc.c (parse_omp_threads): * lib/omp-init.c (parse_omp_threads): Remove unnecessary initialization and unnecessary check whether endptr == NULL. Reported by Alejandro Colomar in: https://lore.kernel.org/liba2i/jx4664ishtl34eg2npdrv5fkfdiczqnlq3vjuacjrupjvh377x@gddcftzgwmfq/ --- ChangeLog | 10 ++++++++++ lib/nproc.c | 22 +++++++++------------- lib/omp-init.c | 22 +++++++++------------- 3 files changed, 28 insertions(+), 26 deletions(-)
diff --git a/ChangeLog b/ChangeLog index dae23affdb..8a788702e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2025-03-19 Paul Eggert <egg...@cs.ucla.edu> + + nproc, openmp-init: omit unnecessary strtol code + * lib/nproc.c (parse_omp_threads): + * lib/omp-init.c (parse_omp_threads): + Remove unnecessary initialization and unnecessary check + whether endptr == NULL. + Reported by Alejandro Colomar in: + https://lore.kernel.org/liba2i/jx4664ishtl34eg2npdrv5fkfdiczqnlq3vjuacjrupjvh377x@gddcftzgwmfq/ + 2025-03-19 Bruno Haible <br...@clisp.org> getlogin, getlogin_r: Fix typo in documentation. diff --git a/lib/nproc.c b/lib/nproc.c index d48e4dd94f..051426a6f0 100644 --- a/lib/nproc.c +++ b/lib/nproc.c @@ -398,20 +398,16 @@ parse_omp_threads (char const* threads) /* Convert it from positive decimal to 'unsigned long'. */ if (c_isdigit (*threads)) { - char *endptr = NULL; + char *endptr; unsigned long int value = strtoul (threads, &endptr, 10); - - if (endptr != NULL) - { - while (*endptr != '\0' && c_isspace (*endptr)) - endptr++; - if (*endptr == '\0') - return value; - /* Also accept the first value in a nesting level, - since we can't determine the nesting level from env vars. */ - else if (*endptr == ',') - return value; - } + while (*endptr != '\0' && c_isspace (*endptr)) + endptr++; + if (*endptr == '\0') + return value; + /* Also accept the first value in a nesting level, + since we can't determine the nesting level from env vars. */ + else if (*endptr == ',') + return value; } return ret; diff --git a/lib/omp-init.c b/lib/omp-init.c index 53d0747e26..b72bec9f23 100644 --- a/lib/omp-init.c +++ b/lib/omp-init.c @@ -44,20 +44,16 @@ parse_omp_threads (char const* threads) /* Convert it from positive decimal to 'unsigned long'. */ if (c_isdigit (*threads)) { - char *endptr = NULL; + char *endptr; unsigned long int value = strtoul (threads, &endptr, 10); - - if (endptr != NULL) - { - while (*endptr != '\0' && c_isspace (*endptr)) - endptr++; - if (*endptr == '\0') - return value; - /* Also accept the first value in a nesting level, - since we can't determine the nesting level from env vars. */ - else if (*endptr == ',') - return value; - } + while (*endptr != '\0' && c_isspace (*endptr)) + endptr++; + if (*endptr == '\0') + return value; + /* Also accept the first value in a nesting level, + since we can't determine the nesting level from env vars. */ + else if (*endptr == ',') + return value; } return ret; -- 2.45.2