[PATCH] D14817: [sanitizer] Avoid -Wmaybe-uninitialized related warnings when building ASan with GCC.
Maxim Ostapenko via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 19 06:08:25 PST 2015
m.ostepenko created this revision.
m.ostepenko added reviewers: kcc, samsonov.
m.ostepenko added subscribers: llvm-commits, ygribov.
m.ostepenko set the repository for this revision to rL LLVM.
Herald added a subscriber: aemerson.
Hi!
Since "Use same shadow offset for aarch64" and "Enable optional ASan recovery" patches seem to work robustly in LLVM, I would like to perform another merge to GCC (GCC is on stage 3 now, but it is OK to perform merge now). For now, everything seems OK with library, except some warnings I got in GCC due to -Wmaybe-uninitialized switch:
```
/home/max/workspace/downloads/trunk/libsanitizer/asan/asan_interceptors.cc: In function ‘__sanitizer::uptr __interceptor_ptrace(int, int, void*, void*)’:
/home/max/workspace/downloads/trunk/libsanitizer/asan/asan_interceptors.cc:59:29: warning: ‘local_iovec.__sanitizer::__sanitizer_iovec::iov_len’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (__offset > __offset + __size) { \
^
In file included from /home/max/workspace/downloads/trunk/libsanitizer/asan/asan_interceptors.cc:196:0:
/home/max/workspace/downloads/trunk/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:2449:21: note: ‘local_iovec.__sanitizer::__sanitizer_iovec::iov_len’ was declared here
__sanitizer_iovec local_iovec;
^~~~~~~~~~~
```
This patch just adds proper default values to local variables in several places.
Repository:
rL LLVM
http://reviews.llvm.org/D14817
Files:
lib/sanitizer_common/sanitizer_common_interceptors.inc
lib/sanitizer_common/sanitizer_posix.cc
Index: lib/sanitizer_common/sanitizer_posix.cc
===================================================================
--- lib/sanitizer_common/sanitizer_posix.cc
+++ lib/sanitizer_common/sanitizer_posix.cc
@@ -177,6 +177,7 @@
case RdOnly: flags = O_RDONLY; break;
case WrOnly: flags = O_WRONLY | O_CREAT; break;
case RdWr: flags = O_RDWR | O_CREAT; break;
+ default: flags = O_RDONLY; break;
}
fd_t res = internal_open(filename, flags, 0660);
if (internal_iserror(res, errno_p))
Index: lib/sanitizer_common/sanitizer_common_interceptors.inc
===================================================================
--- lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -2448,7 +2448,7 @@
INTERCEPTOR(uptr, ptrace, int request, int pid, void *addr, void *data) {
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, ptrace, request, pid, addr, data);
- __sanitizer_iovec local_iovec;
+ __sanitizer_iovec local_iovec = {0, 0};
if (data) {
if (request == ptrace_setregs)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14817.40634.patch
Type: text/x-patch
Size: 1060 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151119/c88bb696/attachment.bin>
More information about the llvm-commits
mailing list