From 183083c35972611e7786c7ee0c96d7da571631ed Mon Sep 17 00:00:00 2001 From: Carlos O'Donell Date: Wed, 29 Apr 2020 16:31:29 -0400 Subject: 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 --- support/tst-support_capture_subprocess.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'support/tst-support_capture_subprocess.c') diff --git a/support/tst-support_capture_subprocess.c b/support/tst-support_capture_subprocess.c index 67bbc1e8ae..6094dba49e 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; -- cgit 1.4.1