From: Petr Štetiar Date: Wed, 29 Mar 2023 07:45:04 +0000 (+0200) Subject: treewide: fix multiple compiler warnings X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=1fe1d4f5e8c2e235a1ab4e0df8baa734142fe994;p=project%2Fnetifd.git treewide: fix multiple compiler warnings Fixes bunch of clang-15/gcc-10 compiler warnings, mostly related to blobmsg_for_each_attr() usage: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare] error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] error: format string is not a string literal [-Werror,-Wformat-nonliteral] Signed-off-by: Petr Štetiar --- diff --git a/bonding.c b/bonding.c index f4005de..402c71c 100644 --- a/bonding.c +++ b/bonding.c @@ -353,7 +353,7 @@ bonding_config_init(struct device *dev) { struct bonding_device *bdev; struct blob_attr *cur; - int rem; + size_t rem; bdev = container_of(dev, struct bonding_device, dev); diff --git a/bridge.c b/bridge.c index 02fd392..6306bec 100644 --- a/bridge.c +++ b/bridge.c @@ -782,7 +782,7 @@ bridge_hotplug_set_member_vlans(struct bridge_state *bst, struct blob_attr *vlan { struct bridge_vlan *vlan; struct blob_attr *cur; - int rem; + size_t rem; if (!vlans) return; @@ -1004,7 +1004,8 @@ bridge_config_init(struct device *dev) struct bridge_state *bst; struct bridge_vlan *vlan; struct blob_attr *cur; - int i, rem; + size_t rem; + int i; bst = container_of(dev, struct bridge_state, dev); diff --git a/config.c b/config.c index 9bbda39..e1c01e1 100644 --- a/config.c +++ b/config.c @@ -337,7 +337,7 @@ config_parse_vlan(struct device *dev, struct uci_section *s) char *name_buf; int name_len = 0; int n_ports = 0; - int rem; + size_t rem; val = uci_lookup_option_string(uci_ctx, s, "vlan"); if (!val) diff --git a/extdev.c b/extdev.c index 5c5e769..8d06228 100644 --- a/extdev.c +++ b/extdev.c @@ -754,7 +754,7 @@ static void __buf_add_all(struct blob_attr *attr) { struct blob_attr *cur; - int rem; + size_t rem; blobmsg_for_each_attr(cur, attr, rem) blobmsg_add_field(&b, blobmsg_type(cur), blobmsg_name(cur), blobmsg_data(cur), @@ -1055,7 +1055,8 @@ error: static void __bridge_config_init(struct extdev_bridge *ebr) { - int rem, ret; + int ret; + size_t rem; struct blob_attr *cur; if (ebr->empty) { @@ -1100,7 +1101,7 @@ extdev_config_init(struct device *dev) } static void -extdev_buf_add_list(struct blob_attr *attr, int len, const char *name, +extdev_buf_add_list(struct blob_attr *attr, size_t len, const char *name, struct blob_buf *buf, bool array) { struct blob_attr *cur; diff --git a/interface-ip.c b/interface-ip.c index 7359db2..a06a514 100644 --- a/interface-ip.c +++ b/interface-ip.c @@ -1429,7 +1429,7 @@ void interface_add_dns_server_list(struct interface_ip_settings *ip, struct blob_attr *list) { struct blob_attr *cur; - int rem; + size_t rem; blobmsg_for_each_attr(cur, list, rem) { if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING) @@ -1461,7 +1461,7 @@ void interface_add_dns_search_list(struct interface_ip_settings *ip, struct blob_attr *list) { struct blob_attr *cur; - int rem; + size_t rem; blobmsg_for_each_attr(cur, list, rem) { if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING) diff --git a/interface.c b/interface.c index 89654f9..66e0e80 100644 --- a/interface.c +++ b/interface.c @@ -232,7 +232,8 @@ interface_add_data(struct interface *iface, const struct blob_attr *data) int interface_parse_data(struct interface *iface, const struct blob_attr *attr) { struct blob_attr *cur; - int rem, ret; + size_t rem; + int ret; iface->updated = 0; @@ -517,7 +518,7 @@ static void interface_add_assignment_classes(struct interface *iface, struct blob_attr *list) { struct blob_attr *cur; - int rem; + size_t rem; blobmsg_for_each_attr(cur, list, rem) { if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING) diff --git a/main.c b/main.c index e5260b5..ec7b1be 100644 --- a/main.c +++ b/main.c @@ -64,6 +64,7 @@ netifd_delete_process(struct netifd_process *proc) } void +__attribute__((format(printf, 2, 0))) netifd_log_message(int priority, const char *format, ...) { va_list vl; diff --git a/proto-shell.c b/proto-shell.c index 9cdbc7f..bc3c41d 100644 --- a/proto-shell.c +++ b/proto-shell.c @@ -401,7 +401,7 @@ proto_shell_parse_route_list(struct interface *iface, struct blob_attr *attr, bool v6) { struct blob_attr *cur; - int rem; + size_t rem; blobmsg_for_each_attr(cur, attr, rem) { if (blobmsg_type(cur) != BLOBMSG_TYPE_TABLE) { @@ -418,7 +418,7 @@ proto_shell_parse_neighbor_list(struct interface *iface, struct blob_attr *attr, bool v6) { struct blob_attr *cur; - int rem; + size_t rem; blobmsg_for_each_attr(cur, attr, rem) { if (blobmsg_type(cur) != BLOBMSG_TYPE_TABLE) { @@ -434,7 +434,7 @@ static void proto_shell_parse_data(struct interface *iface, struct blob_attr *attr) { struct blob_attr *cur; - int rem; + size_t rem; blobmsg_for_each_attr(cur, attr, rem) interface_add_data(iface, cur); @@ -597,7 +597,7 @@ fill_string_list(struct blob_attr *attr, char **argv, int max) { struct blob_attr *cur; int argc = 0; - int rem; + size_t rem; if (!attr) goto out; @@ -671,7 +671,7 @@ proto_shell_notify_error(struct proto_shell_state *state, struct blob_attr **tb) struct blob_attr *cur; char *data[16]; int n_data = 0; - int rem; + size_t rem; if (!tb[NOTIFY_ERROR]) return UBUS_STATUS_INVALID_ARGUMENT; diff --git a/proto.c b/proto.c index 48dd213..63f461d 100644 --- a/proto.c +++ b/proto.c @@ -160,7 +160,7 @@ parse_static_address_option(struct interface *iface, struct blob_attr *attr, struct device_addr *addr; const char *str; int n_addr = 0; - int rem; + size_t rem; blobmsg_for_each_attr(cur, attr, rem) { if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING) @@ -266,7 +266,7 @@ parse_address_list(struct interface *iface, struct blob_attr *attr, bool v6, struct device_addr *addr; struct blob_attr *cur; int n_addr = 0; - int rem; + size_t rem; blobmsg_for_each_attr(cur, attr, rem) { addr = parse_address_item(cur, v6, ext); @@ -392,7 +392,7 @@ parse_prefix_list(struct interface *iface, struct blob_attr *attr) { struct blob_attr *cur; int n_addr = 0; - int rem; + size_t rem; blobmsg_for_each_attr(cur, attr, rem) { if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING) diff --git a/system-linux.c b/system-linux.c index e4041fb..432581e 100644 --- a/system-linux.c +++ b/system-linux.c @@ -1036,7 +1036,7 @@ int system_bonding_set_device(struct device *dev, struct bonding_config *cfg) struct blob_attr *cur; char op = cfg ? '+' : '-'; char buf[64]; - int rem; + size_t rem; snprintf(dev_buf, sizeof(dev_buf), "%s/class/net/bonding_masters", sysfs_path); snprintf(buf, sizeof(buf), "%c%s", op, ifname); diff --git a/ubus.c b/ubus.c index 4d05786..3504a49 100644 --- a/ubus.c +++ b/ubus.c @@ -272,7 +272,7 @@ netifd_handle_alias(struct ubus_context *ctx, struct ubus_object *obj, struct device *dev = NULL; struct blob_attr *tb[__ALIAS_ATTR_MAX]; struct blob_attr *cur; - int rem; + size_t rem; blobmsg_parse(alias_attrs, __ALIAS_ATTR_MAX, tb, blob_data(msg), blob_len(msg)); diff --git a/vlandev.c b/vlandev.c index d93d2b3..ad4c526 100644 --- a/vlandev.c +++ b/vlandev.c @@ -288,7 +288,8 @@ static void vlandev_qos_mapping_list_apply(struct vlist_simple_tree *qos_mapping { struct blob_attr *cur; struct vlan_qos_mapping *qos_mapping; - int rem, rc; + size_t rem; + int rc; blobmsg_for_each_attr(cur, list, rem) { if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING) diff --git a/wireless.c b/wireless.c index 1f54bfb..1b203b6 100644 --- a/wireless.c +++ b/wireless.c @@ -141,7 +141,7 @@ vif_config_add_bridge(struct blob_buf *buf, struct blob_attr *networks, bool pre struct device *dev = NULL, *orig_dev; struct blob_attr *cur; const char *network; - int rem; + size_t rem; if (!networks) return; @@ -335,7 +335,7 @@ static void wireless_interface_handle_link(struct wireless_interface *vif, const struct interface *iface; struct blob_attr *cur; const char *network; - int rem; + size_t rem; if (!vif->network || !vif->ifname) return; @@ -372,7 +372,7 @@ static void wireless_vlan_handle_link(struct wireless_vlan *vlan, bool up) struct interface *iface; struct blob_attr *cur; const char *network; - int rem; + size_t rem; if (!vlan->network || !vlan->ifname) return;