more of -Wall fixes from Cristian Ionescu-Idbohrn.

Some are fixing real bugs.

function                                             old     new   delta
syslogd_main                                         938     958     +20
get_signum                                           136     143      +7
obj_load                                             777     782      +5
recv_from_to                                         210     214      +4
get_next_block                                      1795    1799      +4
display_topmem_process_list                         1117    1121      +4
logread_main                                         484     487      +3
buffer_fill_and_print                                 73      76      +3
kill_main                                            687     689      +2
ll_remember_index                                    240     241      +1
do_stats                                             452     453      +1
if_readconf                                          166     165      -1
display_process_list                                1192    1191      -1
run_applet_and_exit                                  507     505      -2
print_signames                                        33      31      -2
parse_one_line                                      1092    1090      -2
find_out_spec                                         57      55      -2
add_ksymoops_symbols                                 421     419      -2
ash_main                                            1407    1402      -5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 11/8 up/down: 54/-17)            Total: 37 bytes
This commit is contained in:
Denis Vlasenko
2008-05-15 21:30:45 +00:00
parent 43d5d429fd
commit 6b06cb80be
43 changed files with 113 additions and 110 deletions

View File

@@ -174,7 +174,7 @@ static bool recv_pack(unsigned char *buf, int len, struct sockaddr_ll *FROM)
if (ah->ar_pro != htons(ETH_P_IP)
|| (ah->ar_pln != 4)
|| (ah->ar_hln != me.sll_halen)
|| (len < sizeof(*ah) + 2 * (4 + ah->ar_hln)))
|| (len < (int)(sizeof(*ah) + 2 * (4 + ah->ar_hln))))
return false;
memcpy(&src_ip, p + ah->ar_hln, 4);

View File

