From da968eee8fb96168ad16d7ccaa5cd7a489295e0c Mon Sep 17 00:00:00 2001 From: Grische <2787581+grische@users.noreply.github.com> Date: Thu, 26 Jun 2025 18:56:20 +0200 Subject: [PATCH 1/2] editorconfig: trim trailing whitespaces --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 2e6feec..a1f5df5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,4 +4,4 @@ root = true end_of_line = lf insert_final_newline = true indent_style = tab - +trim_trailing_whitespace = true From d437b8ccd10a70bc3d4a20b020af22d682d69592 Mon Sep 17 00:00:00 2001 From: Grische <2787581+grische@users.noreply.github.com> Date: Thu, 26 Jun 2025 19:02:59 +0200 Subject: [PATCH 2/2] treewide: trim trailing whitespaces --- src/Makefile | 4 ++-- src/batadv.c | 5 ++--- src/daemon.c | 10 +++++----- src/information.c | 10 +++++----- src/interface.c | 2 +- src/monitor.c | 12 ++++++------ src/ubus.c | 4 ++-- 7 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/Makefile b/src/Makefile index 73c0651..3c894fd 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,6 +1,6 @@ CC ?= gcc CFLAGS_common ?= -Wall -Wextra -Werror -std=c99 -g -LDFLAGS_common ?= +LDFLAGS_common ?= PKG_CONFIG ?= pkg-config @@ -35,4 +35,4 @@ all: $(CC) $(CFLAGS) -D_GNU_SOURCE -o node-whisperer daemon.c util.c information.c log.c ubus.c interface.c batadv.c $(LDFLAGS) monitor: - $(CC) $(CFLAGS_MONITOR) -D_GNU_SOURCE -o monitor monitor.c log.c util.c ieee80211.c information.c $(LDFLAGS_MONITOR) + $(CC) $(CFLAGS_MONITOR) -D_GNU_SOURCE -o monitor monitor.c log.c util.c ieee80211.c information.c $(LDFLAGS_MONITOR) diff --git a/src/batadv.c b/src/batadv.c index bcc1a09..cc4b396 100644 --- a/src/batadv.c +++ b/src/batadv.c @@ -69,7 +69,7 @@ static int parse_orig_list_netlink_cb(struct nl_msg *msg, void *arg) if (batadv_genl_missing_attrs(attrs, parse_orig_list_mandatory, BATADV_ARRAY_SIZE(parse_orig_list_mandatory))) return NL_OK; - + hardif = nla_get_u32(attrs[BATADV_ATTR_HARD_IFINDEX]); orig = nla_data(attrs[BATADV_ATTR_ORIG_ADDRESS]); dest = nla_data(attrs[BATADV_ATTR_NEIGH_ADDRESS]); @@ -86,7 +86,6 @@ static int parse_orig_list_netlink_cb(struct nl_msg *msg, void *arg) opts->stats->vpn.tq = nla_get_u8(attrs[BATADV_ATTR_TQ]); opts->stats->vpn.connected = 1; } - return NL_OK; } @@ -169,4 +168,4 @@ int nw_get_batadv_clients() { } return opts.clients; -} \ No newline at end of file +} diff --git a/src/daemon.c b/src/daemon.c index b636150..5689a8b 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -46,9 +46,9 @@ static int nw_daemon_create_vendor_element_buf(struct nw *instance) { instance->output.buf[5] = 0x04; /* Length now matches content. Make sure to update on each new information! */ - + /* Loop through all information-sources */ - for (int i = 0; information_sources[i].name; i++) { + for (int i = 0; information_sources[i].name; i++) { if (!information_sources[i].enabled) { log_debug("Information source id=%d name=%s is disabled", information_sources[i].type, information_sources[i].name); @@ -121,11 +121,11 @@ static void nw_daemon_collect_information(struct uloop_timeout *timeout) { if (nw_daemon_create_vendor_element_buf(instance) < 0) { goto out_free; } - + /* Allocate output buffer */ size_t buf_len = instance->output.len * 2 + 1; uint8_t *buf_hex = malloc(buf_len); - + nw_buffer_to_hexstring(instance->output.buf, instance->output.len, buf_hex); /* Update nodes */ @@ -141,7 +141,7 @@ static void nw_daemon_collect_information(struct uloop_timeout *timeout) { static int start_daemon() { struct nw instance = {}; - + INIT_LIST_HEAD(&instance.enabled_interfaces); uloop_init(); diff --git a/src/information.c b/src/information.c index 91dcc7f..4f8bfa4 100644 --- a/src/information.c +++ b/src/information.c @@ -89,13 +89,13 @@ int node_whisperer_information_batman_adv_collect(uint8_t *buffer, size_t buffer ret = nw_get_batadv_neighbor_stats(&stats); if (ret) return -1; - + ret = nw_get_batadv_clients(); if (ret < 0) { num_clients = 0; } else { num_clients = (uint16_t)ret; - } + } buffer[0] = stats.vpn.connected ? 1 : 0; buffer[1] = stats.vpn.tq; @@ -245,7 +245,7 @@ int node_whisperer_information_hostname_parse(const uint8_t *ie_buf, size_t ie_l return 0; } -int node_whisperer_information_node_id_parse(const uint8_t *ie_buf, size_t ie_len) { +int node_whisperer_information_node_id_parse(const uint8_t *ie_buf, size_t ie_len) { /* We Print Node-ID on top */ return 0; @@ -256,7 +256,7 @@ int node_whisperer_information_batman_adv_parse(const uint8_t *ie_buf, size_t ie if (ie_len < 8) return -1; - + printf("VPN connected: %s\n", ie_buf[0] ? "Yes" : "No"); printf("VPN-TQ: %d\n", ie_buf[1]); tmp = (uint16_t *)&ie_buf[2]; @@ -310,7 +310,7 @@ int node_whisperer_information_domain_parse(const uint8_t *ie_buf, size_t ie_len tmp = malloc(ie_len + 1); if (!tmp) return -1; - + memcpy(tmp, ie_buf, ie_len); tmp[ie_len] = '\0'; diff --git a/src/interface.c b/src/interface.c index 5e8d8dc..cd3975c 100644 --- a/src/interface.c +++ b/src/interface.c @@ -73,7 +73,7 @@ int nw_interface_update(struct ubus_context *ctx, char *vendor_elements) /* Delete element */ blob_buf_init(&b, 0); blobmsg_add_string(&b, "vendor_elements", ""); - + ret = ubus_invoke(ctx, iface->ubus.id, "set_vendor_elements", b.head, NULL, NULL, 1000); if (ret) { log_error("Failed to reset vendor elements for id=%d name=%s code=%d", iface->ubus.id, iface->ubus.name, ret); diff --git a/src/monitor.c b/src/monitor.c index 18e7877..4f6dc73 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -196,7 +196,7 @@ int nl_get_multicast_id(struct nl80211_sock *sock, const char *family, const cha ret = -ENOMEM; goto nla_put_failure; } - + cb = nl_cb_alloc(NL_CB_DEFAULT); if (!cb) { log_error("Failed to allocate callback message."); @@ -224,7 +224,7 @@ int nl_get_multicast_id(struct nl80211_sock *sock, const char *family, const cha nl_recvmsgs(sock->nls, cb); if (ret == 0) { - ret = grp.id; + ret = grp.id; } log_debug("Received multicast group ID: %d", ret); @@ -281,8 +281,8 @@ int nl80211_trigger_scan(struct nl80211_sock *wifi, int ifindex) genlmsg_put(msg, 0, 0, wifi->nl80211_id, 0, 0, NL80211_CMD_TRIGGER_SCAN, 0); nla_put_nested(msg, NL80211_ATTR_SCAN_SSIDS, scan_ssid); NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex); - - + + err = -ENOENT; nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, callback_trigger, &results); nl_cb_err(cb, NL_CB_CUSTOM, error_handler, &err); @@ -294,7 +294,7 @@ int nl80211_trigger_scan(struct nl80211_sock *wifi, int ifindex) while (err > 0) ret = nl_recvmsgs(wifi->nls, cb); - + if (ret < 0) { log_debug("ERROR: nl_recvmsgs() returned %d (%s).", ret, nl_geterror(-ret)); goto nla_put_failure; @@ -507,7 +507,7 @@ static int callback_dump(struct nl_msg *msg, void *arg) if (!bss[NL80211_BSS_BSSID] || !bss[NL80211_BSS_INFORMATION_ELEMENTS]) return NL_SKIP; - + /* Add Node */ monitor_gluon_node_add(nla_data(bss[NL80211_BSS_BSSID]), nla_data(bss[NL80211_BSS_INFORMATION_ELEMENTS]), nla_len(bss[NL80211_BSS_INFORMATION_ELEMENTS])); diff --git a/src/ubus.c b/src/ubus.c index fa2a414..216eb33 100644 --- a/src/ubus.c +++ b/src/ubus.c @@ -48,13 +48,13 @@ static int nw_ubus_set_interfaces(struct ubus_context *ctx, struct ubus_object * ifname = blobmsg_get_string(cur); if (!ifname) return UBUS_STATUS_INVALID_ARGUMENT; - + log_debug("Add interface %s\n", ifname); iface = calloc(1, sizeof(*iface)); if (!iface) return UBUS_STATUS_UNKNOWN_ERROR; - + iface->name = strdup(ifname); if (!iface->name) { free(iface);