From: GNU Libc Maintainers Date: Thu, 15 Feb 2024 22:29:51 +0000 (+0000) Subject: git-strtol-test X-Git-Tag: archive/raspbian/2.31-13+rpi1+deb11u10~89 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4405e69b854723bfc889ae2f02438b923bf6482b;p=glibc.git git-strtol-test Committed for glibc 2.32 commit 183083c35972611e7786c7ee0c96d7da571631ed Author: Carlos O'Donell Date: Wed Apr 29 16:31:29 2020 -0400 support: Set errno before testing it. In test-conainer we should set errno to 0 before calling strtol, and check after with TEST_COMPARE. In tst-support_capture_subprocess we should set errno to 0 before checking it after the call to strtol. Tested on x86_64. Reviewed-by: DJ Delorie Gbp-Pq: Topic hurd-i386 Gbp-Pq: Name git-strtol-test.diff --- diff --git a/support/test-container.c b/support/test-container.c index 4c5825455..843227dd8 100644 --- a/support/test-container.c +++ b/support/test-container.c @@ -902,7 +902,9 @@ main (int argc, char **argv) else if (nt == 3 && strcmp (the_words[0], "chmod") == 0) { long int m; + errno = 0; m = strtol (the_words[1], NULL, 0); + TEST_COMPARE (errno, 0); if (chmod (the_words[2], m) < 0) FAIL_EXIT1 ("chmod %s: %s\n", the_words[2], strerror (errno)); diff --git a/support/tst-support_capture_subprocess.c b/support/tst-support_capture_subprocess.c index 67bbc1e8a..6094dba49 100644 --- a/support/tst-support_capture_subprocess.c +++ b/support/tst-support_capture_subprocess.c @@ -133,7 +133,9 @@ static int parse_int (const char *str) { char *endptr; - long int ret = strtol (str, &endptr, 10); + long int ret; + errno = 0; + ret = strtol (str, &endptr, 10); TEST_COMPARE (errno, 0); TEST_VERIFY (ret >= 0 && ret <= INT_MAX); return ret;