[PATCH 1/2] Add braces in initializers for GCC 4.9 or older
H.J. Lu
hjl.tools@gmail.com
Sun Dec 15 12:09:56 GMT 2024
Add braces to silence GCC 4.9 or older:
getaddrinfo.c: In function ‘gaih_inet’:
getaddrinfo.c:1135:24: error: missing braces around initializer [-Werror=missing
-braces]
/ sizeof (struct gaih_typeproto)] = {0};
^
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
misc/tst-preadvwritev2-common.c | 2 +-
nss/getaddrinfo.c | 2 +-
sysdeps/unix/sysv/linux/tst-getcwd-smallbuff.c | 4 ++--
.../unix/sysv/linux/tst-socket-timestamp-compat.c | 4 ++--
time/tst-itimer.c | 13 ++++++++-----
5 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/misc/tst-preadvwritev2-common.c b/misc/tst-preadvwritev2-common.c
index 4556421a43..5d1f498da9 100644
--- a/misc/tst-preadvwritev2-common.c
+++ b/misc/tst-preadvwritev2-common.c
@@ -97,7 +97,7 @@ do_test_with_invalid_iov (void)
{
/* An invalid iovec buffer should trigger an invalid memory access
or an error (Linux for instance returns EFAULT). */
- struct iovec iov[IOV_MAX+1] = { 0 };
+ struct iovec iov[IOV_MAX+1] = { { 0 } };
TEST_VERIFY (preadv2 (temp_fd, iov, IOV_MAX + 1, 0, RWF_HIPRI) == -1);
TEST_VERIFY (errno == EINVAL || errno == ENOTSUP);
diff --git a/nss/getaddrinfo.c b/nss/getaddrinfo.c
index 78f50954df..2df9542e6f 100644
--- a/nss/getaddrinfo.c
+++ b/nss/getaddrinfo.c
@@ -1132,7 +1132,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
unsigned int *naddrs, struct scratch_buffer *tmpbuf)
{
struct gaih_servtuple st[sizeof (gaih_inet_typeproto)
- / sizeof (struct gaih_typeproto)] = {0};
+ / sizeof (struct gaih_typeproto)] = {{0}};
const char *orig_name = name;
diff --git a/sysdeps/unix/sysv/linux/tst-getcwd-smallbuff.c b/sysdeps/unix/sysv/linux/tst-getcwd-smallbuff.c
index 55362f6060..a024783885 100644
--- a/sysdeps/unix/sysv/linux/tst-getcwd-smallbuff.c
+++ b/sysdeps/unix/sysv/linux/tst-getcwd-smallbuff.c
@@ -59,7 +59,7 @@ send_fd (const int sock, const int fd)
{
struct cmsghdr hdr;
char buf[CMSG_SPACE (sizeof (int))];
- } cmsgbuf = {0};
+ } cmsgbuf = {{0}};
struct cmsghdr *cmsg;
struct iovec vec;
char ch = 'A';
@@ -92,7 +92,7 @@ recv_fd (const int sock)
{
struct cmsghdr hdr;
char buf[CMSG_SPACE(sizeof(int))];
- } cmsgbuf = {0};
+ } cmsgbuf = {{0}};
struct cmsghdr *cmsg;
struct iovec vec;
ssize_t n;
diff --git a/sysdeps/unix/sysv/linux/tst-socket-timestamp-compat.c b/sysdeps/unix/sysv/linux/tst-socket-timestamp-compat.c
index e0fb28d0b9..2d8739b00d 100644
--- a/sysdeps/unix/sysv/linux/tst-socket-timestamp-compat.c
+++ b/sysdeps/unix/sysv/linux/tst-socket-timestamp-compat.c
@@ -76,7 +76,7 @@ do_recvmsg_ancillary (bool use_multi_call, struct mmsghdr *mmhdr,
static void
do_test_large_buffer (bool mc)
{
- struct mmsghdr mmhdr = { 0 };
+ struct mmsghdr mmhdr = { { 0 } };
/* It should be large enough for either timeval/timespec and the
64 time type as well. */
@@ -147,7 +147,7 @@ do_test_large_buffer (bool mc)
static void
do_test_small_buffer (bool mc)
{
- struct mmsghdr mmhdr = { 0 };
+ struct mmsghdr mmhdr = { { 0 } };
/* Enable 32 bit timeval precision and check if no 64 bit timeval stamp
is created. */
diff --git a/time/tst-itimer.c b/time/tst-itimer.c
index e7186e6200..3937deecc8 100644
--- a/time/tst-itimer.c
+++ b/time/tst-itimer.c
@@ -62,7 +62,8 @@ do_test (void)
it.it_interval.tv_usec = 20;
TEST_COMPARE (setitimer (timers[i], &it, NULL), 0);
- TEST_COMPARE (setitimer (timers[i], &(struct itimerval) { 0 }, &it_old),
+ TEST_COMPARE (setitimer (timers[i], &(struct itimerval) { { 0 } },
+ &it_old),
0);
/* ITIMER_REAL returns { 0, 0 } for single-shot timers, while
other timers returns setitimer value. */
@@ -87,7 +88,8 @@ do_test (void)
it.it_value.tv_usec = 40;
TEST_COMPARE (setitimer (timers[i], &it, NULL), 0);
- TEST_COMPARE (setitimer (timers[i], &(struct itimerval) { 0 }, &it_old),
+ TEST_COMPARE (setitimer (timers[i], &(struct itimerval) { { 0 } },
+ &it_old),
0);
TEST_COMPARE (it.it_interval.tv_sec, it_old.it_interval.tv_sec);
if (timers[i] == ITIMER_REAL)
@@ -107,7 +109,7 @@ do_test (void)
if (support_itimer_support_time64())
{
TEST_COMPARE (setitimer (timers[i], &it, NULL), 0);
- TEST_COMPARE (setitimer (timers[i], &(struct itimerval) { 0 },
+ TEST_COMPARE (setitimer (timers[i], &(struct itimerval) { { 0 } },
&it_old),
0);
/* ITIMER_REAL returns { 0, 0 } for single-sort timers, while other
@@ -134,7 +136,7 @@ do_test (void)
{
TEST_COMPARE (setitimer (timers[i], &it, NULL), 0);
- TEST_COMPARE (setitimer (timers[i], &(struct itimerval) { 0 },
+ TEST_COMPARE (setitimer (timers[i], &(struct itimerval) { { 0 } },
&it_old),
0);
if (timers[i] == ITIMER_REAL)
@@ -169,7 +171,8 @@ do_test (void)
TEST_COMPARE (setitimer (ITIMER_REAL, &it, NULL), 0);
intr_sleep (1);
TEST_COMPARE (cnt, 3);
- TEST_COMPARE (setitimer (ITIMER_REAL, &(struct itimerval) { 0 }, NULL), 0);
+ TEST_COMPARE (setitimer (ITIMER_REAL, &(struct itimerval) { { 0 } },
+ NULL), 0);
return 0;
}
--
2.47.1
More information about the Libc-alpha
mailing list