Patchwork osutil: move declaration to top of the scope

login
register
mail settings
Submitter Yuya Nishihara
Date March 22, 2020, 12:39 p.m.
Message ID <bbb3fc76b442292b20e5.1584880745@mimosa>
Download mbox | patch
Permalink /patch/45862/
State Accepted
Headers show

Comments

Yuya Nishihara - March 22, 2020, 12:39 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1584870004 -32400
#      Sun Mar 22 18:40:04 2020 +0900
# Node ID bbb3fc76b442292b20e5dccccf97ea462997eb5e
# Parent  a7f8c657a3f08d1e71ee112f797df011eea7a078
osutil: move declaration to top of the scope

Otherwise the build would fail with -Werror=declaration-after-statement.
Augie Fackler - March 23, 2020, 3:52 p.m.
Queued, thanks

> On Mar 22, 2020, at 08:39, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1584870004 -32400
> #      Sun Mar 22 18:40:04 2020 +0900
> # Node ID bbb3fc76b442292b20e5dccccf97ea462997eb5e
> # Parent  a7f8c657a3f08d1e71ee112f797df011eea7a078
> osutil: move declaration to top of the scope
> 
> Otherwise the build would fail with -Werror=declaration-after-statement.
> 
> diff --git a/mercurial/cext/osutil.c b/mercurial/cext/osutil.c
> --- a/mercurial/cext/osutil.c
> +++ b/mercurial/cext/osutil.c
> @@ -810,9 +810,10 @@ static PyObject *setprocname(PyObject *s
> 			/* Check the memory we can use. Typically, argv[i] and
> 			 * argv[i + 1] are continuous. */
> 			for (i = 0; i < argc; ++i) {
> +				size_t len;
> 				if (argv[i] > argvend || argv[i] < argvstart)
> 					break; /* not continuous */
> -				size_t len = strlen(argv[i]);
> +				len = strlen(argv[i]);
> 				argvend = argv[i] + len + 1 /* '\0' */;
> 			}
> 			if (argvend > argvstart) /* sanity check */
> @@ -1169,10 +1170,10 @@ static PyObject *getfsmountpoint(PyObjec
> static PyObject *unblocksignal(PyObject *self, PyObject *args)
> {
> 	int sig = 0;
> +	sigset_t set;
> 	int r;
> 	if (!PyArg_ParseTuple(args, "i", &sig))
> 		return NULL;
> -	sigset_t set;
> 	r = sigemptyset(&set);
> 	if (r != 0)
> 		return PyErr_SetFromErrno(PyExc_OSError);
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/cext/osutil.c b/mercurial/cext/osutil.c
--- a/mercurial/cext/osutil.c
+++ b/mercurial/cext/osutil.c
@@ -810,9 +810,10 @@  static PyObject *setprocname(PyObject *s
 			/* Check the memory we can use. Typically, argv[i] and
 			 * argv[i + 1] are continuous. */
 			for (i = 0; i < argc; ++i) {
+				size_t len;
 				if (argv[i] > argvend || argv[i] < argvstart)
 					break; /* not continuous */
-				size_t len = strlen(argv[i]);
+				len = strlen(argv[i]);
 				argvend = argv[i] + len + 1 /* '\0' */;
 			}
 			if (argvend > argvstart) /* sanity check */
@@ -1169,10 +1170,10 @@  static PyObject *getfsmountpoint(PyObjec
 static PyObject *unblocksignal(PyObject *self, PyObject *args)
 {
 	int sig = 0;
+	sigset_t set;
 	int r;
 	if (!PyArg_ParseTuple(args, "i", &sig))
 		return NULL;
-	sigset_t set;
 	r = sigemptyset(&set);
 	if (r != 0)
 		return PyErr_SetFromErrno(PyExc_OSError);