summaryrefslogtreecommitdiffstats
path: root/src/network/bpf
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-09-16 02:19:21 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-09-16 07:36:54 +0200
commit41afafbf2a1b248bee77d6c9e5d73cee63595bb2 (patch)
tree29dc6f88ca6958e33dae30fe0c0869333c6522e1 /src/network/bpf
parentNEWS: fix typo (diff)
downloadsystemd-41afafbf2a1b248bee77d6c9e5d73cee63595bb2.tar.xz
systemd-41afafbf2a1b248bee77d6c9e5d73cee63595bb2.zip
network/sysctl-monitor: fix sanity check in cut_last()
This also adds basic comment about the return code. Follow-up for 6d9ef22acdeac4b429efb75164341233955484af.
Diffstat (limited to 'src/network/bpf')
-rw-r--r--src/network/bpf/sysctl_monitor/sysctl-monitor.bpf.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/network/bpf/sysctl_monitor/sysctl-monitor.bpf.c b/src/network/bpf/sysctl_monitor/sysctl-monitor.bpf.c
index ef154931ce..e0ec8489d2 100644
--- a/src/network/bpf/sysctl_monitor/sysctl-monitor.bpf.c
+++ b/src/network/bpf/sysctl_monitor/sysctl-monitor.bpf.c
@@ -36,23 +36,22 @@ struct str {
static long cut_last(u32 i, struct str *str) {
char *s;
- i = str->l - i - 1;
- s = str->s + i;
-
/* Sanity check for the preverifier */
if (i >= str->l)
- return 1;
+ return 1; /* exit from the loop */
+
+ i = str->l - i - 1;
+ s = str->s + i;
if (*s == 0)
- return 0;
+ return 0; /* continue */
if (*s == '\n' || *s == '\r' || *s == ' ' || *s == '\t') {
*s = 0;
-
- return 0;
+ return 0; /* continue */
}
- return 1;
+ return 1; /* exit from the loop */
}
/* Cut off trailing whitespace and newlines */