Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/networking/libiproute/utils.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/networking/libiproute/utils.c
r3232 r3621 14 14 #include "inet_common.h" 15 15 16 unsigned get_hz(void) 17 { 18 static unsigned hz_internal; 19 FILE *fp; 20 21 if (hz_internal) 22 return hz_internal; 23 24 fp = fopen_for_read("/proc/net/psched"); 25 if (fp) { 26 unsigned nom, denom; 27 28 if (fscanf(fp, "%*08x%*08x%08x%08x", &nom, &denom) == 2) 29 if (nom == 1000000) 30 hz_internal = denom; 31 fclose(fp); 32 } 33 if (!hz_internal) 34 hz_internal = bb_clk_tck(); 35 return hz_internal; 36 } 37 16 38 unsigned get_unsigned(char *arg, const char *errmsg) 17 39 { … … 26 48 } 27 49 } 28 invarg (arg, errmsg); /* does not return */50 invarg_1_to_2(arg, errmsg); /* does not return */ 29 51 } 30 52 … … 41 63 } 42 64 } 43 invarg (arg, errmsg); /* does not return */65 invarg_1_to_2(arg, errmsg); /* does not return */ 44 66 } 45 67 … … 56 78 } 57 79 } 58 invarg (arg, errmsg); /* does not return */80 invarg_1_to_2(arg, errmsg); /* does not return */ 59 81 } 60 82 … … 209 231 void incomplete_command(void) 210 232 { 211 bb_error_msg_and_die("command line is not complete, try option\"help\"");212 } 213 214 void invarg (const char *arg, const char *opt)215 { 216 bb_error_msg_and_die(bb_msg_invalid_arg , arg, opt);233 bb_error_msg_and_die("command line is not complete, try \"help\""); 234 } 235 236 void invarg_1_to_2(const char *arg, const char *opt) 237 { 238 bb_error_msg_and_die(bb_msg_invalid_arg_to, arg, opt); 217 239 } 218 240 … … 255 277 } 256 278 257 const char *rt_addr_n2a(int af, 258 void *addr, char *buf, int buflen) 279 const char *rt_addr_n2a(int af, void *addr) 259 280 { 260 281 switch (af) { 261 282 case AF_INET: 262 283 case AF_INET6: 263 return inet_ntop(af, addr, buf, buflen); 284 return inet_ntop(af, addr, 285 auto_string(xzalloc(INET6_ADDRSTRLEN)), INET6_ADDRSTRLEN 286 ); 264 287 default: 265 288 return "???"; … … 268 291 269 292 #ifdef RESOLVE_HOSTNAMES 270 const char *format_host(int af, int len, void *addr , char *buf, int buflen)293 const char *format_host(int af, int len, void *addr) 271 294 { 272 295 if (resolve_hosts) { … … 287 310 h_ent = gethostbyaddr(addr, len, af); 288 311 if (h_ent != NULL) { 289 safe_strncpy(buf, h_ent->h_name, buflen); 290 return buf; 291 } 292 } 293 } 294 return rt_addr_n2a(af, addr, buf, buflen); 312 return auto_string(xstrdup(h_ent->h_name)); 313 } 314 } 315 } 316 return rt_addr_n2a(af, addr); 295 317 } 296 318 #endif
Note:
See TracChangeset
for help on using the changeset viewer.