bpf_progs: use unsigned instead of int
This gets rid of a bunch of warnings (enabled by -Wextra)
about signed vs unsigned comparisons.
For the for loops, the compiler really should be smarter...
the so-called 'unsigned' values are *small* compile time
constants like 20 / 2 = 10 or 40 / 2 = 20.
For the 'int len' argument, it's always going to be a positive
value anyway (negative values or zero are meaningless)
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I57fae9add1d2aea7f47ed6a897f1b0f3fb874113
diff --git a/bpf_progs/bpf_net_helpers.h b/bpf_progs/bpf_net_helpers.h
index 1511ee5..ba2f26b 100644
--- a/bpf_progs/bpf_net_helpers.h
+++ b/bpf_progs/bpf_net_helpers.h
@@ -83,7 +83,7 @@
// try to make the first 'len' header bytes readable/writable via direct packet access
// (note: AFAIK there is no way to ask for only direct packet read without also getting write)
-static inline __always_inline void try_make_writable(struct __sk_buff* skb, int len) {
+static inline __always_inline void try_make_writable(struct __sk_buff* skb, unsigned len) {
if (len > skb->len) len = skb->len;
if (skb->data_end - skb->data < len) bpf_skb_pull_data(skb, len);
}