Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/networking/libiproute/utils.c

    r3232 r3621  
    1414#include "inet_common.h"
    1515
     16unsigned 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
    1638unsigned get_unsigned(char *arg, const char *errmsg)
    1739{
     
    2648        }
    2749    }
    28     invarg(arg, errmsg); /* does not return */
     50    invarg_1_to_2(arg, errmsg); /* does not return */
    2951}
    3052
     
    4163        }
    4264    }
    43     invarg(arg, errmsg); /* does not return */
     65    invarg_1_to_2(arg, errmsg); /* does not return */
    4466}
    4567
     
    5678        }
    5779    }
    58     invarg(arg, errmsg); /* does not return */
     80    invarg_1_to_2(arg, errmsg); /* does not return */
    5981}
    6082
     
    209231void incomplete_command(void)
    210232{
    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
     236void invarg_1_to_2(const char *arg, const char *opt)
     237{
     238    bb_error_msg_and_die(bb_msg_invalid_arg_to, arg, opt);
    217239}
    218240
     
    255277}
    256278
    257 const char *rt_addr_n2a(int af,
    258         void *addr, char *buf, int buflen)
     279const char *rt_addr_n2a(int af, void *addr)
    259280{
    260281    switch (af) {
    261282    case AF_INET:
    262283    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        );
    264287    default:
    265288        return "???";
     
    268291
    269292#ifdef RESOLVE_HOSTNAMES
    270 const char *format_host(int af, int len, void *addr, char *buf, int buflen)
     293const char *format_host(int af, int len, void *addr)
    271294{
    272295    if (resolve_hosts) {
     
    287310            h_ent = gethostbyaddr(addr, len, af);
    288311            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);
    295317}
    296318#endif
Note: See TracChangeset for help on using the changeset viewer.