From 4b83102da60bf26b455ac8425a1f5e338ea01f8a Mon Sep 17 00:00:00 2001 From: Hans Dedecker Date: Mon, 19 Nov 2018 09:59:05 +0100 Subject: [PATCH] treewide: switch to C-code style comments Signed-off-by: Hans Dedecker --- bridge.c | 8 +++++--- interface-ip.c | 32 +++++++++++++++++--------------- interface-ip.h | 2 +- interface.c | 8 ++++---- system-linux.c | 18 +++++++++--------- 5 files changed, 36 insertions(+), 32 deletions(-) diff --git a/bridge.c b/bridge.c index da450a1..c1f4ffa 100644 --- a/bridge.c +++ b/bridge.c @@ -409,9 +409,11 @@ bridge_create_member(struct bridge_state *bst, const char *name, strcpy(bm->name, name); bm->dev.dev = dev; vlist_add(&bst->members, &bm->node, bm->name); - // Need to look up the bridge member again as the above - // created pointer will be freed in case the bridge member - // already existed + /* + * Need to look up the bridge member again as the above + * created pointer will be freed in case the bridge member + * already existed + */ bm = vlist_find(&bst->members, name, bm, node); if (hotplug && bm) bm->node.version = -1; diff --git a/interface-ip.c b/interface-ip.c index 9cea0a6..1a6c28d 100644 --- a/interface-ip.c +++ b/interface-ip.c @@ -170,7 +170,7 @@ __find_ip_addr_target(struct interface_ip_settings *ip, union if_addr *a, bool v if (v6 != ((addr->flags & DEVADDR_FAMILY) == DEVADDR_INET6)) continue; - // Handle offlink addresses correctly + /* Handle offlink addresses correctly */ unsigned int mask = addr->mask; if ((addr->flags & DEVADDR_FAMILY) == DEVADDR_INET6 && (addr->flags & DEVADDR_OFFLINK)) @@ -357,7 +357,7 @@ interface_ip_add_route(struct interface *iface, struct blob_attr *attr, bool v6) route->flags |= DEVROUTE_MTU; } - // Use source-based routing + /* Use source-based routing */ if ((cur = tb[ROUTE_SOURCE]) != NULL) { char *saveptr, *source = alloca(blobmsg_data_len(cur)); memcpy(source, blobmsg_data(cur), blobmsg_data_len(cur)); @@ -393,7 +393,7 @@ interface_ip_add_route(struct interface *iface, struct blob_attr *attr, bool v6) if ((cur = tb[ROUTE_VALID]) != NULL) { int64_t valid = blobmsg_get_u32(cur); int64_t valid_until = valid + (int64_t)system_get_rtime(); - if (valid_until <= LONG_MAX && valid != 0xffffffffLL) // Catch overflow + if (valid_until <= LONG_MAX && valid != 0xffffffffLL) /* Catch overflow */ route->valid_until = valid_until; } @@ -572,10 +572,12 @@ interface_update_proto_addr(struct vlist_tree *tree, if (node_old) { if (a_old->enabled && !keep) { - //This is needed for source routing to work correctly. If a device - //has two connections to a network using the same subnet, adding - //only the network-rule will cause packets to be routed through the - //first matching network (source IP matches both masks). + /* + * This is needed for source routing to work correctly. If a device + * has two connections to a network using the same subnet, adding + * only the network-rule will cause packets to be routed through the + * first matching network (source IP matches both masks) + */ if (a_old->policy_table) interface_add_addr_rules(a_old, false); @@ -908,7 +910,7 @@ static void interface_update_prefix_assignments(struct device_prefix *prefix, bo struct device_prefix_assignment *c; struct interface *iface; - // Delete all assignments + /* Delete all assignments */ while (!list_empty(&prefix->assignments)) { c = list_first_entry(&prefix->assignments, struct device_prefix_assignment, head); @@ -921,7 +923,7 @@ static void interface_update_prefix_assignments(struct device_prefix *prefix, bo if (!setup) return; - // End-of-assignment sentinel + /* End-of-assignment sentinel */ c = malloc(sizeof(*c) + 1); if (!c) return; @@ -932,7 +934,7 @@ static void interface_update_prefix_assignments(struct device_prefix *prefix, bo c->addr = in6addr_any; list_add(&c->head, &prefix->assignments); - // Excluded prefix + /* Excluded prefix */ if (prefix->excl_length > 0) { const char name[] = "!excluded"; c = malloc(sizeof(*c) + sizeof(name)); @@ -959,7 +961,7 @@ static void interface_update_prefix_assignments(struct device_prefix *prefix, bo iface->assignment_length > 64) continue; - // Test whether there is a matching class + /* Test whether there is a matching class */ if (!list_empty(&iface->assignment_classes)) { bool found = false; @@ -987,7 +989,7 @@ static void interface_update_prefix_assignments(struct device_prefix *prefix, bo c->enabled = false; memcpy(c->name, iface->name, namelen); - // First process all custom assignments, put all others in later-list + /* First process all custom assignments, put all others in later-list */ if (c->assigned == -1 || !interface_prefix_assign(&prefix->assignments, c)) { if (c->assigned != -1) { c->assigned = -1; @@ -1077,7 +1079,7 @@ interface_update_prefix(struct vlist_tree *tree, struct interface *iface; if (node_old && node_new) { - // Move assignments and refresh addresses to update valid times + /* Move assignments and refresh addresses to update valid times */ list_splice(&prefix_old->assignments, &prefix_new->assignments); list_for_each_entry(c, &prefix_new->assignments, head) @@ -1088,13 +1090,13 @@ interface_update_prefix(struct vlist_tree *tree, prefix_new->valid_until != prefix_old->valid_until) ip->iface->updated |= IUF_PREFIX; } else if (node_new) { - // Set null-route to avoid routing loops + /* Set null-route to avoid routing loops */ system_add_route(NULL, &route); if (!prefix_new->iface || !prefix_new->iface->proto_ip.no_delegation) interface_update_prefix_assignments(prefix_new, true); } else if (node_old) { - // Remove null-route + /* Remove null-route */ interface_update_prefix_assignments(prefix_old, false); system_del_route(NULL, &route); } diff --git a/interface-ip.h b/interface-ip.h index 5374d93..ec6d7fb 100644 --- a/interface-ip.h +++ b/interface-ip.h @@ -98,7 +98,7 @@ struct device_route { /* must be last */ enum device_addr_flags flags; - int metric; // there can be multiple routes to the same target + int metric; /* there can be multiple routes to the same target */ unsigned int table; unsigned int mask; unsigned int sourcemask; diff --git a/interface.c b/interface.c index 041f0a5..4cefe64 100644 --- a/interface.c +++ b/interface.c @@ -530,8 +530,8 @@ interface_merge_assignment_data(struct interface *old, struct interface *new) struct interface_assignment_class *c; list_for_each_entry(c, &new->assignment_classes, head) { - // Compare list entries one-by-one to see if there was a change - if (list_empty(&old->assignment_classes)) // The new list is longer + /* Compare list entries one-by-one to see if there was a change */ + if (list_empty(&old->assignment_classes)) /* The new list is longer */ changed = true; if (changed) @@ -540,14 +540,14 @@ interface_merge_assignment_data(struct interface *old, struct interface *new) struct interface_assignment_class *c_old = list_first_entry(&old->assignment_classes, struct interface_assignment_class, head); - if (strcmp(c_old->name, c->name)) // An entry didn't match + if (strcmp(c_old->name, c->name)) /* An entry didn't match */ break; list_del(&c_old->head); free(c_old); } - // The old list was longer than the new one or the last entry didn't match + /* The old list was longer than the new one or the last entry didn't match */ if (!list_empty(&old->assignment_classes)) { interface_clear_assignment_classes(old); changed = true; diff --git a/system-linux.c b/system-linux.c index 60f55ee..9694c6f 100644 --- a/system-linux.c +++ b/system-linux.c @@ -105,12 +105,12 @@ handler_nl_event(struct uloop_fd *u, unsigned int events) switch(err) { case ENOBUFS: - // Increase rx buffer size on netlink socket + /* Increase rx buffer size on netlink socket */ ev->bufsize *= 2; if (nl_socket_set_buffer_size(ev->sock, ev->bufsize, 0)) goto abort; - // Request full dump since some info got dropped + /* Request full dump since some info got dropped */ struct rtgenmsg msg = { .rtgen_family = AF_UNSPEC }; nl_send_simple(ev->sock, RTM_GETLINK, NLM_F_DUMP, &msg, sizeof(msg)); break; @@ -167,13 +167,13 @@ create_event_socket(struct event_socket *ev, int protocol, if (!create_raw_event_socket(ev, protocol, 0, handler_nl_event, ULOOP_ERROR_CB)) return false; - // Install the valid custom callback handler + /* Install the valid custom callback handler */ nl_socket_modify_cb(ev->sock, NL_CB_VALID, NL_CB_CUSTOM, cb, NULL); - // Disable sequence number checking on event sockets + /* Disable sequence number checking on event sockets */ nl_socket_disable_seq_check(ev->sock); - // Increase rx buffer size to 65K on event sockets + /* Increase rx buffer size to 65K on event sockets */ ev->bufsize = 65535; if (nl_socket_set_buffer_size(ev->sock, ev->bufsize, 0)) return false; @@ -241,7 +241,7 @@ int system_init(void) sock_ioctl = socket(AF_LOCAL, SOCK_DGRAM, 0); system_fd_set_cloexec(sock_ioctl); - // Prepare socket for routing / address control + /* Prepare socket for routing / address control */ sock_rtnl = create_socket(NETLINK_ROUTE, 0); if (!sock_rtnl) return -1; @@ -253,7 +253,7 @@ int system_init(void) handle_hotplug_event, 0)) return -1; - // Receive network link events form kernel + /* Receive network link events form kernel */ nl_socket_add_membership(rtnl_event.sock, RTNLGRP_LINK); return 0; @@ -518,7 +518,7 @@ static int system_get_sendredirects(struct device *dev, char *buf, const size_t dev->ifname, buf, buf_sz); } -// Evaluate netlink messages +/* Evaluate netlink messages */ static int cb_rtnl_event(struct nl_msg *msg, void *arg) { struct nlmsghdr *nh = nlmsg_hdr(msg); @@ -1899,7 +1899,7 @@ static int system_rt(struct device *dev, struct device_route *route, int cmd) if (cmd == RTM_NEWROUTE) { flags |= NLM_F_CREATE | NLM_F_REPLACE; - if (!dev) { // Add null-route + if (!dev) { /* Add null-route */ rtm.rtm_scope = RT_SCOPE_UNIVERSE; rtm.rtm_type = RTN_UNREACHABLE; } -- 2.25.1