Two SCTP cleanup patches
Subsystems (3)
cover Two SCTP cleanup patches
Two cleanup-only patches to make the code more readable and consistent with the rest of the kernel code.
Daniel Borkmann (2):
net: sctp: get rid of t_new macro for kzalloc
net: sctp: remove SCTP_STATIC macro
include/net/sctp/sctp.h | 11 ------- net/sctp/associola.c | 2 +- net/sctp/bind_addr.c | 2 +- net/sctp/chunk.c | 2 +- net/sctp/endpointola.c | 3 +- net/sctp/input.c | 4 +-- net/sctp/ipv6.c | 6 ++-- net/sctp/protocol.c | 6 ++-- net/sctp/sm_make_chunk.c | 10 +++---- net/sctp/socket.c | 78 ++++++++++++++++++++++-------------------------- net/sctp/transport.c | 2 +- net/sctp/tsnmap.c | 10 +++---- net/sctp/ulpevent.c | 10 +++---- 13 files changed, 64 insertions(+), 82 deletions(-)
Signature · 1 line
1.7.11.7
PATCH 1/2 net: sctp: get rid of t_new macro for kzalloc
t_new rather obfuscates things where everyone else is using actual function names instead of that macro, so replace it with kzalloc, which is the function t_new wraps.
--- include/net/sctp/sctp.h | 3 --- net/sctp/associola.c | 2 +- net/sctp/bind_addr.c | 2 +- net/sctp/endpointola.c | 3 ++- net/sctp/ipv6.c | 2 +- net/sctp/protocol.c | 2 +- net/sctp/transport.c | 2 +- 7 files changed, 7 insertions(+), 9 deletions(-)
include/net/sctp/sctp.h +0 -3
@@ -575,9 +575,6 @@ for (pos = chunk->subh.fwdtsn_hdr->skip;\/* Round an int up to the next multiple of 4. */ #define WORD_ROUND (s) (((s)+3)&~3) -/* Make a new instance of type. */ -#define t_new (type, flags) kzalloc(sizeof(type), flags) -/* Compare two timevals. */ #define tv_lt (s, t) \ (s.tv_sec < t.tv_sec || (s.tv_sec = t.tv_sec && s.tv_usec < t.tv_usec))
net/sctp/associola.c +1 -1
@@ -355,7 +355,7 @@ struct sctp_association *sctp_association_new(const struct sctp_endpoint *ep, {struct sctp_association *asoc; - asoc = t_new(struct sctp_association, gfp); + asoc =kzalloc (sizeof (*asoc), gfp);if (!asoc) goto fail;
net/sctp/bind_addr.c +1 -1
@@ -162,7 +162,7 @@ int sctp_add_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *new,struct sctp_sockaddr_entry *addr;/* Add the address to the bind address list. */ - addr = t_new(struct sctp_sockaddr_entry, gfp); + addr =kzalloc (sizeof (*addr), gfp);if (!addr)return -ENOMEM ;
net/sctp/endpointola.c +2 -1
@@ -192,9 +192,10 @@ struct sctp_endpoint *sctp_endpoint_new(struct sock *sk, gfp_t gfp)struct sctp_endpoint *ep;/* Build a local endpoint. */ - ep = t_new(struct sctp_endpoint, gfp); + ep =kzalloc (sizeof (*ep), gfp);if (!ep) goto fail; +if (!sctp_endpoint_init (ep, sk, gfp)) goto fail_init;
net/sctp/ipv6.c +1 -1
@@ -402,7 +402,7 @@ static void sctp_v6_copy_addrlist(struct list_head *addrlist,read_lock_bh (&in6_dev->lock);list_for_each_entry (ifp, &in6_dev->addr_list, if_list) {/* Add the address to the local list. */ - addr = t_new(struct sctp_sockaddr_entry, GFP_ATOMIC); + addr =kzalloc (sizeof (*addr),GFP_ATOMIC );if (addr) { addr->a.v6.sin6_family =AF_INET6 ; addr->a.v6.sin6_port =0 ;
net/sctp/protocol.c +1 -1
@@ -153,7 +153,7 @@ static void sctp_v4_copy_addrlist(struct list_head *addrlist,for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {/* Add the address to the local list. */ - addr = t_new(struct sctp_sockaddr_entry, GFP_ATOMIC); + addr =kzalloc (sizeof (*addr),GFP_ATOMIC );if (addr) { addr->a.v4.sin_family =AF_INET ; addr->a.v4.sin_port =0 ;
net/sctp/transport.c +1 -1
@@ -116,7 +116,7 @@ struct sctp_transport *sctp_transport_new(struct net *net, {struct sctp_transport *transport; - transport = t_new(struct sctp_transport, gfp); + transport =kzalloc (sizeof (*transport), gfp);if (!transport) goto fail;
Signature · 1 line
1.7.11.7
PATCH 2/2 net: sctp: remove SCTP_STATIC macro
In reply to Daniel BorkmannSCTP_STATIC ist just another define for the static keyword. It's use is inconsistent in the SCTP code anyway and it was introduced in the initial implementation of SCTP in 2.5. We have a regression suite in lksctp-tools, but this is for user space only, so noone makes use of this macro anymore. The kernel test suite for 2.5 is incompatible with the current SCTP code anyway.
So simply Remove it, to be more consistent with the rest of the kernel code.
--- include/net/sctp/sctp.h | 8 ----- net/sctp/chunk.c | 2 +- net/sctp/input.c | 4 +-- net/sctp/ipv6.c | 4 +-- net/sctp/protocol.c | 4 +-- net/sctp/sm_make_chunk.c | 10 +++---- net/sctp/socket.c | 78 ++++++++++++++++++++++-------------------------- net/sctp/tsnmap.c | 10 +++---- net/sctp/ulpevent.c | 10 +++---- 9 files changed, 57 insertions(+), 73 deletions(-)
include/net/sctp/sctp.h +0 -8
@@ -99,14 +99,6 @@#define SCTP_PROTOSW_FLAG INET_PROTOSW_PERMANENT#endif - -/* Certain internal static functions need to be exported when -* compiled into the test frame. -*/ -#ifndef SCTP_STATIC -#define SCTP_STATIC static -#endif -/* * Function declarations. */
net/sctp/chunk.c +1 -1
@@ -66,7 +66,7 @@ static void sctp_datamsg_init(struct sctp_datamsg *msg) }/* Allocate and initialize datamsg. */ -SCTP_STATIC struct sctp_datamsg *sctp_datamsg_new(gfp_t gfp) +static struct sctp_datamsg *sctp_datamsg_new (gfp_t gfp) {struct sctp_datamsg *msg; msg =kmalloc (sizeof (struct sctp_datamsg ), gfp);
net/sctp/input.c +2 -2
@@ -903,11 +903,11 @@ hit: }/* Look up an association. BH-safe. */ -SCTP_STATIC +static struct sctp_association *sctp_lookup_association (struct net *net,const union sctp_addr *laddr,const union sctp_addr *paddr, -struct sctp_transport **transportp) +struct sctp_transport **transportp) {struct sctp_association *asoc;
net/sctp/ipv6.c +2 -2
@@ -145,8 +145,8 @@ static struct notifier_block sctp_inet6addr_notifier = { };/* ICMP error handler. */ -SCTP_STATIC void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, -u8 type,u8 code,int offset,__be32 info) +static void sctp_v6_err (struct sk_buff *skb,struct inet6_skb_parm *opt, +u8 type,u8 code,int offset,__be32 info) {struct inet6_dev *idev;struct sock *sk;
net/sctp/protocol.c +2 -2
@@ -1312,7 +1312,7 @@ static struct pernet_operations sctp_net_ops = { };/* Initialize the universe into something sensible. */ -SCTP_STATIC __init int sctp_init(void) +static __init int sctp_init (void ) {int i;int status = -EINVAL ;
@@ -1499,7 +1499,7 @@ err_chunk_cachep: }/* Exit handler for the SCTP protocol. */ -SCTP_STATIC __exit void sctp_exit(void) +static __exit void sctp_exit(void) {/* BUG. This should probably do something useful like clean * up all the remaining associations and all that memory.
net/sctp/sm_make_chunk.c +4 -6
@@ -68,9 +68,8 @@#include <net/sctp/sctp.h> #include <net/sctp/sm.h> -SCTP_STATIC -struct sctp_chunk *sctp_make_chunk(const struct sctp_association *asoc, -__u8 type,__u8 flags,int paylen); +static struct sctp_chunk *sctp_make_chunk (const struct sctp_association *asoc, +__u8 type,__u8 flags,int paylen); static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep, const struct sctp_association *asoc, const struct sctp_chunk *init_chunk,
@@ -1353,9 +1352,8 @@ const union sctp_addr *sctp_source(const struct sctp_chunk *chunk)/* Create a new chunk, setting the type and flags headers from the * arguments, reserving enough space for a 'paylen' byte payload. */ -SCTP_STATIC -struct sctp_chunk *sctp_make_chunk(const struct sctp_association *asoc, -__u8 type,__u8 flags,int paylen) +static struct sctp_chunk *sctp_make_chunk (const struct sctp_association *asoc, +__u8 type,__u8 flags,int paylen) {struct sctp_chunk *retval;sctp_chunkhdr_t *chunk_hdr;
net/sctp/socket.c +36 -42
211 lines not on this page · raw message
net/sctp/tsnmap.c +5 -5
@@ -161,8 +161,8 @@ int sctp_tsnmap_mark(struct sctp_tsnmap *map, __u32 tsn,/* Initialize a Gap Ack Block iterator from memory being provided. */ -SCTP_STATIC void sctp_tsnmap_iter_init(const struct sctp_tsnmap *map, -struct sctp_tsnmap_iter *iter) +static void sctp_tsnmap_iter_init (const struct sctp_tsnmap *map, +struct sctp_tsnmap_iter *iter) {/* Only start looking one past the Cumulative TSN Ack Point. */ iter->start = map->cumulative_tsn_ack_point +1 ;
@@ -171,9 +171,9 @@ SCTP_STATIC void sctp_tsnmap_iter_init(const struct sctp_tsnmap *map,/* Get the next Gap Ack Blocks. Returns 0 if there was not another block * to get. */ -SCTP_STATIC int sctp_tsnmap_next_gap_ack(const struct sctp_tsnmap *map, -struct sctp_tsnmap_iter *iter, -__u16 *start,__u16 *end) +static int sctp_tsnmap_next_gap_ack (const struct sctp_tsnmap *map, +struct sctp_tsnmap_iter *iter, +__u16 *start,__u16 *end) {int ended =0 ;__u16 start_ =0 , end_ =0 , offset;
net/sctp/ulpevent.c +5 -5
@@ -57,9 +57,9 @@ static void sctp_ulpevent_release_frag_data(struct sctp_ulpevent *event);/* Initialize an ULP event from an given skb. */ -SCTP_STATIC void sctp_ulpevent_init(struct sctp_ulpevent *event, -int msg_flags, -unsigned int len) +static void sctp_ulpevent_init (struct sctp_ulpevent *event, +int msg_flags, +unsigned int len) {memset (event,0 ,sizeof (struct sctp_ulpevent )); event->msg_flags = msg_flags;
@@ -67,8 +67,8 @@ SCTP_STATIC void sctp_ulpevent_init(struct sctp_ulpevent *event, }/* Create a new sctp_ulpevent. */ -SCTP_STATIC struct sctp_ulpevent *sctp_ulpevent_new(int size, int msg_flags, -gfp_t gfp) +static struct sctp_ulpevent *sctp_ulpevent_new (int size,int msg_flags, +gfp_t gfp) {struct sctp_ulpevent *event;struct sk_buff *skb;
Signature · 1 line
1.7.11.7
Quoted 7 lines · Daniel Borkmann
Two cleanup-only patches to make the code more readable and consistent with the rest of the kernel code.
Daniel Borkmann (2):
net: sctp: get rid oft_newmacro for kzalloc
net: sctp: removeSCTP_STATICmacro
-vlad
Quoted 15 lines
include/net/sctp/sctp.h | 11 ------- net/sctp/associola.c | 2 +- net/sctp/bind_addr.c | 2 +- net/sctp/chunk.c | 2 +- net/sctp/endpointola.c | 3 +- net/sctp/input.c | 4 +-- net/sctp/ipv6.c | 6 ++-- net/sctp/protocol.c | 6 ++-- net/sctp/sm_make_chunk.c | 10 +++---- net/sctp/socket.c | 78 ++++++++++++++++++++++-------------------------- net/sctp/transport.c | 2 +- net/sctp/tsnmap.c | 10 +++---- net/sctp/ulpevent.c | 10 +++---- 13 files changed, 64 insertions(+), 82 deletions(-)
David Miller
maintainerFrom: Vlad Yasevich <[email protected]>
Date: Mon, 17 Jun 2013 09:56:06 -0400
Quoted 10 lines · Daniel Borkmann
Quoted 7 lines
Two cleanup-only patches to make the code more readable and consistent with the rest of the kernel code.
Daniel Borkmann (2):
net: sctp: get rid oft_newmacro for kzalloc
net: sctp: removeSCTP_STATICmacroAcked-by Vlad Yasevich <[email protected]>
Series applied, thanks everyone.