OSDN Git Service

Silence false positive warnings on GCC.
authorJosh Gao <jmgao@google.com>
Tue, 15 Mar 2016 01:15:15 +0000 (18:15 -0700)
committerJosh Gao <jmgao@google.com>
Tue, 15 Mar 2016 02:45:52 +0000 (19:45 -0700)
We still use GCC to build the bionic unit tests into CTS, and it emits a
false positive -Wmissing-field-initializers warning for the C++11 aggregate
initialization syntax `Foo foo = {}`.

Bug: http://b/27656293
Change-Id: I016d8dae6d6cd28afe4bc19250c2a8fba908f8e6
(cherry picked from commit d7878529b80295625df610bd32dadf11d507e8c0)

tests/signal_test.cpp

index 8c1e834..32308aa 100644 (file)
@@ -387,13 +387,15 @@ TEST(signal, rt_tgsigqueueinfo) {
     "* https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=66dd34ad31e5963d72a700ec3f2449291d322921\n";
   static siginfo received;
 
-  struct sigaction handler = {};
+  struct sigaction handler;
+  memset(&handler, 0, sizeof(handler));
   handler.sa_sigaction = [](int, siginfo_t* siginfo, void*) { received = *siginfo; };
   handler.sa_flags = SA_SIGINFO;
 
   ASSERT_EQ(0, sigaction(SIGUSR1, &handler, nullptr));
 
-  siginfo sent = {};
+  siginfo sent;
+  memset(&sent, 0, sizeof(sent));
 
   sent.si_code = SI_TKILL;
   ASSERT_EQ(0, syscall(SYS_rt_tgsigqueueinfo, getpid(), gettid(), SIGUSR1, &sent))