[OpenWrt-Devel] [PATCH 1/6] Changes for more readability.

Yousong Zhou yszhou4tech at gmail.com
Tue May 19 08:38:28 EDT 2015


 - "ifname" for Linux interface name.
 - "interface" for netifd defined logical interface names as in
   /etc/config/network.
 - A few comments and variable renames for better readability.

Signed-off-by: Yousong Zhou <yszhou4tech at gmail.com>
---
 device.c      |    4 ++--
 device.h      |    3 +++
 interface.c   |    4 ++--
 interface.h   |    1 +
 proto-shell.c |    8 ++++----
 ubus.c        |    2 +-
 6 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/device.c b/device.c
index dd2823d..feb9460 100644
--- a/device.c
+++ b/device.c
@@ -270,14 +270,14 @@ static void __init dev_init(void)
 static int device_broadcast_cb(void *ctx, struct safe_list *list)
 {
 	struct device_user *dep = container_of(list, struct device_user, list);
-	int *ev = ctx;
+	int ev = *(int *)ctx;
 
 	/* device might have been removed by an earlier callback */
 	if (!dep->dev)
 		return 0;
 
 	if (dep->cb)
-		dep->cb(dep, *ev);
+		dep->cb(dep, ev);
 	return 0;
 }
 
diff --git a/device.h b/device.h
index 3001f10..7f0f9d1 100644
--- a/device.h
+++ b/device.h
@@ -154,8 +154,11 @@ struct device {
 	struct blob_attr *config;
 	bool config_pending;
 	bool sys_present;
+	/* DEV_EVENT_ADD */
 	bool present;
+	/* DEV_EVENT_UP */
 	int active;
+	/* DEV_EVENT_LINK_UP */
 	bool link_active;
 
 	bool external;
diff --git a/interface.c b/interface.c
index ea018ad..5b79ffc 100644
--- a/interface.c
+++ b/interface.c
@@ -635,7 +635,7 @@ interface_handle_config_change(struct interface *iface)
 }
 
 static void
-interface_proto_cb(struct interface_proto_state *state, enum interface_proto_event ev)
+interface_proto_event_cb(struct interface_proto_state *state, enum interface_proto_event ev)
 {
 	struct interface *iface = state->iface;
 
@@ -694,7 +694,7 @@ void interface_set_proto_state(struct interface *iface, struct interface_proto_s
 	if (!state)
 		return;
 
-	state->proto_event = interface_proto_cb;
+	state->proto_event = interface_proto_event_cb;
 	state->iface = iface;
 }
 
diff --git a/interface.h b/interface.h
index 8eeb7db..4776073 100644
--- a/interface.h
+++ b/interface.h
@@ -120,6 +120,7 @@ struct interface {
 
 	struct list_head users;
 
+	/* alias: name of parent interface */
 	const char *parent_ifname;
 	struct interface_user parent_iface;
 
diff --git a/proto-shell.c b/proto-shell.c
index bc4c658..660cb9e 100644
--- a/proto-shell.c
+++ b/proto-shell.c
@@ -51,7 +51,7 @@ struct proto_shell_handler {
 struct proto_shell_dependency {
 	struct list_head list;
 
-	char *interface;
+	char *ifname;
 	struct proto_shell_state *proto;
 	struct interface_user dep;
 
@@ -110,8 +110,8 @@ proto_shell_update_host_dep(struct proto_shell_dependency *dep)
 	if (dep->dep.iface)
 		goto out;
 
-	if (dep->interface[0])
-		iface = vlist_find(&interfaces, dep->interface, iface, node);
+	if (dep->ifname[0])
+		iface = vlist_find(&interfaces, dep->ifname, iface, node);
 
 	iface = interface_ip_add_target_route(&dep->host, dep->v6, iface);
 	if (!iface)
@@ -693,7 +693,7 @@ proto_shell_add_host_dependency(struct proto_shell_state *state, struct blob_att
 	}
 
 	dep->proto = state;
-	dep->interface = strcpy(ifname, ifname_str);
+	dep->ifname = strcpy(ifname, ifname_str);
 
 	dep->dep.cb = proto_shell_if_up_cb;
 	interface_add_user(&dep->dep, NULL);
diff --git a/ubus.c b/ubus.c
index 422b652..c7a329a 100644
--- a/ubus.c
+++ b/ubus.c
@@ -843,7 +843,7 @@ netifd_iface_handle_device(struct ubus_context *ctx, struct ubus_object *obj,
 
 	cur = tb[DEV_LINK_EXT];
 	if (cur)
-		link_ext = !!blobmsg_get_u8(cur);
+		link_ext = blobmsg_get_bool(cur);
 
 	return interface_handle_link(iface, blobmsg_data(tb[DEV_LINK_NAME]), add, link_ext);
 }
-- 
1.7.10.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list