Skip to content

Commit

Permalink
examples: fixed http_filter example
Browse files Browse the repository at this point in the history
Loop unrolling wasn't happening because of variable upper
bound. Making it const fixes the problem.

Tested with 4.13.0-rc6 on fedora 26
  • Loading branch information
pbhole committed Sep 5, 2017
1 parent ac1334f commit ec60e75
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion examples/networking/http_filter/http-parse-complete.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ int http_filter(struct __sk_buff *skb) {
unsigned long p[7];
int i = 0;
int j = 0;
for (i = payload_offset ; i < (payload_offset + 7) ; i++) {
const int last_index = payload_offset + 7;
for (i = payload_offset ; i < last_index ; i++) {
p[j] = load_byte(skb , i);
j++;
}
Expand Down
3 changes: 2 additions & 1 deletion examples/networking/http_filter/http-parse-simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ int http_filter(struct __sk_buff *skb) {
unsigned long p[7];
int i = 0;
int j = 0;
for (i = payload_offset ; i < (payload_offset + 7) ; i++) {
const int last_index = payload_offset + 7;
for (i = payload_offset ; i < last_index ; i++) {
p[j] = load_byte(skb , i);
j++;
}
Expand Down

0 comments on commit ec60e75

Please sign in to comment.