diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-02-04 18:41:18 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-02-04 18:41:18 +0100 |
commit | 12ca080a1ca8dfd0aeac54485451b906a7e61b16 (patch) | |
tree | abb273fb03a73bc9c20d05f9128bdfd9bfe55e55 /networking | |
parent | 98a4c7cf3d799ab953cb77e8b34597c73e3e7335 (diff) | |
download | busybox-w32-12ca080a1ca8dfd0aeac54485451b906a7e61b16.tar.gz busybox-w32-12ca080a1ca8dfd0aeac54485451b906a7e61b16.tar.bz2 busybox-w32-12ca080a1ca8dfd0aeac54485451b906a7e61b16.zip |
*: eliminate more aliasing warnings
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-rw-r--r-- | networking/ipcalc.c | 44 | ||||
-rw-r--r-- | networking/udhcp/arpping.c | 3 |
2 files changed, 23 insertions, 24 deletions
diff --git a/networking/ipcalc.c b/networking/ipcalc.c index 18abc12eb..78558495e 100644 --- a/networking/ipcalc.c +++ b/networking/ipcalc.c | |||
@@ -75,29 +75,34 @@ int get_prefix(unsigned long netmask); | |||
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | int ipcalc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 77 | int ipcalc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
78 | int ipcalc_main(int argc, char **argv) | 78 | int ipcalc_main(int argc UNUSED_PARAM, char **argv) |
79 | { | 79 | { |
80 | unsigned opt; | 80 | unsigned opt; |
81 | int have_netmask = 0; | 81 | bool have_netmask = 0; |
82 | in_addr_t netmask, broadcast, network, ipaddr; | 82 | struct in_addr s_netmask, s_broadcast, s_network, s_ipaddr; |
83 | struct in_addr a; | 83 | /* struct in_addr { in_addr_t s_addr; } and in_addr_t |
84 | * (which in turn is just a typedef to uint32_t) | ||
85 | * are essentially the same type. A few macros for less verbosity: */ | ||
86 | #define netmask (s_netmask.s_addr) | ||
87 | #define broadcast (s_broadcast.s_addr) | ||
88 | #define network (s_network.s_addr) | ||
89 | #define ipaddr (s_ipaddr.s_addr) | ||
84 | char *ipstr; | 90 | char *ipstr; |
85 | 91 | ||
86 | #if ENABLE_FEATURE_IPCALC_LONG_OPTIONS | 92 | #if ENABLE_FEATURE_IPCALC_LONG_OPTIONS |
87 | applet_long_options = ipcalc_longopts; | 93 | applet_long_options = ipcalc_longopts; |
88 | #endif | 94 | #endif |
89 | opt = getopt32(argv, "mbn" IF_FEATURE_IPCALC_FANCY("phs")); | 95 | opt = getopt32(argv, "mbn" IF_FEATURE_IPCALC_FANCY("phs")); |
90 | argc -= optind; | ||
91 | argv += optind; | 96 | argv += optind; |
97 | if (opt & SILENT) | ||
98 | logmode = LOGMODE_NONE; /* suppress error_msg() output */ | ||
92 | if (opt & (BROADCAST | NETWORK | NETPREFIX)) { | 99 | if (opt & (BROADCAST | NETWORK | NETPREFIX)) { |
93 | if (argc > 2 || argc <= 0) | 100 | if (!argv[0] || !argv[1] || argv[2]) |
94 | bb_show_usage(); | 101 | bb_show_usage(); |
95 | } else { | 102 | } else { |
96 | if (argc != 1) | 103 | if (!argv[0] || argv[1]) |
97 | bb_show_usage(); | 104 | bb_show_usage(); |
98 | } | 105 | } |
99 | if (opt & SILENT) | ||
100 | logmode = LOGMODE_NONE; /* Suppress error_msg() output */ | ||
101 | 106 | ||
102 | ipstr = argv[0]; | 107 | ipstr = argv[0]; |
103 | if (ENABLE_FEATURE_IPCALC_FANCY) { | 108 | if (ENABLE_FEATURE_IPCALC_FANCY) { |
@@ -108,8 +113,7 @@ int ipcalc_main(int argc, char **argv) | |||
108 | 113 | ||
109 | while (*prefixstr) { | 114 | while (*prefixstr) { |
110 | if (*prefixstr == '/') { | 115 | if (*prefixstr == '/') { |
111 | *prefixstr = (char)0; | 116 | *prefixstr++ = '\0'; |
112 | prefixstr++; | ||
113 | if (*prefixstr) { | 117 | if (*prefixstr) { |
114 | unsigned msk; | 118 | unsigned msk; |
115 | netprefix = xatoul_range(prefixstr, 0, 32); | 119 | netprefix = xatoul_range(prefixstr, 0, 32); |
@@ -130,42 +134,36 @@ int ipcalc_main(int argc, char **argv) | |||
130 | prefixstr++; | 134 | prefixstr++; |
131 | } | 135 | } |
132 | } | 136 | } |
133 | ipaddr = inet_aton(ipstr, &a); | ||
134 | 137 | ||
135 | if (ipaddr == 0) { | 138 | if (inet_aton(ipstr, &s_ipaddr) == 0) { |
136 | bb_error_msg_and_die("bad IP address: %s", argv[0]); | 139 | bb_error_msg_and_die("bad IP address: %s", argv[0]); |
137 | } | 140 | } |
138 | ipaddr = a.s_addr; | ||
139 | 141 | ||
140 | if (argc == 2) { | 142 | if (argv[1]) { |
141 | if (ENABLE_FEATURE_IPCALC_FANCY && have_netmask) { | 143 | if (ENABLE_FEATURE_IPCALC_FANCY && have_netmask) { |
142 | bb_error_msg_and_die("use prefix or netmask, not both"); | 144 | bb_error_msg_and_die("use prefix or netmask, not both"); |
143 | } | 145 | } |
144 | 146 | if (inet_aton(argv[1], &s_netmask) == 0) { | |
145 | netmask = inet_aton(argv[1], &a); | ||
146 | if (netmask == 0) { | ||
147 | bb_error_msg_and_die("bad netmask: %s", argv[1]); | 147 | bb_error_msg_and_die("bad netmask: %s", argv[1]); |
148 | } | 148 | } |
149 | netmask = a.s_addr; | ||
150 | } else { | 149 | } else { |
151 | |||
152 | /* JHC - If the netmask wasn't provided then calculate it */ | 150 | /* JHC - If the netmask wasn't provided then calculate it */ |
153 | if (!ENABLE_FEATURE_IPCALC_FANCY || !have_netmask) | 151 | if (!ENABLE_FEATURE_IPCALC_FANCY || !have_netmask) |
154 | netmask = get_netmask(ipaddr); | 152 | netmask = get_netmask(ipaddr); |
155 | } | 153 | } |
156 | 154 | ||
157 | if (opt & NETMASK) { | 155 | if (opt & NETMASK) { |
158 | printf("NETMASK=%s\n", inet_ntoa((*(struct in_addr *) &netmask))); | 156 | printf("NETMASK=%s\n", inet_ntoa(s_netmask)); |
159 | } | 157 | } |
160 | 158 | ||
161 | if (opt & BROADCAST) { | 159 | if (opt & BROADCAST) { |
162 | broadcast = (ipaddr & netmask) | ~netmask; | 160 | broadcast = (ipaddr & netmask) | ~netmask; |
163 | printf("BROADCAST=%s\n", inet_ntoa((*(struct in_addr *) &broadcast))); | 161 | printf("BROADCAST=%s\n", inet_ntoa(s_broadcast)); |
164 | } | 162 | } |
165 | 163 | ||
166 | if (opt & NETWORK) { | 164 | if (opt & NETWORK) { |
167 | network = ipaddr & netmask; | 165 | network = ipaddr & netmask; |
168 | printf("NETWORK=%s\n", inet_ntoa((*(struct in_addr *) &network))); | 166 | printf("NETWORK=%s\n", inet_ntoa(s_network)); |
169 | } | 167 | } |
170 | 168 | ||
171 | if (ENABLE_FEATURE_IPCALC_FANCY) { | 169 | if (ENABLE_FEATURE_IPCALC_FANCY) { |
diff --git a/networking/udhcp/arpping.c b/networking/udhcp/arpping.c index 548796e2b..cf18153f7 100644 --- a/networking/udhcp/arpping.c +++ b/networking/udhcp/arpping.c | |||
@@ -87,6 +87,7 @@ int FAST_FUNC arpping(uint32_t test_nip, | |||
87 | /* wait for arp reply, and check it */ | 87 | /* wait for arp reply, and check it */ |
88 | timeout_ms = 2000; | 88 | timeout_ms = 2000; |
89 | do { | 89 | do { |
90 | typedef uint32_t aliased_uint32_t FIX_ALIASING; | ||
90 | int r; | 91 | int r; |
91 | unsigned prevTime = monotonic_ms(); | 92 | unsigned prevTime = monotonic_ms(); |
92 | 93 | ||
@@ -107,7 +108,7 @@ int FAST_FUNC arpping(uint32_t test_nip, | |||
107 | && arp.operation == htons(ARPOP_REPLY) | 108 | && arp.operation == htons(ARPOP_REPLY) |
108 | /* don't check it: Linux doesn't return proper tHaddr (fixed in 2.6.24?) */ | 109 | /* don't check it: Linux doesn't return proper tHaddr (fixed in 2.6.24?) */ |
109 | /* && memcmp(arp.tHaddr, from_mac, 6) == 0 */ | 110 | /* && memcmp(arp.tHaddr, from_mac, 6) == 0 */ |
110 | && *((uint32_t *) arp.sInaddr) == test_nip | 111 | && *(aliased_uint32_t*)arp.sInaddr == test_nip |
111 | ) { | 112 | ) { |
112 | /* if ARP source MAC matches safe_mac | 113 | /* if ARP source MAC matches safe_mac |
113 | * (which is client's MAC), then it's not a conflict | 114 | * (which is client's MAC), then it's not a conflict |