Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1 | From 000629f74908a2a95f6104444c77ad93cf40d62d Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Wed, 13 Jan 2016 08:50:50 +0000 |
| 4 | Subject: [PATCH] Intialize struct elements by name |
| 5 | |
| 6 | makes it portable across glibc and musl |
| 7 | |
| 8 | Fixes errors |
| 9 | |
| 10 | | ping.c: In function 'send_probe': |
| 11 | | ping.c:735:19: warning: initialization makes integer from pointer |
| 12 | without a cast [-Wint-conversion] |
| 13 | | &iov, 1, &cmsg, 0, 0 }; |
| 14 | | ^ |
| 15 | | ping.c:735:19: note: (near initialization for 'm.__pad1') |
| 16 | | ping.c:735:19: error: initializer element is not computable at load |
| 17 | time |
| 18 | | ping.c:735:19: note: (near initialization for 'm.__pad1') |
| 19 | | make: *** [ping.o] Error 1 |
| 20 | |
| 21 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 22 | --- |
| 23 | Upstream-Status: Pending |
| 24 | |
| 25 | ping.c | 11 +++++++++-- |
| 26 | 1 file changed, 9 insertions(+), 2 deletions(-) |
| 27 | |
| 28 | diff --git a/ping.c b/ping.c |
| 29 | index 4989760..e67f381 100644 |
| 30 | --- a/ping.c |
| 31 | +++ b/ping.c |
| 32 | @@ -731,8 +731,15 @@ int send_probe() |
| 33 | |
| 34 | do { |
| 35 | static struct iovec iov = {outpack, 0}; |
| 36 | - static struct msghdr m = { &whereto, sizeof(whereto), |
| 37 | - &iov, 1, &cmsg, 0, 0 }; |
| 38 | + static struct msghdr m = { |
| 39 | + .msg_name = &whereto, |
| 40 | + .msg_namelen = sizeof(whereto), |
| 41 | + .msg_iov = &iov, |
| 42 | + .msg_iovlen = 1, |
| 43 | + .msg_control = &cmsg, |
| 44 | + .msg_controllen = 0, |
| 45 | + .msg_flags= 0, |
| 46 | + }; |
| 47 | m.msg_controllen = cmsg_len; |
| 48 | iov.iov_len = cc; |
| 49 | |
| 50 | -- |
| 51 | 2.7.0 |
| 52 | |