sctp: remove typedefs from structures part 6
Subsystems (3)
Xin Long
maintainercover sctp: remove typedefs from structures part 6
As we know, typedef is suggested not to use in kernel, even checkpatch.pl also gives warnings about it. Now sctp is using it for many structures.
All this kind of typedef's using should be removed. This patchset is the part 6 to remove all typedefs in include/net/sctp/structs.h, command.h and sm.h.
Just as the part 1-5, No any code's logic would be changed in these patches, only cleaning up.
Note that this is the last part for this typedef cleaning up. after this patchset, no more inappropriate typedefs in sctp. It's also to tidy some codes when removing them, like fixing many indents, reodering some local params, especially in the last 2 patches.
Xin Long (14):
sctp: remove the unused typedef sctp_packet_phandler_t
sctp: remove the typedef sctp_sender_hb_info_t
sctp: remove the typedef sctp_endpoint_type_t
sctp: remove the typedef sctp_cmsgs_t
sctp: remove the typedef sctp_dbg_objcnt_entry_t
sctp: remove the typedef sctp_socket_type_t
sctp: remove the typedef sctp_cmd_t
sctp: remove the typedef sctp_cmd_seq_t
sctp: remove the typedef sctp_arg_t
sctp: remove the typedef sctp_verb_t
sctp: remove the unused typedef sctp_sm_command_t
sctp: remove the typedef sctp_sm_table_entry_t
sctp: remove the typedef sctp_disposition_t
sctp: fix some indents in sm_make_chunk.c
include/net/sctp/command.h | 58 +- include/net/sctp/sctp.h | 3 +- include/net/sctp/sm.h | 188 +++--- include/net/sctp/structs.h | 26 +- net/sctp/objcnt.c | 2 +- net/sctp/probe.c | 13 +- net/sctp/sm_make_chunk.c | 354 ++++++------ net/sctp/sm_sideeffect.c | 106 ++-- net/sctp/sm_statefuns.c | 1368 +++++++++++++++++++++++--------------------- net/sctp/sm_statetable.c | 42 +- net/sctp/socket.c | 16 +- 11 files changed, 1104 insertions(+), 1072 deletions(-)
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 1/14 sctp: remove the unused typedef sctp_packet_phandler_t
Remove this function typedef, there is even no places using it.
--- include/net/sctp/structs.h | 2 -- 1 file changed, 2 deletions(-)
include/net/sctp/structs.h +0 -2
@@ -657,8 +657,6 @@ struct sctp_sockaddr_entry {#define SCTP_ADDRESS_TICK_DELAY 500 -typedef struct sctp_chunk *(sctp_packet_phandler_t )(struct sctp_association *); -/* This structure holds lists of chunks as we are assembling for * transmission. */
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 2/14 sctp: remove the typedef sctp_sender_hb_info_t
This patch is to remove the typedef sctp_sender_hb_info_t, and replace with struct sctp_sender_hb_info in the places where it's using this typedef.
It is also to use sizeof(variable) instead of sizeof(type).
--- include/net/sctp/structs.h | 4 ++-- net/sctp/sm_make_chunk.c | 6 +++--- net/sctp/sm_sideeffect.c | 4 ++-- net/sctp/sm_statefuns.c | 12 +++++------- 4 files changed, 12 insertions(+), 14 deletions(-)
include/net/sctp/structs.h +2 -2
@@ -371,12 +371,12 @@ union sctp_params {* chunk is sent and the destination transport address to which this * HEARTBEAT is sent (see Section 8.3). */ -typedef struct sctp_sender_hb_info { +struct sctp_sender_hb_info {struct sctp_paramhdr param_hdr;union sctp_addr daddr;unsigned long sent_at;__u64 hb_nonce; -}sctp_sender_hb_info_t ; +};int sctp_stream_init (struct sctp_stream *stream,__u16 outcnt,__u16 incnt,gfp_t gfp);
net/sctp/sm_make_chunk.c +3 -3
@@ -1142,10 +1142,10 @@ struct sctp_chunk *sctp_make_violation_max_retrans(/* Make a HEARTBEAT chunk. */ struct sctp_chunk *sctp_make_heartbeat (const struct sctp_association *asoc, -const struct sctp_transport *transport) +const struct sctp_transport *transport) { +struct sctp_sender_hb_info hbinfo;struct sctp_chunk *retval; -sctp_sender_hb_info_t hbinfo; retval =sctp_make_control (asoc,SCTP_CID_HEARTBEAT ,0 ,sizeof (hbinfo),GFP_ATOMIC );
@@ -1154,7 +1154,7 @@ struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *asoc, goto nodata; hbinfo.param_hdr.type =SCTP_PARAM_HEARTBEAT_INFO ; - hbinfo.param_hdr.length =htons (sizeof (sctp_sender_hb_info_t)); + hbinfo.param_hdr.length =htons (sizeof (hbinfo)); hbinfo.daddr = transport->ipaddr; hbinfo.sent_at = jiffies; hbinfo.hb_nonce = transport->hb_nonce;
net/sctp/sm_sideeffect.c +2 -2
@@ -714,7 +714,7 @@ static void sctp_cmd_transport_on(sctp_cmd_seq_t *cmds,struct sctp_transport *t, struct sctp_chunk *chunk) { - sctp_sender_hb_info_t *hbinfo; + struct sctp_sender_hb_info *hbinfo;int was_unconfirmed =0 ;/* 8.3 Upon the receipt of the HEARTBEAT ACK, the sender of the
@@ -768,7 +768,7 @@ static void sctp_cmd_transport_on(sctp_cmd_seq_t *cmds,if (t->rto_pending =0 ) t->rto_pending =1 ; - hbinfo = (sctp_sender_hb_info_t *) chunk->skb->data; + hbinfo = (struct sctp_sender_hb_info *)chunk->skb->data;sctp_transport_update_rto (t, (jiffies - hbinfo->sent_at));/* Update the heartbeat timer. */
net/sctp/sm_statefuns.c +5 -6
@@ -1155,27 +1155,25 @@ sctp_disposition_t sctp_sf_backbeat_8_3(struct net *net,void *arg, sctp_cmd_seq_t *commands) { + struct sctp_sender_hb_info *hbinfo;struct sctp_chunk *chunk = arg; -union sctp_addr from_addr;struct sctp_transport *link; -sctp_sender_hb_info_t *hbinfo;unsigned long max_interval; +union sctp_addr from_addr;if (!sctp_vtag_verify (chunk, asoc))return sctp_sf_pdiscard (net, ep, asoc, type, arg, commands);/* Make sure that the HEARTBEAT-ACK chunk has a valid length. */ if (!sctp_chunk_length_valid (chunk,sizeof (struct sctp_chunkhdr ) + -sizeof (sctp_sender_hb_info_t))) +sizeof (*hbinfo)))return sctp_sf_violation_chunklen (net, ep, asoc, type, arg, commands); - hbinfo = (sctp_sender_hb_info_t *) chunk->skb->data; + hbinfo = (struct sctp_sender_hb_info *)chunk->skb->data;/* Make sure that the length of the parameter is what we expect */ - if (ntohs(hbinfo->param_hdr.length) !- sizeof(sctp_sender_hb_info_t)) { +if (ntohs (hbinfo->param_hdr.length) !=sizeof (*hbinfo))return SCTP_DISPOSITION_DISCARD ; - } from_addr = hbinfo->daddr; link =sctp_assoc_lookup_paddr (asoc, &from_addr);
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 3/14 sctp: remove the typedef sctp_endpoint_type_t
This patch is to remove the typedef sctp_endpoint_type_t, and replace with enum sctp_endpoint_type in the places where it's using this typedef.
--- include/net/sctp/structs.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/net/sctp/structs.h +3 -3
@@ -1142,10 +1142,10 @@ int sctp_is_ep_boundall(struct sock *sk);/* What type of endpoint? */ -typedef enum { +enum sctp_endpoint_type {SCTP_EP_TYPE_SOCKET ,SCTP_EP_TYPE_ASSOCIATION , -}sctp_endpoint_type_t ; +};/* * A common base class to bridge the implmentation view of a
@@ -1169,7 +1169,7 @@ struct sctp_ep_common {int hashent;/* Runtime type information. What kind of endpoint is this? */ -sctp_endpoint_type_t type; +enum sctp_endpoint_type type;/* Some fields to help us manage this object. * refcnt - Reference count access to this object.
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 4/14 sctp: remove the typedef sctp_cmsgs_t
This patch is to remove the typedef sctp_cmsgs_t, and replace with struct sctp_cmsgs in the places where it's using this typedef.
--- include/net/sctp/structs.h | 4 ++-- net/sctp/socket.c | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-)
include/net/sctp/structs.h +2 -2
@@ -1985,11 +1985,11 @@ int sctp_cmp_addr_exact(const union sctp_addr *ss1,struct sctp_chunk *sctp_get_ecne_prepend (struct sctp_association *asoc);/* A convenience structure to parse out SCTP specific CMSGs. */ -typedef struct sctp_cmsgs { +struct sctp_cmsgs {struct sctp_initmsg *init;struct sctp_sndrcvinfo *srinfo;struct sctp_sndinfo *sinfo; -}sctp_cmsgs_t ; +};/* Structure for tracking memory objects */ typedef struct {
net/sctp/socket.c +5 -4
@@ -1593,7 +1593,8 @@ static int sctp_error(struct sock *sk, int flags, int err)*/ /* BUG: We do not implement the equivalent of sk_stream_wait_memory(). */ -static int sctp_msghdr_parse (const struct msghdr *,sctp_cmsgs_t *); +static int sctp_msghdr_parse (const struct msghdr *msg, +struct sctp_cmsgs *cmsgs);static int sctp_sendmsg (struct sock *sk,struct msghdr *msg,size_t msg_len) {
@@ -1609,7 +1610,7 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)struct sctp_sndrcvinfo *sinfo;struct sctp_initmsg *sinit;sctp_assoc_t associd =0 ; -sctp_cmsgs_t cmsgs = {NULL }; +struct sctp_cmsgs cmsgs = {NULL };enum sctp_scope scope;bool fill_sinfo_ttl = false, wait_connect = false;struct sctp_datamsg *datamsg;
@@ -7445,10 +7446,10 @@ static int sctp_autobind(struct sock *sk)* msg_control * points here */ -static int sctp_msghdr_parse (const struct msghdr *msg,sctp_cmsgs_t *cmsgs) +static int sctp_msghdr_parse (const struct msghdr *msg,struct sctp_cmsgs *cmsgs) { -struct cmsghdr *cmsg;struct msghdr *my_msg = (struct msghdr *)msg; +struct cmsghdr *cmsg;for_each_cmsghdr (cmsg, my_msg) {if (!CMSG_OK (my_msg, cmsg))
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 5/14 sctp: remove the typedef sctp_dbg_objcnt_entry_t
This patch is to remove the typedef sctp_dbg_objcnt_entry_t, and replace with struct sctp_dbg_objcnt_entry in the places where it's using this typedef.
--- include/net/sctp/structs.h | 4 ++-- net/sctp/objcnt.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
include/net/sctp/structs.h +2 -2
@@ -1992,9 +1992,9 @@ struct sctp_cmsgs { };/* Structure for tracking memory objects */ -typedef struct { +struct sctp_dbg_objcnt_entry {char *label;atomic_t *counter; -}sctp_dbg_objcnt_entry_t ; +};#endif /* __sctp_structs_h__ */
net/sctp/objcnt.c +1 -1
@@ -57,7 +57,7 @@ SCTP_DBG_OBJCNT(keys);/* An array to make it easy to pretty print the debug information * to the proc fs. */ -static sctp_dbg_objcnt_entry_t sctp_dbg_objcnt[] = { +static struct sctp_dbg_objcnt_entry sctp_dbg_objcnt[] = {SCTP_DBG_OBJCNT_ENTRY (sock),SCTP_DBG_OBJCNT_ENTRY (ep),SCTP_DBG_OBJCNT_ENTRY (assoc),
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 6/14 sctp: remove the typedef sctp_socket_type_t
This patch is to remove the typedef sctp_socket_type_t, and replace with enum sctp_socket_type in the places where it's using this typedef.
--- include/net/sctp/sctp.h | 3 ++- include/net/sctp/structs.h | 6 +++--- net/sctp/socket.c | 7 ++++--- 3 files changed, 9 insertions(+), 7 deletions(-)
include/net/sctp/sctp.h +2 -1
@@ -550,7 +550,8 @@ static inline int sctp_ep_hashfn(struct net *net, __u16 lport)/* Is a socket of this style? */ #define sctp_style (sk, style) __sctp_style((sk), (SCTP_SOCKET_##style)) -static inline int __sctp_style (const struct sock *sk,sctp_socket_type_t style) +static inline int __sctp_style (const struct sock *sk, +enum sctp_socket_type style) {return sctp_sk (sk)->type = style; }
include/net/sctp/structs.h +3 -3
@@ -150,18 +150,18 @@ extern struct sctp_globals {#define sctp_checksum_disable (sctp_globals.checksum_disable)/* SCTP Socket type: UDP or TCP style. */ -typedef enum { +enum sctp_socket_type {SCTP_SOCKET_UDP =0 ,SCTP_SOCKET_UDP_HIGH_BANDWIDTH ,SCTP_SOCKET_TCP -}sctp_socket_type_t ; +};/* Per socket SCTP information. */ struct sctp_sock {/* inet_sock has to be the first member of sctp_sock */ struct inet_sock inet;/* What kind of a socket is this? */ -sctp_socket_type_t type; +enum sctp_socket_type type;/* PF_ family specific functions. */ struct sctp_pf *pf;
net/sctp/socket.c +4 -3
@@ -100,8 +100,9 @@ static int sctp_send_asconf(struct sctp_association *asoc, struct sctp_chunk *chunk);static int sctp_do_bind (struct sock *,union sctp_addr *,int );static int sctp_autobind (struct sock *sk); -static void sctp_sock_migrate (struct sock *,struct sock *, -struct sctp_association *,sctp_socket_type_t ); +static void sctp_sock_migrate (struct sock *oldsk,struct sock *newsk, +struct sctp_association *assoc, +enum sctp_socket_type type);static unsigned long sctp_memory_pressure;static atomic_long_t sctp_memory_allocated;
@@ -8086,7 +8087,7 @@ static inline void sctp_copy_descendant(struct sock *sk_to,*/ static void sctp_sock_migrate (struct sock *oldsk,struct sock *newsk,struct sctp_association *assoc, -sctp_socket_type_t type) +enum sctp_socket_type type) {struct sctp_sock *oldsp =sctp_sk (oldsk);struct sctp_sock *newsp =sctp_sk (newsk);
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 7/14 sctp: remove the typedef sctp_cmd_t
This patch is to remove the typedef sctp_cmd_t, and replace with enum sctp_cmd in the places where it's using this typedef.
--- include/net/sctp/command.h | 14 +++++++------- net/sctp/sm_sideeffect.c | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-)
include/net/sctp/command.h +7 -7
@@ -196,15 +196,15 @@ static inline sctp_arg_t SCTP_NULL(void)return retval; } -typedef struct { +struct sctp_cmd {sctp_arg_t obj;sctp_verb_t verb; -}sctp_cmd_t ; +};typedef struct { -sctp_cmd_t cmds[SCTP_MAX_NUM_COMMANDS ]; -sctp_cmd_t *last_used_slot; -sctp_cmd_t *next_cmd; +struct sctp_cmd cmds[SCTP_MAX_NUM_COMMANDS ]; +struct sctp_cmd *last_used_slot; +struct sctp_cmd *next_cmd; }sctp_cmd_seq_t ;
@@ -228,7 +228,7 @@ static inline int sctp_init_cmd_seq(sctp_cmd_seq_t *seq)static inline void sctp_add_cmd_sf (sctp_cmd_seq_t *seq,sctp_verb_t verb,sctp_arg_t obj) { -sctp_cmd_t *cmd = seq->last_used_slot -1 ; +struct sctp_cmd *cmd = seq->last_used_slot -1 ;BUG_ON (cmd < seq->cmds);
@@ -240,7 +240,7 @@ static inline void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb,/* Return the next command structure in an sctp_cmd_seq. * Return NULL at the end of the sequence. */ -static inline sctp_cmd_t *sctp_next_cmd (sctp_cmd_seq_t *seq) +static inline struct sctp_cmd *sctp_next_cmd (sctp_cmd_seq_t *seq) {if (seq->next_cmd <= seq->last_used_slot)return NULL ;
net/sctp/sm_sideeffect.c +1 -1
@@ -1277,7 +1277,7 @@ static int sctp_cmd_interpreter(enum sctp_event event_type,struct sctp_sock *sp =sctp_sk (sk);int error =0 ;int force; -sctp_cmd_t *cmd; +struct sctp_cmd *cmd;struct sctp_chunk *new_obj;struct sctp_chunk *chunk =NULL ;struct sctp_packet *packet;
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 8/14 sctp: remove the typedef sctp_cmd_seq_t
This patch is to remove the typedef sctp_cmd_seq_t, and replace with struct sctp_cmd_seq in the places where it's using this typedef.
Note that it doesn't fix many indents although it should, as sctp_disposition_t's removal would mess them up again. So better to fix them when removing sctp_disposition_t in the later patch.
--- include/net/sctp/command.h | 14 +-- include/net/sctp/sm.h | 2 +- net/sctp/probe.c | 2 +- net/sctp/sm_sideeffect.c | 54 ++++++------ net/sctp/sm_statefuns.c | 216 +++++++++++++++++++++++---------------------- 5 files changed, 145 insertions(+), 143 deletions(-)
include/net/sctp/command.h +7 -7
@@ -110,7 +110,7 @@ typedef enum { SCTP_CMD_LAST } sctp_verb_t; -/* How many commands can you put in an sctp_cmd_seq_t? +/* How many commands can you put in an struct sctp_cmd_seq? * This is a rather arbitrary number, ideally derived from a careful * analysis of the state functions, but in reality just taken from * thin air in the hopes othat we don't trigger a kernel panic.
@@ -201,17 +201,17 @@ struct sctp_cmd {sctp_verb_t verb; }; -typedef struct { +struct sctp_cmd_seq {struct sctp_cmd cmds[SCTP_MAX_NUM_COMMANDS ];struct sctp_cmd *last_used_slot;struct sctp_cmd *next_cmd; -}sctp_cmd_seq_t ; +};/* Initialize a block of memory as a command sequence. * Return 0 if the initialization fails. */ -static inline int sctp_init_cmd_seq (sctp_cmd_seq_t *seq) +static inline int sctp_init_cmd_seq (struct sctp_cmd_seq *seq) {/* cmds[] is filled backwards to simplify the overflow BUG() check */ seq->last_used_slot = seq->cmds +SCTP_MAX_NUM_COMMANDS ;
@@ -220,12 +220,12 @@ static inline int sctp_init_cmd_seq(sctp_cmd_seq_t *seq) } -/* Add a command to an sctp_cmd_seq_t. +/* Add a command to an struct sctp_cmd_seq. * * Use the SCTP_* constructors defined by SCTP_ARG_CONSTRUCTOR() above * to wrap data which goes in the obj argument. */ -static inline void sctp_add_cmd_sf (sctp_cmd_seq_t *seq,sctp_verb_t verb, +static inline void sctp_add_cmd_sf (struct sctp_cmd_seq *seq,sctp_verb_t verb,sctp_arg_t obj) {struct sctp_cmd *cmd = seq->last_used_slot -1 ;
@@ -240,7 +240,7 @@ static inline void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb,/* Return the next command structure in an sctp_cmd_seq. * Return NULL at the end of the sequence. */ -static inline struct sctp_cmd *sctp_next_cmd (sctp_cmd_seq_t *seq) +static inline struct sctp_cmd *sctp_next_cmd (struct sctp_cmd_seq *seq) {if (seq->next_cmd <= seq->last_used_slot)return NULL ;
include/net/sctp/sm.h +1 -1
@@ -75,7 +75,7 @@ typedef sctp_disposition_t (sctp_state_fn_t) (struct net *, const struct sctp_association *, const union sctp_subtype type, void *arg, - sctp_cmd_seq_t *); + struct sctp_cmd_seq *);typedef void (sctp_timer_event_t ) (unsigned long ); typedef struct { sctp_state_fn_t *fn;
net/sctp/probe.c +1 -1
@@ -132,7 +132,7 @@ static sctp_disposition_t jsctp_sf_eat_sack(struct net *net,const struct sctp_association *asoc, const union sctp_subtype type, void *arg, - sctp_cmd_seq_t *commands) + struct sctp_cmd_seq *commands) { struct sctp_chunk *chunk = arg;struct sk_buff *skb = chunk->skb;
net/sctp/sm_sideeffect.c +27 -27
192 lines not on this page · raw message
net/sctp/sm_statefuns.c +109 -107
853 lines not on this page · raw message
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 9/14 sctp: remove the typedef sctp_arg_t
This patch is to remove the typedef sctp_arg_t, and replace with union sctp_arg in the places where it's using this typedef.
--- include/net/sctp/command.h | 26 +++++++++++++------------- net/sctp/sm_statefuns.c | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-)
include/net/sctp/command.h +13 -13
@@ -117,7 +117,7 @@ typedef enum {*/ #define SCTP_MAX_NUM_COMMANDS 20 -typedef union { +union sctp_arg {void *zero_all;/* Set to NULL to clear the entire union */ __s32 i32;__u32 u32;
@@ -137,24 +137,24 @@ typedef union {struct sctp_packet *packet;struct sctp_sackhdr *sackh;struct sctp_datamsg *msg; -} sctp_arg_t; +};/* We are simulating ML type constructors here. * * SCTP_ARG_CONSTRUCTOR(NAME, TYPE, ELT) builds a function called * SCTP_NAME() which takes an argument of type TYPE and returns an -* sctp_arg_t. It does this by inserting the sole argument into the -* ELT union element of a local sctp_arg_t. +* union sctp_arg. It does this by inserting the sole argument into +* the ELT union element of a local union sctp_arg. * * E.g., SCTP_ARG_CONSTRUCTOR(I32, __s32, i32) builds SCTP_I32(arg), -* which takes an __s32 and returns a sctp_arg_t containing the +* which takes an __s32 and returns a union sctp_arg containing the * __s32. So, after foo = SCTP_I32(arg), foo.i32 = arg. */ #define SCTP_ARG_CONSTRUCTOR (name, type, elt) \ -static inline sctp_arg_t \ +static inline union sctp_arg \ SCTP_## name (type arg) \ -{ sctp_arg_t retval;\ +{ union sctp_arg retval;\ retval.zero_all = NULL;\ retval.elt = arg;\ return retval;\
@@ -179,25 +179,25 @@ SCTP_ARG_CONSTRUCTOR(PACKET, struct sctp_packet *, packet) SCTP_ARG_CONSTRUCTOR(SACKH, struct sctp_sackhdr *, sackh) SCTP_ARG_CONSTRUCTOR(DATAMSG, struct sctp_datamsg *, msg) -static inline sctp_arg_t SCTP_FORCE (void ) +static inline union sctp_arg SCTP_FORCE (void ) {return SCTP_I32 (1 ); } -static inline sctp_arg_t SCTP_NOFORCE (void ) +static inline union sctp_arg SCTP_NOFORCE (void ) {return SCTP_I32 (0 ); } -static inline sctp_arg_t SCTP_NULL (void ) +static inline union sctp_arg SCTP_NULL (void ) { -sctp_arg_t retval; +union sctp_arg retval; retval.zero_all =NULL ;return retval; }struct sctp_cmd { -sctp_arg_t obj; +union sctp_arg obj;sctp_verb_t verb; };
@@ -226,7 +226,7 @@ static inline int sctp_init_cmd_seq(struct sctp_cmd_seq *seq)* to wrap data which goes in the obj argument. */ static inline void sctp_add_cmd_sf (struct sctp_cmd_seq *seq,sctp_verb_t verb, -sctp_arg_t obj) +union sctp_arg obj) {struct sctp_cmd *cmd = seq->last_used_slot -1 ;
net/sctp/sm_statefuns.c +1 -1
@@ -2975,8 +2975,8 @@ sctp_disposition_t sctp_sf_eat_data_6_2(struct net *net,void *arg, struct sctp_cmd_seq *commands) { + union sctp_arg force = SCTP_NOFORCE();struct sctp_chunk *chunk = arg; -sctp_arg_t force =SCTP_NOFORCE ();int error;if (!sctp_vtag_verify (chunk, asoc)) {
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 10/14 sctp: remove the typedef sctp_verb_t
This patch is to remove the typedef sctp_verb_t, and replace with enum sctp_verb in the places where it's using this typedef.
--- include/net/sctp/command.h | 10 +++++----- net/sctp/sm_statefuns.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)
include/net/sctp/command.h +5 -5
@@ -40,7 +40,7 @@#include <net/sctp/structs.h> -typedef enum { +enum sctp_verb {SCTP_CMD_NOP =0 ,/* Do nothing. */ SCTP_CMD_NEW_ASOC ,/* Register a new association. */ SCTP_CMD_DELETE_TCB ,/* Delete the current association. */
@@ -108,7 +108,7 @@ typedef enum {SCTP_CMD_PURGE_ASCONF_QUEUE ,/* Purge all asconf queues.*/ SCTP_CMD_SET_ASOC ,/* Restore association context */ SCTP_CMD_LAST -} sctp_verb_t; +};/* How many commands can you put in an struct sctp_cmd_seq? * This is a rather arbitrary number, ideally derived from a careful
@@ -198,7 +198,7 @@ static inline union sctp_arg SCTP_NULL(void)struct sctp_cmd {union sctp_arg obj; -sctp_verb_t verb; +enum sctp_verb verb; };struct sctp_cmd_seq {
@@ -225,8 +225,8 @@ static inline int sctp_init_cmd_seq(struct sctp_cmd_seq *seq)* Use the SCTP_* constructors defined by SCTP_ARG_CONSTRUCTOR() above * to wrap data which goes in the obj argument. */ -static inline void sctp_add_cmd_sf (struct sctp_cmd_seq *seq,sctp_verb_t verb, -union sctp_arg obj) +static inline void sctp_add_cmd_sf (struct sctp_cmd_seq *seq, +enum sctp_verb verb,union sctp_arg obj) {struct sctp_cmd *cmd = seq->last_used_slot -1 ;
net/sctp/sm_statefuns.c +1 -1
@@ -6205,7 +6205,7 @@ static int sctp_eat_data(const struct sctp_association *asoc,struct sctp_datahdr *data_hdr;struct sctp_chunk *err;size_t datalen; -sctp_verb_t deliver; +enum sctp_verb deliver;int tmp;__u32 tsn;struct sctp_tsnmap *map = (struct sctp_tsnmap *)&asoc->peer.tsn_map;
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 11/14 sctp: remove the unused typedef sctp_sm_command_t
Remove this typedef including the struct, there is even no places using it.
--- include/net/sctp/sm.h | 5 ----- 1 file changed, 5 deletions(-)
include/net/sctp/sm.h +0 -5
@@ -65,11 +65,6 @@ typedef enum {SCTP_DISPOSITION_BUG ,/* This is a bug. */ } sctp_disposition_t; -typedef struct { -int name; -int action; -}sctp_sm_command_t ; - typedef sctp_disposition_t (sctp_state_fn_t) (struct net *, const struct sctp_endpoint *, const struct sctp_association *,
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 12/14 sctp: remove the typedef sctp_sm_table_entry_t
This patch is to remove the typedef sctp_sm_table_entry_t, and replace with struct sctp_sm_table_entry in the places where it's using this typedef.
It is also to fix some indents.
--- include/net/sctp/sm.h | 6 +++--- net/sctp/sm_sideeffect.c | 2 +- net/sctp/sm_statetable.c | 42 +++++++++++++++++++++++++----------------- 3 files changed, 29 insertions(+), 21 deletions(-)
include/net/sctp/sm.h +3 -3
@@ -72,10 +72,10 @@ typedef sctp_disposition_t (sctp_state_fn_t) (struct net *,void *arg, struct sctp_cmd_seq *);typedef void (sctp_timer_event_t ) (unsigned long ); -typedef struct { +struct sctp_sm_table_entry {sctp_state_fn_t *fn;const char *name; -}sctp_sm_table_entry_t ; +};/* A naming convention of "sctp_sf_xxx" applies to all the state functions * currently in use.
@@ -170,7 +170,7 @@ sctp_state_fn_t sctp_sf_autoclose_timer_expire;/* Prototypes for utility support functions. */ __u8 sctp_get_chunk_type (struct sctp_chunk *chunk); -const sctp_sm_table_entry_t *sctp_sm_lookup_event( +const struct sctp_sm_table_entry *sctp_sm_lookup_event( struct net *net, enum sctp_event event_type, enum sctp_state state,
net/sctp/sm_sideeffect.c +1 -1
@@ -1146,7 +1146,7 @@ int sctp_do_sm(struct net *net, enum sctp_event event_type, void *event_arg, gfp_t gfp) {struct sctp_cmd_seq commands; -const sctp_sm_table_entry_t *state_fn; +const struct sctp_sm_table_entry *state_fn;sctp_disposition_t status;int error =0 ;typedef const char *(printfn_t )(union sctp_subtype );
net/sctp/sm_statetable.c +25 -17
126 lines not on this page · raw message
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 13/14 sctp: remove the typedef sctp_disposition_t
This patch is to remove the typedef sctp_disposition_t, and replace with enum sctp_disposition in the places where it's using this typedef.
It's also to fix the indent for many functions' defination.
--- include/net/sctp/sm.h | 19 +- net/sctp/probe.c | 13 +- net/sctp/sm_sideeffect.c | 50 +- net/sctp/sm_statefuns.c | 1316 ++++++++++++++++++++++++---------------------- 4 files changed, 717 insertions(+), 681 deletions(-)
include/net/sctp/sm.h +10 -9
@@ -53,7 +53,7 @@/* * Possible values for the disposition are: */ -typedef enum { +enum sctp_disposition {SCTP_DISPOSITION_DISCARD ,/* No further processing. */ SCTP_DISPOSITION_CONSUME ,/* Process return values normally. */ SCTP_DISPOSITION_NOMEM ,/* We ran out of memory--recover. */
@@ -63,14 +63,15 @@ typedef enum { SCTP_DISPOSITION_NOT_IMPL, /* This entry is not implemented. */SCTP_DISPOSITION_ERROR ,/* This is plain old user error. */ SCTP_DISPOSITION_BUG, /* This is a bug. */ -} sctp_disposition_t; - -typedef sctp_disposition_t (sctp_state_fn_t ) (struct net *, -const struct sctp_endpoint *, -const struct sctp_association *, -const union sctp_subtype type, -void *arg, -struct sctp_cmd_seq *); +}; + +typedef enum sctp_disposition (sctp_state_fn_t ) ( +struct net *net, +const struct sctp_endpoint *ep, +const struct sctp_association *asoc, +const union sctp_subtype type, +void *arg, +struct sctp_cmd_seq *commands);typedef void (sctp_timer_event_t ) (unsigned long );struct sctp_sm_table_entry {sctp_state_fn_t *fn;
net/sctp/probe.c +7 -6
@@ -127,12 +127,13 @@ static const struct file_operations sctpprobe_fops = { .llseek = noop_llseek, }; -static sctp_disposition_t jsctp_sf_eat_sack (struct net *net, -const struct sctp_endpoint *ep, -const struct sctp_association *asoc, -const union sctp_subtype type, -void *arg, -struct sctp_cmd_seq *commands) +static enum sctp_disposition jsctp_sf_eat_sack ( +struct net *net, +const struct sctp_endpoint *ep, +const struct sctp_association *asoc, +const union sctp_subtype type, +void *arg, +struct sctp_cmd_seq *commands) {struct sctp_chunk *chunk = arg;struct sk_buff *skb = chunk->skb;
net/sctp/sm_sideeffect.c +25 -25
158 lines not on this page · raw message
net/sctp/sm_statefuns.c +675 -641
2,046 lines not on this page · raw message
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 14/14 sctp: fix some indents in sm_make_chunk.c
There are some bad indents of functions' defination in sm_make_chunk.c. They have been there since beginning, it was probably caused by that the typedef sctp_chunk_t was replaced with struct sctp_chunk.
So it's the best time to fix them in this patchset, it's also to fix some bad indents in other functions' defination in sm_make_chunk.c.
--- include/net/sctp/sm.h | 158 ++++++++++----------- net/sctp/sm_make_chunk.c | 348 +++++++++++++++++++++++------------------------ 2 files changed, 249 insertions(+), 257 deletions(-)
include/net/sctp/sm.h +79 -79
@@ -184,68 +184,69 @@ __u32 sctp_generate_verification_tag(void);void sctp_populate_tie_tags (__u8 *cookie,__u32 curTag,__u32 hisTag);/* Prototypes for chunk-building functions. */ -struct sctp_chunk *sctp_make_init (const struct sctp_association *, -const struct sctp_bind_addr *, -gfp_t gfp,int vparam_len); -struct sctp_chunk *sctp_make_init_ack (const struct sctp_association *, -const struct sctp_chunk *, -const gfp_t gfp, -const int unkparam_len); -struct sctp_chunk *sctp_make_cookie_echo (const struct sctp_association *, -const struct sctp_chunk *); -struct sctp_chunk *sctp_make_cookie_ack (const struct sctp_association *, -const struct sctp_chunk *); -struct sctp_chunk *sctp_make_cwr (const struct sctp_association *, +struct sctp_chunk *sctp_make_init (const struct sctp_association *asoc, +const struct sctp_bind_addr *bp, +gfp_t gfp,int vparam_len); +struct sctp_chunk *sctp_make_init_ack (const struct sctp_association *asoc, +const struct sctp_chunk *chunk, +const gfp_t gfp,const int unkparam_len); +struct sctp_chunk *sctp_make_cookie_echo (const struct sctp_association *asoc, +const struct sctp_chunk *chunk); +struct sctp_chunk *sctp_make_cookie_ack (const struct sctp_association *asoc, +const struct sctp_chunk *chunk); +struct sctp_chunk *sctp_make_cwr (const struct sctp_association *asoc,const __u32 lowest_tsn, -const struct sctp_chunk *); -struct sctp_chunk *sctp_make_datafrag_empty (struct sctp_association *, -const struct sctp_sndrcvinfo *sinfo, -int len,const __u8 flags, -__u16 ssn,gfp_t gfp); -struct sctp_chunk *sctp_make_ecne (const struct sctp_association *, -const __u32 ); -struct sctp_chunk *sctp_make_sack (const struct sctp_association *); +const struct sctp_chunk *chunk); +struct sctp_chunk *sctp_make_datafrag_empty (struct sctp_association *asoc, +const struct sctp_sndrcvinfo *sinfo, +int len,const __u8 flags, +__u16 ssn,gfp_t gfp); +struct sctp_chunk *sctp_make_ecne (const struct sctp_association *asoc, +const __u32 lowest_tsn); +struct sctp_chunk *sctp_make_sack (const struct sctp_association *asoc);struct sctp_chunk *sctp_make_shutdown (const struct sctp_association *asoc,const struct sctp_chunk *chunk);struct sctp_chunk *sctp_make_shutdown_ack (const struct sctp_association *asoc, -const struct sctp_chunk *); -struct sctp_chunk *sctp_make_shutdown_complete (const struct sctp_association *, -const struct sctp_chunk *); -void sctp_init_cause (struct sctp_chunk *,__be16 cause,size_t ); -struct sctp_chunk *sctp_make_abort (const struct sctp_association *, -const struct sctp_chunk *, -const size_t hint); -struct sctp_chunk *sctp_make_abort_no_data (const struct sctp_association *, -const struct sctp_chunk *, -__u32 tsn); -struct sctp_chunk *sctp_make_abort_user (const struct sctp_association *, -struct msghdr *,size_t msg_len); -struct sctp_chunk *sctp_make_abort_violation (const struct sctp_association *, -const struct sctp_chunk *, -const __u8 *, -const size_t ); -struct sctp_chunk *sctp_make_violation_paramlen (const struct sctp_association *, -const struct sctp_chunk *, -struct sctp_paramhdr *); -struct sctp_chunk *sctp_make_violation_max_retrans (const struct sctp_association *, -const struct sctp_chunk *); -struct sctp_chunk *sctp_make_heartbeat (const struct sctp_association *, -const struct sctp_transport *); -struct sctp_chunk *sctp_make_heartbeat_ack (const struct sctp_association *, -const struct sctp_chunk *, -const void *payload, -const size_t paylen); -struct sctp_chunk *sctp_make_op_error (const struct sctp_association *, -const struct sctp_chunk *chunk, -__be16 cause_code, -const void *payload, -size_t paylen, -size_t reserve_tail); - -struct sctp_chunk *sctp_make_asconf_update_ip (struct sctp_association *, -union sctp_addr *, -struct sockaddr *, -int ,__be16 ); +const struct sctp_chunk *chunk); +struct sctp_chunk *sctp_make_shutdown_complete ( +const struct sctp_association *asoc, +const struct sctp_chunk *chunk); +void sctp_init_cause (struct sctp_chunk *chunk,__be16 cause,size_t paylen); +struct sctp_chunk *sctp_make_abort (const struct sctp_association *asoc, +const struct sctp_chunk *chunk, +const size_t hint); +struct sctp_chunk *sctp_make_abort_no_data (const struct sctp_association *asoc, +const struct sctp_chunk *chunk, +__u32 tsn); +struct sctp_chunk *sctp_make_abort_user (const struct sctp_association *asoc, +struct msghdr *msg,size_t msg_len); +struct sctp_chunk *sctp_make_abort_violation ( +const struct sctp_association *asoc, +const struct sctp_chunk *chunk, +const __u8 *payload, +const size_t paylen); +struct sctp_chunk *sctp_make_violation_paramlen ( +const struct sctp_association *asoc, +const struct sctp_chunk *chunk, +struct sctp_paramhdr *param); +struct sctp_chunk *sctp_make_violation_max_retrans ( +const struct sctp_association *asoc, +const struct sctp_chunk *chunk); +struct sctp_chunk *sctp_make_heartbeat (const struct sctp_association *asoc, +const struct sctp_transport *transport); +struct sctp_chunk *sctp_make_heartbeat_ack (const struct sctp_association *asoc, +const struct sctp_chunk *chunk, +const void *payload, +const size_t paylen); +struct sctp_chunk *sctp_make_op_error (const struct sctp_association *asoc, +const struct sctp_chunk *chunk, +__be16 cause_code,const void *payload, +size_t paylen,size_t reserve_tail); + +struct sctp_chunk *sctp_make_asconf_update_ip (struct sctp_association *asoc, +union sctp_addr *laddr, +struct sockaddr *addrs, +int addrcnt,__be16 flags);struct sctp_chunk *sctp_make_asconf_set_prim (struct sctp_association *asoc,union sctp_addr *addr); bool sctp_verify_asconf(const struct sctp_association *asoc,
@@ -259,27 +260,25 @@ struct sctp_chunk *sctp_make_fwdtsn(const struct sctp_association *asoc, __u32 new_cum_tsn, size_t nstreams, struct sctp_fwdtsn_skip *skiplist);struct sctp_chunk *sctp_make_auth (const struct sctp_association *asoc); -struct sctp_chunk *sctp_make_strreset_req ( -const struct sctp_association *asoc, -__u16 stream_num,__u16 *stream_list, -bool out,bool in); +struct sctp_chunk *sctp_make_strreset_req (const struct sctp_association *asoc, +__u16 stream_num,__u16 *stream_list, +bool out,bool in);struct sctp_chunk *sctp_make_strreset_tsnreq ( -const struct sctp_association *asoc); +const struct sctp_association *asoc);struct sctp_chunk *sctp_make_strreset_addstrm ( -const struct sctp_association *asoc, -__u16 out,__u16 in); -struct sctp_chunk *sctp_make_strreset_resp ( -const struct sctp_association *asoc, -__u32 result,__u32 sn); -struct sctp_chunk *sctp_make_strreset_tsnresp ( -struct sctp_association *asoc, -__u32 result,__u32 sn, -__u32 sender_tsn,__u32 receiver_tsn); +const struct sctp_association *asoc, +__u16 out,__u16 in); +struct sctp_chunk *sctp_make_strreset_resp (const struct sctp_association *asoc, +__u32 result,__u32 sn); +struct sctp_chunk *sctp_make_strreset_tsnresp (struct sctp_association *asoc, +__u32 result,__u32 sn, +__u32 sender_tsn, +__u32 receiver_tsn);bool sctp_verify_reconf (const struct sctp_association *asoc,struct sctp_chunk *chunk,struct sctp_paramhdr **errp); -void sctp_chunk_assign_tsn (struct sctp_chunk *); -void sctp_chunk_assign_ssn (struct sctp_chunk *); +void sctp_chunk_assign_tsn (struct sctp_chunk *chunk); +void sctp_chunk_assign_ssn (struct sctp_chunk *chunk);/* Prototypes for stream-processing functions. */ struct sctp_chunk *sctp_process_strreset_outreq(
@@ -322,11 +321,12 @@ void sctp_generate_proto_unreach_event(unsigned long peer);void sctp_ootb_pkt_free (struct sctp_packet *packet); -struct sctp_association *sctp_unpack_cookie (const struct sctp_endpoint *ep, -const struct sctp_association *asoc, -struct sctp_chunk *chunk, -gfp_t gfp,int *err, -struct sctp_chunk **err_chk_p); +struct sctp_association *sctp_unpack_cookie ( +const struct sctp_endpoint *ep, +const struct sctp_association *asoc, +struct sctp_chunk *chunk, +gfp_t gfp,int *err, +struct sctp_chunk **err_chk_p);/* 3rd level prototypes */ __u32 sctp_generate_tag (const struct sctp_endpoint *ep);
net/sctp/sm_make_chunk.c +170 -178
715 lines not on this page · raw message
Signature · 1 line
2.1.0
David Miller
maintainerFrom: Xin Long <[email protected]>
Date: Fri, 11 Aug 2017 10:23:44 +0800
Quoted 7 lines
As we know, typedef is suggested not to use in kernel, even checkpatch.pl also gives warnings about it. Now sctp is using it for many structures.
All this kind of typedef's using should be removed. This patchset is the part 6 to remove all typedefs in
include/net/sctp/structs.h,command.handsm.h.
Quoted 7 lines
Just as the part 1-5, No any code's logic would be changed in these patches, only cleaning up.
Note that this is the last part for this typedef cleaning up. after this patchset, no more inappropriate typedefs in sctp. It's also to tidy some codes when removing them, like fixing many indents, reodering some local params, especially in the last 2 patches.
Series applied, thanks Xin.