This is the mail archive of the
gdb-testers@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Fix sometimes-uninitialized warning in gdbscm_value_address
- From: sergiodj+buildbot at sergiodj dot net
- To: gdb-testers at sourceware dot org
- Date: Fri, 22 Sep 2017 10:13:17 -0400
- Subject: [binutils-gdb] Fix sometimes-uninitialized warning in gdbscm_value_address
- Authentication-results: sourceware.org; auth=none
*** TEST RESULTS FOR COMMIT 432ae719d35c81324e01ae6bd9970cc43e69fa5e ***
Author: Simon Marchi <simon.marchi@ericsson.com>
Branch: master
Commit: 432ae719d35c81324e01ae6bd9970cc43e69fa5e
Fix sometimes-uninitialized warning in gdbscm_value_address
I am getting this warning with clang:
/home/emaisin/src/binutils-gdb/gdb/guile/scm-value.c:439:11: error: variable 'address' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
if (res_val != NULL)
^~~~~~~~~~~~~~~
/home/emaisin/src/binutils-gdb/gdb/guile/scm-value.c:444:32: note: uninitialized use occurs here
if (gdbscm_is_exception (address))
^~~~~~~
/home/emaisin/src/binutils-gdb/gdb/guile/scm-value.c:439:7: note: remove the 'if' if its condition is always true
if (res_val != NULL)
^~~~~~~~~~~~~~~~~~~~
/home/emaisin/src/binutils-gdb/gdb/guile/scm-value.c:427:18: note: initialize the variable 'address' to silence this warning
SCM address;
^
= nullptr
We can get rid of it with a small refactoring. I think it's a bit
cleaner/safer to initialize address with a pessimistic value and assign
it on success. Then there's no chance of using it uninitialized. If I
understand correctly, the NULL check on res_val was to check whether
value_addr threw, and that if value_addr returns without throwing, the
result will never be NULL. If that's true, we can skip the res_val
variable.
Tested by running gdb.guile/*.exp locally.
gdb/ChangeLog:
* guile/scm-value.c (gdbscm_value_address): Initialize address,
get rid of res_val.
- Follow-Ups:
- Failures on Fedora-i686, branch master
- Failures on Fedora-x86_64-m64, branch master
- Failures on Fedora-s390x-m64, branch master
- Failures on Fedora-x86_64-native-gdbserver-m32, branch master
- Failures on Ubuntu-AArch32-m32, branch master
- Failures on Fedora-x86_64-native-extended-gdbserver-m64, branch master
- Failures on Fedora-x86_64-m32, branch master
- Failures on Fedora-x86_64-native-gdbserver-m64, branch master
- Failures on Fedora-x86_64-native-extended-gdbserver-m32, branch master
- Failures on Ubuntu-AArch32-native-extended-gdbserver-m32, branch master
- Failures on Ubuntu-AArch64-m64, branch master
- Failures on Ubuntu-AArch32-native-gdbserver-m32, branch master