From patchwork Tue Nov 3 02:54:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4,of,4,STABLE] chg: reset errno prior to calling strtol() From: Yuya Nishihara X-Patchwork-Id: 47538 Message-Id: <81da6feb5000140adb89.1604372088@mimosa> To: mercurial-devel@mercurial-scm.org Date: Tue, 03 Nov 2020 11:54:48 +0900 # HG changeset patch # User Yuya Nishihara # Date 1604370261 -32400 # Tue Nov 03 11:24:21 2020 +0900 # Branch stable # Node ID 81da6feb5000140adb8972607415855953415233 # Parent 9534de20358f656be05e0633a3a2ba59932326f3 chg: reset errno prior to calling strtol() Otherwise we can't figure out if the last strtol() invocation failed or not. diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c --- a/contrib/chg/chg.c +++ b/contrib/chg/chg.c @@ -276,6 +276,7 @@ static void execcmdserver(const struct c debugmsg("closing files based on /proc contents"); struct dirent *de; while ((de = readdir(dp))) { + errno = 0; char *end; long fd_value = strtol(de->d_name, &end, 10); if (end == de->d_name) {