Patchwork [4,of,4,STABLE] chg: reset errno prior to calling strtol()

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 3, 2020, 2:54 a.m.
Message ID <81da6feb5000140adb89.1604372088@mimosa>
Download mbox | patch
Permalink /patch/47538/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 3, 2020, 2:54 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# 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.
Augie Fackler - Nov. 17, 2020, 7:34 p.m.
queued for stable, thanks

> On Nov 2, 2020, at 21:54, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # 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) {
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

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) {