@@ -600,7 +600,7 @@ static void parse_conf(const char *path, int flag)
#if ENABLE_FEATURE_HTTPD_ERROR_PAGES
if (flag == FIRST_PARSE && *p0 == 'E') {
int i;
unsigned i;
/* error status code */
int status = atoi(++p0);
/* c already points at the character following ':' in parse loop */

View File

@@ -604,7 +604,7 @@ static int set_if_addr(char *master_ifname, char *slave_ifname)
struct ifreq ifr;
int res;
int i;
unsigned i;
for (i = 0; i < ARRAY_SIZE(ifra); i++) {
strncpy_IFNAMSIZ(ifr.ifr_name, master_ifname);

View File

@@ -486,7 +486,7 @@ static const struct dhcp_client_t ext_dhcp_clients[] = {
#if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP
static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
{
int i;
unsigned i;
#if ENABLE_FEATURE_IFUPDOWN_IP
/* ip doesn't up iface when it configures it (unlike ifconfig) */
if (!execute("ip link set %iface% up", ifd, exec))
@@ -522,7 +522,7 @@ static int dhcp_up(struct interface_defn_t *ifd ATTRIBUTE_UNUSED,
#if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP
static int dhcp_down(struct interface_defn_t *ifd, execfn *exec)
{
int i;
unsigned i;
for (i = 0; i < ARRAY_SIZE(ext_dhcp_clients); i++) {
if (exists_execable(ext_dhcp_clients[i].name))
return execute(ext_dhcp_clients[i].stopcmd, ifd, exec);
@@ -1154,7 +1154,7 @@ int ifupdown_main(int argc, char **argv)
char *liface;
char *pch;
bool okay = 0;
unsigned cmds_ret;
int cmds_ret;
iface = xstrdup(target_list->data);
target_list = target_list->link;

View File

@@ -750,7 +750,7 @@ static NOINLINE servtab_t *parse_one_line(void)
if (*p == '-') {
p++;
n = bb_strtou(p, &p, 10);
if (n > INT_MAX || n < sep->se_rpcver_lo)
if (n > INT_MAX || (int)n < sep->se_rpcver_lo)
goto bad_ver_spec;
sep->se_rpcver_hi = n;
}
@@ -812,7 +812,7 @@ static NOINLINE servtab_t *parse_one_line(void)
&& (sep->se_socktype == SOCK_STREAM
|| sep->se_socktype == SOCK_DGRAM)
) {
int i;
unsigned i;
for (i = 0; i < ARRAY_SIZE(builtins); i++)
if (strncmp(builtins[i].bi_service7, sep->se_service, 7) == 0)
goto found_bi;

View File

@@ -525,7 +525,7 @@ static int if_readconf(void)
if (ioctl_or_warn(skfd, SIOCGIFCONF, &ifc) < 0) {
goto out;
}
if (ifc.ifc_len == sizeof(struct ifreq) * numreqs) {
if (ifc.ifc_len == (int)(sizeof(struct ifreq) * numreqs)) {
/* assume it overflowed and try again */
numreqs += 10;
continue;
@@ -862,7 +862,7 @@ const struct hwtype *get_hwntype(int type)
/* return 1 if address is all zeros */
static int hw_null_address(const struct hwtype *hw, void *ap)
{
unsigned int i;
int i;
unsigned char *address = (unsigned char *) ap;
for (i = 0; i < hw->alen; i++)

View File

@@ -61,7 +61,7 @@ static int do_rd(int fd, void **paramp)
p = strpbrk(cur, "\r\n");
if (p)
*p = '\0';
if (!p && sz && buf->pos <= sizeof(buf->buf))
if (!p && sz && buf->pos <= (int)sizeof(buf->buf))
goto ok;
/* Terminate session. If we are in server mode, then
* fd is still in nonblocking mode - we never block here */

View File

@@ -265,7 +265,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n,
if (msg.msg_namelen != sizeof(nladdr)) {
bb_error_msg_and_die("sender address length == %d", msg.msg_namelen);
}
for (h = (struct nlmsghdr*)buf; status >= sizeof(*h); ) {
for (h = (struct nlmsghdr*)buf; status >= (int)sizeof(*h); ) {
// int l_err;
int len = h->nlmsg_len;
int l = len - sizeof(*h);
@@ -293,7 +293,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n,
if (h->nlmsg_type == NLMSG_ERROR) {
struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h);
if (l < sizeof(struct nlmsgerr)) {
if (l < (int)sizeof(struct nlmsgerr)) {
bb_error_msg("ERROR truncated");
} else {
errno = - err->error;
@@ -336,7 +336,7 @@ int addattr32(struct nlmsghdr *n, int maxlen, int type, uint32_t data)
{
int len = RTA_LENGTH(4);
struct rtattr *rta;
if (NLMSG_ALIGN(n->nlmsg_len) + len > maxlen)
if ((int)(NLMSG_ALIGN(n->nlmsg_len) + len) > maxlen)
return -1;
rta = (struct rtattr*)(((char*)n) + NLMSG_ALIGN(n->nlmsg_len));
rta->rta_type = type;
@@ -351,7 +351,7 @@ int addattr_l(struct nlmsghdr *n, int maxlen, int type, void *data, int alen)
int len = RTA_LENGTH(alen);
struct rtattr *rta;
if (NLMSG_ALIGN(n->nlmsg_len) + len > maxlen)
if ((int)(NLMSG_ALIGN(n->nlmsg_len) + len) > maxlen)
return -1;
rta = (struct rtattr*)(((char*)n) + NLMSG_ALIGN(n->nlmsg_len));
rta->rta_type = type;

View File

@@ -75,7 +75,7 @@ int ll_remember_index(struct sockaddr_nl *who ATTRIBUTE_UNUSED,
if (tb[IFLA_ADDRESS]) {
int alen;
im->alen = alen = RTA_PAYLOAD(tb[IFLA_ADDRESS]);
if (alen > sizeof(im->addr))
if (alen > (int)sizeof(im->addr))
alen = sizeof(im->addr);
memcpy(im->addr, RTA_DATA(tb[IFLA_ADDRESS]), alen);
} else {

View File

@@ -98,10 +98,8 @@ __PF(ECONET,econet)
const char *ll_proto_n2a(unsigned short id, char *buf, int len)
{
int i;
unsigned i;
id = ntohs(id);
for (i = 0; i < ARRAY_SIZE(llproto_names); i++) {
if (llproto_names[i].id == id)
return llproto_names[i].name;
@@ -112,7 +110,7 @@ const char *ll_proto_n2a(unsigned short id, char *buf, int len)
int ll_proto_a2n(unsigned short *id, char *buf)
{
int i;
unsigned i;
for (i = 0; i < ARRAY_SIZE(llproto_names); i++) {
if (strcasecmp(llproto_names[i].name, buf) == 0) {
*id = htons(llproto_names[i].id);

View File

@@ -187,7 +187,7 @@ const char *ll_type_n2a(int type, char *buf, int len)
#endif /* FEATURE_IP_RARE_PROTOCOLS */
};
int i;
unsigned i;
const char *aname = arphrd_name;
for (i = 0; i < ARRAY_SIZE(arphrd_type); i++) {
if (arphrd_type[i] == type)

View File

@@ -187,7 +187,7 @@ static int smtp_checkp(const char *fmt, const char *param, int code)
bb_error_msg_and_die("%s failed", msg);
}
static int inline smtp_check(const char *fmt, int code)
static inline int smtp_check(const char *fmt, int code)
{
return smtp_checkp(fmt, NULL, code);
}
@@ -224,7 +224,7 @@ static void pop3_checkr(const char *fmt, const char *param, char **ret)
bb_error_msg_and_die("%s failed", msg);
}
static void inline pop3_check(const char *fmt, const char *param)
static inline void pop3_check(const char *fmt, const char *param)
{
pop3_checkr(fmt, param, NULL);
}

View File

@@ -413,7 +413,7 @@ ifaddrlist(struct IFADDRLIST **ipaddrp)
ifc.ifc_buf = (caddr_t)ibuf;
if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) < 0
|| ifc.ifc_len < sizeof(struct ifreq)
|| ifc.ifc_len < (int)sizeof(struct ifreq)
) {
if (errno == EINVAL)
bb_error_msg_and_die(

View File

@@ -319,7 +319,7 @@ void read_config(const char *file)
{
FILE *in;
char buffer[READ_CONFIG_BUF_SIZE], *token, *line;
int i, lineno;
unsigned i, lineno;
for (i = 0; i < KWS_WITH_DEFAULTS; i++)
keywords[i].handler(keywords[i].def, keywords[i].var);
@@ -344,7 +344,7 @@ void read_config(const char *file)
for (i = 0; i < ARRAY_SIZE(keywords); i++) {
if (!strcasecmp(token, keywords[i].keyword)) {
if (!keywords[i].handler(line, keywords[i].var)) {
bb_error_msg("can't parse line %d in %s at '%s'",
bb_error_msg("can't parse line %u in %s at '%s'",
lineno, file, line);
/* reset back to the default value */
keywords[i].handler(keywords[i].def, keywords[i].var);

View File

@@ -162,7 +162,7 @@ static int run(char *argv[3], struct in_addr *ip)
/**
* Return milliseconds of random delay, up to "secs" seconds.
*/
static unsigned ALWAYS_INLINE random_delay_ms(unsigned secs)
static ALWAYS_INLINE unsigned random_delay_ms(unsigned secs)
{
return rand() % (secs * 1000);
}