Fix -Wall -Wpedantic warnings

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
This commit is contained in:
Jo-Philipp Wich 2015-05-19 18:54:58 +02:00
parent 5aef442328
commit e8a1e7d224
6 changed files with 23 additions and 36 deletions

View file

@ -121,7 +121,7 @@ struct iwinfo_crypto_entry {
struct iwinfo_scanlist_entry { struct iwinfo_scanlist_entry {
uint8_t mac[6]; uint8_t mac[6];
uint8_t ssid[IWINFO_ESSID_MAX_SIZE+1]; char ssid[IWINFO_ESSID_MAX_SIZE+1];
enum iwinfo_opmode mode; enum iwinfo_opmode mode;
uint8_t channel; uint8_t channel;
uint8_t signal; uint8_t signal;
@ -132,12 +132,12 @@ struct iwinfo_scanlist_entry {
struct iwinfo_country_entry { struct iwinfo_country_entry {
uint16_t iso3166; uint16_t iso3166;
uint8_t ccode[4]; char ccode[4];
}; };
struct iwinfo_iso3166_label { struct iwinfo_iso3166_label {
uint16_t iso3166; uint16_t iso3166;
uint8_t name[28]; char name[28];
}; };
struct iwinfo_hardware_id { struct iwinfo_hardware_id {

View file

@ -903,7 +903,6 @@ int main(int argc, char **argv)
} }
} }
out:
iwinfo_finish(); iwinfo_finish();
return rv; return rv;

View file

@ -597,7 +597,7 @@ static char * iwinfo_L_country_lookup(char *buf, int len, int iso3166)
static int iwinfo_L_countrylist(lua_State *L, int (*func)(const char *, char *, int *)) static int iwinfo_L_countrylist(lua_State *L, int (*func)(const char *, char *, int *))
{ {
int len, i, j; int len, i;
char rv[IWINFO_BUFSIZE], alpha2[3]; char rv[IWINFO_BUFSIZE], alpha2[3];
char *ccode; char *ccode;
const char *ifname = luaL_checkstring(L, 1); const char *ifname = luaL_checkstring(L, 1);
@ -608,7 +608,7 @@ static int iwinfo_L_countrylist(lua_State *L, int (*func)(const char *, char *,
if (!(*func)(ifname, rv, &len)) if (!(*func)(ifname, rv, &len))
{ {
for (l = IWINFO_ISO3166_NAMES, j = 1; l->iso3166; l++) for (l = IWINFO_ISO3166_NAMES, i = 1; l->iso3166; l++)
{ {
if ((ccode = iwinfo_L_country_lookup(rv, len, l->iso3166)) != NULL) if ((ccode = iwinfo_L_country_lookup(rv, len, l->iso3166)) != NULL)
{ {
@ -626,7 +626,7 @@ static int iwinfo_L_countrylist(lua_State *L, int (*func)(const char *, char *,
lua_pushstring(L, l->name); lua_pushstring(L, l->name);
lua_setfield(L, -2, "name"); lua_setfield(L, -2, "name");
lua_rawseti(L, -2, j++); lua_rawseti(L, -2, i++);
} }
} }
} }

View file

@ -216,7 +216,6 @@ static struct nl80211_msg_conveyor * nl80211_new(struct genl_family *family,
return &cv; return &cv;
err: err:
nla_put_failure:
if (cb) if (cb)
nl_cb_put(cb); nl_cb_put(cb);
@ -268,7 +267,7 @@ static int nl80211_phy_idx_from_uci_macaddr(struct uci_section *s)
if (!opt) if (!opt)
return -1; return -1;
snprintf(buf, sizeof(buf), "/sys/class/ieee80211/*", opt); /**/ snprintf(buf, sizeof(buf), "/sys/class/ieee80211/*"); /**/
if (glob(buf, 0, NULL, &gl)) if (glob(buf, 0, NULL, &gl))
return -1; return -1;
@ -566,7 +565,7 @@ static char * nl80211_ifname2phy(const char *ifname)
static char * nl80211_phy2ifname(const char *ifname) static char * nl80211_phy2ifname(const char *ifname)
{ {
int fd, ifidx = -1, cifidx = -1, phyidx = -1; int ifidx = -1, cifidx = -1, phyidx = -1;
char buffer[64]; char buffer[64];
static char nif[IFNAMSIZ] = { 0 }; static char nif[IFNAMSIZ] = { 0 };
@ -892,10 +891,9 @@ static int __nl80211_wpactl_query(const char *ifname, ...)
static char * nl80211_ifadd(const char *ifname) static char * nl80211_ifadd(const char *ifname)
{ {
int phyidx;
char *rv = NULL, path[PATH_MAX]; char *rv = NULL, path[PATH_MAX];
static char nif[IFNAMSIZ] = { 0 }; static char nif[IFNAMSIZ] = { 0 };
struct nl80211_msg_conveyor *req, *res; struct nl80211_msg_conveyor *req;
FILE *sysfs; FILE *sysfs;
req = nl80211_msg(ifname, NL80211_CMD_NEW_INTERFACE, 0); req = nl80211_msg(ifname, NL80211_CMD_NEW_INTERFACE, 0);
@ -984,7 +982,7 @@ static int nl80211_get_ssid_bssid_cb(struct nl_msg *msg, void *arg)
struct nlattr *bss[NL80211_BSS_MAX + 1]; struct nlattr *bss[NL80211_BSS_MAX + 1];
static struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = { static struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = {
[NL80211_BSS_INFORMATION_ELEMENTS] = { }, [NL80211_BSS_INFORMATION_ELEMENTS] = { 0 },
[NL80211_BSS_STATUS] = { .type = NLA_U32 }, [NL80211_BSS_STATUS] = { .type = NLA_U32 },
}; };
@ -1043,7 +1041,7 @@ static int nl80211_get_ssid(const char *ifname, char *buf)
res = nl80211_phy2ifname(ifname); res = nl80211_phy2ifname(ifname);
req = nl80211_msg(res ? res : ifname, NL80211_CMD_GET_SCAN, NLM_F_DUMP); req = nl80211_msg(res ? res : ifname, NL80211_CMD_GET_SCAN, NLM_F_DUMP);
sb.ssid = buf; sb.ssid = (unsigned char *)buf;
*buf = 0; *buf = 0;
if (req) if (req)
@ -1944,15 +1942,15 @@ static int nl80211_get_scanlist_cb(struct nl_msg *msg, void *arg)
static struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = { static struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = {
[NL80211_BSS_TSF] = { .type = NLA_U64 }, [NL80211_BSS_TSF] = { .type = NLA_U64 },
[NL80211_BSS_FREQUENCY] = { .type = NLA_U32 }, [NL80211_BSS_FREQUENCY] = { .type = NLA_U32 },
[NL80211_BSS_BSSID] = { }, [NL80211_BSS_BSSID] = { 0 },
[NL80211_BSS_BEACON_INTERVAL] = { .type = NLA_U16 }, [NL80211_BSS_BEACON_INTERVAL] = { .type = NLA_U16 },
[NL80211_BSS_CAPABILITY] = { .type = NLA_U16 }, [NL80211_BSS_CAPABILITY] = { .type = NLA_U16 },
[NL80211_BSS_INFORMATION_ELEMENTS] = { }, [NL80211_BSS_INFORMATION_ELEMENTS] = { 0 },
[NL80211_BSS_SIGNAL_MBM] = { .type = NLA_U32 }, [NL80211_BSS_SIGNAL_MBM] = { .type = NLA_U32 },
[NL80211_BSS_SIGNAL_UNSPEC] = { .type = NLA_U8 }, [NL80211_BSS_SIGNAL_UNSPEC] = { .type = NLA_U8 },
[NL80211_BSS_STATUS] = { .type = NLA_U32 }, [NL80211_BSS_STATUS] = { .type = NLA_U32 },
[NL80211_BSS_SEEN_MS_AGO] = { .type = NLA_U32 }, [NL80211_BSS_SEEN_MS_AGO] = { .type = NLA_U32 },
[NL80211_BSS_BEACON_IES] = { }, [NL80211_BSS_BEACON_IES] = { 0 },
}; };
if (!tb[NL80211_ATTR_BSS] || if (!tb[NL80211_ATTR_BSS] ||
@ -2073,7 +2071,7 @@ static int wpasupp_ssid_decode(const char *in, char *out, int outlen)
break; break;
case 'e': case 'e':
out[len++] = '\e'; in++; out[len++] = '\033'; in++;
break; break;
case 'x': case 'x':
@ -2333,15 +2331,6 @@ static int nl80211_get_freqlist_cb(struct nl_msg *msg, void *arg)
struct nlattr *freqs[NL80211_FREQUENCY_ATTR_MAX + 1]; struct nlattr *freqs[NL80211_FREQUENCY_ATTR_MAX + 1];
struct nlattr *band, *freq; struct nlattr *band, *freq;
static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = {
[NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 },
[NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG },
[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] = { .type = NLA_FLAG },
[NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG },
[NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG },
[NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 },
};
nla_for_each_nested(band, attr[NL80211_ATTR_WIPHY_BANDS], bands_remain) nla_for_each_nested(band, attr[NL80211_ATTR_WIPHY_BANDS], bands_remain)
{ {
nla_parse(bands, NL80211_BAND_ATTR_MAX, nla_parse(bands, NL80211_BAND_ATTR_MAX,
@ -2426,7 +2415,7 @@ static int nl80211_get_country(const char *ifname, char *buf)
static int nl80211_get_countrylist(const char *ifname, char *buf, int *len) static int nl80211_get_countrylist(const char *ifname, char *buf, int *len)
{ {
int i, count; int count;
struct iwinfo_country_entry *e = (struct iwinfo_country_entry *)buf; struct iwinfo_country_entry *e = (struct iwinfo_country_entry *)buf;
const struct iwinfo_iso3166_label *l; const struct iwinfo_iso3166_label *l;
@ -2531,7 +2520,7 @@ static int nl80211_get_modelist_cb(struct nl_msg *msg, void *arg)
static int nl80211_get_hwmodelist(const char *ifname, int *buf) static int nl80211_get_hwmodelist(const char *ifname, int *buf)
{ {
struct nl80211_msg_conveyor *req; struct nl80211_msg_conveyor *req;
struct nl80211_modes m = { }; struct nl80211_modes m = { 0 };
req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0); req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0);
if (req) if (req)
@ -2552,7 +2541,7 @@ static int nl80211_get_hwmodelist(const char *ifname, int *buf)
static int nl80211_get_htmodelist(const char *ifname, int *buf) static int nl80211_get_htmodelist(const char *ifname, int *buf)
{ {
struct nl80211_msg_conveyor *req; struct nl80211_msg_conveyor *req;
struct nl80211_modes m = { }; struct nl80211_modes m = { 0 };
req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0); req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0);
if (req) if (req)

View file

@ -177,15 +177,16 @@ int iwinfo_hardware_id_from_mtd(struct iwinfo_hardware_id *id)
FILE *mtd; FILE *mtd;
uint16_t *bc; uint16_t *bc;
int fd, len, off; int fd;
unsigned int len, off;
char buf[128]; char buf[128];
if (!(mtd = fopen("/proc/mtd", "r"))) if (!(mtd = fopen("/proc/mtd", "r")))
return -1; return -1;
while (fgets(buf, sizeof(buf), mtd) > 0) while (fgets(buf, sizeof(buf), mtd) != NULL)
{ {
if (fscanf(mtd, "mtd%d: %x %*x %127s", &off, &len, buf) < 3 || if (fscanf(mtd, "mtd%u: %x %*x %127s", &off, &len, buf) < 3 ||
(strcmp(buf, "\"boardconfig\"") && strcmp(buf, "\"EEPROM\"") && (strcmp(buf, "\"boardconfig\"") && strcmp(buf, "\"EEPROM\"") &&
strcmp(buf, "\"factory\""))) strcmp(buf, "\"factory\"")))
{ {
@ -246,7 +247,7 @@ int iwinfo_hardware_id_from_mtd(struct iwinfo_hardware_id *id)
id->subsystem_vendor_id = 0x1814; id->subsystem_vendor_id = 0x1814;
/* device */ /* device */
if (bc[off] & 0xf0 == 0x30) if ((bc[off] & 0xf0) == 0x30)
id->device_id = (bc[off] >> 8) | (bc[off] & 0x00ff) << 8; id->device_id = (bc[off] >> 8) | (bc[off] & 0x00ff) << 8;
else else
id->device_id = bc[off]; id->device_id = bc[off];

View file

@ -32,8 +32,6 @@ static double wext_freq2float(const struct iw_freq *in)
static inline int wext_freq2mhz(const struct iw_freq *in) static inline int wext_freq2mhz(const struct iw_freq *in)
{ {
int i;
if( in->e == 6 ) if( in->e == 6 )
{ {
return in->m; return in->m;