This localizes a variable to the function it's used in.
Signed-off-by: Kris Katterjohn <[EMAIL PROTECTED]>
I assume tmp was used for a reason instead of using a variable local to the if()
in load_pointer(), but I can't figure out why. So I wrote this patch changing it
in case it was just a mistake or something left over from something else.
So in other words, can you explain to me why it was done the way it was done? If
not, I think my patch takes care of it.
Also, I tested it my way and everything seems to be working quite well.
Thanks!
--- x/net/core/filter.c 2006-01-06 16:51:51.000000000 -0600
+++ y/net/core/filter.c 2006-01-06 18:17:43.000000000 -0600
@@ -51,12 +51,12 @@ static void *__load_pointer(struct sk_bu
return NULL;
}
-static inline void *load_pointer(struct sk_buff *skb, int k,
- unsigned int size, void *buffer)
+static inline void *load_pointer(struct sk_buff *skb, int k, unsigned int size)
{
- if (k >= 0)
+ if (k >= 0) {
+ u32 *buffer = NULL;
return skb_header_pointer(skb, k, size, buffer);
- else {
+ } else {
if (k >= SKF_AD_OFF)
return NULL;
return __load_pointer(skb, k);
@@ -82,7 +82,6 @@ unsigned int sk_run_filter(struct sk_buf
u32 A = 0; /* Accumulator */
u32 X = 0; /* Index Register */
u32 mem[BPF_MEMWORDS]; /* Scratch Memory Store */
- u32 tmp;
int k;
int pc;
@@ -176,7 +175,7 @@ unsigned int sk_run_filter(struct sk_buf
case BPF_LD|BPF_W|BPF_ABS:
k = fentry->k;
load_w:
- ptr = load_pointer(skb, k, 4, &tmp);
+ ptr = load_pointer(skb, k, 4);
if (ptr != NULL) {
A = ntohl(*(u32 *)ptr);
continue;
@@ -185,7 +184,7 @@ unsigned int sk_run_filter(struct sk_buf
case BPF_LD|BPF_H|BPF_ABS:
k = fentry->k;
load_h:
- ptr = load_pointer(skb, k, 2, &tmp);
+ ptr = load_pointer(skb, k, 2);
if (ptr != NULL) {
A = ntohs(*(u16 *)ptr);
continue;
@@ -194,7 +193,7 @@ unsigned int sk_run_filter(struct sk_buf
case BPF_LD|BPF_B|BPF_ABS:
k = fentry->k;
load_b:
- ptr = load_pointer(skb, k, 1, &tmp);
+ ptr = load_pointer(skb, k, 1);
if (ptr != NULL) {
A = *(u8 *)ptr;
continue;
@@ -216,7 +215,7 @@ load_b:
k = X + fentry->k;
goto load_b;
case BPF_LDX|BPF_B|BPF_MSH:
- ptr = load_pointer(skb, fentry->k, 1, &tmp);
+ ptr = load_pointer(skb, fentry->k, 1);
if (ptr != NULL) {
X = (*(u8 *)ptr & 0xf) << 2;
continue;
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html