Message309503
gcc is a little bit lost and prints now the following (false) warning:
gcc -pthread -Wno-unused-result -Wsign-compare -g -Og -Wall -Wstrict-prototypes -std=c99 -Wextra
-Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -I. -I./Include -DPy_BUILD_CORE -c ./Modules/posixmodule.c -o Modules/posixmodule.o./Modules/posixmodule.c: In function ‘os_dup2_impl’:
./Modules/posixmodule.c:7785:9: warning: ‘res’ may be used uninitialized in this function [-Wmaybe-uninitialized]
int res;
^~~
The following change fools gcc that does not print anymore the warning:
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 47b79fcc79..90d73daf97 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -7845,7 +7845,7 @@ os_dup2_impl(PyObject *module, int fd, int fd2, int inheritable)
}
}
- if (inheritable || dup3_works == 0)
+ if (inheritable || (!inheritable && dup3_works == 0))
{
#endif
Py_BEGIN_ALLOW_THREADS
The change does not modify the behavior:
* dup3_works == 0 is equivalent to ((inheritable && dup3_works == 0) || (!inheritable && dup3_works == 0))
* (inheritable && dup3_works == 0) is always false
* hence dup3_works == 0 is equivalent to (!inheritable && dup3_works == 0) |
|
Date |
User |
Action |
Args |
2018-01-05 12:27:44 | xdegaye | set | recipients:
+ xdegaye, benjamin.peterson |
2018-01-05 12:27:44 | xdegaye | set | messageid: <1515155264.34.0.467229070634.issue32441@psf.upfronthosting.co.za> |
2018-01-05 12:27:44 | xdegaye | link | issue32441 messages |
2018-01-05 12:27:44 | xdegaye | create | |
|