LinuxKPI: skbuff.h: fix -Warray-bounds warnings
Harmonize sk_buff_head and sk_buff further and fix -Warray-bounds warnings reports by gcc. At the same time simplify some code by re-using other functions or factoring some code out. Sponsored by: The FreeBSD Foundation MFC after: 3 days
This commit is contained in:
parent
87f55ab0b4
commit
b2dcb84868
@ -89,8 +89,16 @@ enum sk_buff_pkt_type {
|
|||||||
|
|
||||||
struct sk_buff_head {
|
struct sk_buff_head {
|
||||||
/* XXX TODO */
|
/* XXX TODO */
|
||||||
struct sk_buff *next;
|
union {
|
||||||
struct sk_buff *prev;
|
struct {
|
||||||
|
struct sk_buff *next;
|
||||||
|
struct sk_buff *prev;
|
||||||
|
};
|
||||||
|
struct sk_buff_head_l {
|
||||||
|
struct sk_buff *next;
|
||||||
|
struct sk_buff *prev;
|
||||||
|
} list;
|
||||||
|
};
|
||||||
size_t qlen;
|
size_t qlen;
|
||||||
spinlock_t lock;
|
spinlock_t lock;
|
||||||
};
|
};
|
||||||
@ -527,8 +535,8 @@ __skb_insert(struct sk_buff *new, struct sk_buff *prev, struct sk_buff *next,
|
|||||||
SKB_TRACE_FMT(new, "prev %p next %p q %p", prev, next, q);
|
SKB_TRACE_FMT(new, "prev %p next %p q %p", prev, next, q);
|
||||||
new->prev = prev;
|
new->prev = prev;
|
||||||
new->next = next;
|
new->next = next;
|
||||||
next->prev = new;
|
((struct sk_buff_head_l *)next)->prev = new;
|
||||||
prev->next = new;
|
((struct sk_buff_head_l *)prev)->next = new;
|
||||||
q->qlen++;
|
q->qlen++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,7 +546,7 @@ __skb_queue_after(struct sk_buff_head *q, struct sk_buff *skb,
|
|||||||
{
|
{
|
||||||
|
|
||||||
SKB_TRACE_FMT(q, "skb %p new %p", skb, new);
|
SKB_TRACE_FMT(q, "skb %p new %p", skb, new);
|
||||||
__skb_insert(new, skb, skb->next, q);
|
__skb_insert(new, skb, ((struct sk_buff_head_l *)skb)->next, q);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
@ -551,24 +559,18 @@ __skb_queue_before(struct sk_buff_head *q, struct sk_buff *skb,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
__skb_queue_tail(struct sk_buff_head *q, struct sk_buff *skb)
|
__skb_queue_tail(struct sk_buff_head *q, struct sk_buff *new)
|
||||||
{
|
{
|
||||||
struct sk_buff *s;
|
|
||||||
|
|
||||||
SKB_TRACE2(q, skb);
|
SKB_TRACE2(q, new);
|
||||||
q->qlen++;
|
__skb_queue_after(q, (struct sk_buff *)q, new);
|
||||||
s = (struct sk_buff *)q;
|
|
||||||
s->prev->next = skb;
|
|
||||||
skb->prev = s->prev;
|
|
||||||
skb->next = s;
|
|
||||||
s->prev = skb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
skb_queue_tail(struct sk_buff_head *q, struct sk_buff *skb)
|
skb_queue_tail(struct sk_buff_head *q, struct sk_buff *new)
|
||||||
{
|
{
|
||||||
SKB_TRACE2(q, skb);
|
SKB_TRACE2(q, skb);
|
||||||
return (__skb_queue_tail(q, skb));
|
return (__skb_queue_tail(q, new));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct sk_buff *
|
static inline struct sk_buff *
|
||||||
@ -817,26 +819,31 @@ skb_mark_not_on_list(struct sk_buff *skb)
|
|||||||
SKB_TODO();
|
SKB_TODO();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
___skb_queue_splice_init(const struct sk_buff_head *from,
|
||||||
|
struct sk_buff *p, struct sk_buff *n)
|
||||||
|
{
|
||||||
|
struct sk_buff *b, *e;
|
||||||
|
|
||||||
|
b = from->next;
|
||||||
|
e = from->prev;
|
||||||
|
|
||||||
|
b->prev = p;
|
||||||
|
((struct sk_buff_head_l *)p)->next = b;
|
||||||
|
e->next = n;
|
||||||
|
((struct sk_buff_head_l *)n)->prev = e;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
skb_queue_splice_init(struct sk_buff_head *from, struct sk_buff_head *to)
|
skb_queue_splice_init(struct sk_buff_head *from, struct sk_buff_head *to)
|
||||||
{
|
{
|
||||||
struct sk_buff *b, *e, *n;
|
|
||||||
|
|
||||||
SKB_TRACE2(from, to);
|
SKB_TRACE2(from, to);
|
||||||
|
|
||||||
if (skb_queue_empty(from))
|
if (skb_queue_empty(from))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* XXX do we need a barrier around this? */
|
___skb_queue_splice_init(from, (struct sk_buff *)to, to->next);
|
||||||
b = from->next;
|
|
||||||
e = from->prev;
|
|
||||||
n = to->next;
|
|
||||||
|
|
||||||
b->prev = (struct sk_buff *)to;
|
|
||||||
to->next = b;
|
|
||||||
e->next = n;
|
|
||||||
n->prev = e;
|
|
||||||
|
|
||||||
to->qlen += from->qlen;
|
to->qlen += from->qlen;
|
||||||
__skb_queue_head_init(from);
|
__skb_queue_head_init(from);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user