Commit bfc6f827 authored by Xin Long's avatar Xin Long Committed by David S. Miller

sctp: remove the typedef sctp_subtype_t

This patch is to remove the typedef sctp_subtype_t, and
replace with union sctp_subtype 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
later patch.
Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 61f0eb07
...@@ -124,20 +124,20 @@ enum sctp_event_primitive { ...@@ -124,20 +124,20 @@ enum sctp_event_primitive {
/* We define here a utility type for manipulating subtypes. /* We define here a utility type for manipulating subtypes.
* The subtype constructors all work like this: * The subtype constructors all work like this:
* *
* sctp_subtype_t foo = SCTP_ST_CHUNK(SCTP_CID_INIT); * union sctp_subtype foo = SCTP_ST_CHUNK(SCTP_CID_INIT);
*/ */
typedef union { union sctp_subtype {
enum sctp_cid chunk; enum sctp_cid chunk;
enum sctp_event_timeout timeout; enum sctp_event_timeout timeout;
enum sctp_event_other other; enum sctp_event_other other;
enum sctp_event_primitive primitive; enum sctp_event_primitive primitive;
} sctp_subtype_t; };
#define SCTP_SUBTYPE_CONSTRUCTOR(_name, _type, _elt) \ #define SCTP_SUBTYPE_CONSTRUCTOR(_name, _type, _elt) \
static inline sctp_subtype_t \ static inline union sctp_subtype \
SCTP_ST_## _name (_type _arg) \ SCTP_ST_## _name (_type _arg) \
{ sctp_subtype_t _retval; _retval._elt = _arg; return _retval; } { union sctp_subtype _retval; _retval._elt = _arg; return _retval; }
SCTP_SUBTYPE_CONSTRUCTOR(CHUNK, enum sctp_cid, chunk) SCTP_SUBTYPE_CONSTRUCTOR(CHUNK, enum sctp_cid, chunk)
SCTP_SUBTYPE_CONSTRUCTOR(TIMEOUT, enum sctp_event_timeout, timeout) SCTP_SUBTYPE_CONSTRUCTOR(TIMEOUT, enum sctp_event_timeout, timeout)
...@@ -220,10 +220,10 @@ enum sctp_sock_state { ...@@ -220,10 +220,10 @@ enum sctp_sock_state {
}; };
/* These functions map various type to printable names. */ /* These functions map various type to printable names. */
const char *sctp_cname(const sctp_subtype_t); /* chunk types */ const char *sctp_cname(const union sctp_subtype id); /* chunk types */
const char *sctp_oname(const sctp_subtype_t); /* other events */ const char *sctp_oname(const union sctp_subtype id); /* other events */
const char *sctp_tname(const sctp_subtype_t); /* timeouts */ const char *sctp_tname(const union sctp_subtype id); /* timeouts */
const char *sctp_pname(const sctp_subtype_t); /* primitives */ const char *sctp_pname(const union sctp_subtype id); /* primitives */
/* This is a table of printable names of sctp_state_t's. */ /* This is a table of printable names of sctp_state_t's. */
extern const char *const sctp_state_tbl[]; extern const char *const sctp_state_tbl[];
......
...@@ -73,7 +73,7 @@ typedef struct { ...@@ -73,7 +73,7 @@ typedef struct {
typedef sctp_disposition_t (sctp_state_fn_t) (struct net *, typedef sctp_disposition_t (sctp_state_fn_t) (struct net *,
const struct sctp_endpoint *, const struct sctp_endpoint *,
const struct sctp_association *, const struct sctp_association *,
const sctp_subtype_t type, const union sctp_subtype type,
void *arg, void *arg,
sctp_cmd_seq_t *); sctp_cmd_seq_t *);
typedef void (sctp_timer_event_t) (unsigned long); typedef void (sctp_timer_event_t) (unsigned long);
...@@ -175,10 +175,11 @@ sctp_state_fn_t sctp_sf_autoclose_timer_expire; ...@@ -175,10 +175,11 @@ sctp_state_fn_t sctp_sf_autoclose_timer_expire;
/* Prototypes for utility support functions. */ /* Prototypes for utility support functions. */
__u8 sctp_get_chunk_type(struct sctp_chunk *chunk); __u8 sctp_get_chunk_type(struct sctp_chunk *chunk);
const sctp_sm_table_entry_t *sctp_sm_lookup_event(struct net *net, const sctp_sm_table_entry_t *sctp_sm_lookup_event(
enum sctp_event event_type, struct net *net,
enum sctp_state state, enum sctp_event event_type,
sctp_subtype_t event_subtype); enum sctp_state state,
union sctp_subtype event_subtype);
int sctp_chunk_iif(const struct sctp_chunk *); int sctp_chunk_iif(const struct sctp_chunk *);
struct sctp_association *sctp_make_temp_asoc(const struct sctp_endpoint *, struct sctp_association *sctp_make_temp_asoc(const struct sctp_endpoint *,
struct sctp_chunk *, struct sctp_chunk *,
...@@ -313,7 +314,7 @@ struct sctp_chunk *sctp_process_strreset_resp( ...@@ -313,7 +314,7 @@ struct sctp_chunk *sctp_process_strreset_resp(
/* Prototypes for statetable processing. */ /* Prototypes for statetable processing. */
int sctp_do_sm(struct net *net, enum sctp_event event_type, int sctp_do_sm(struct net *net, enum sctp_event event_type,
sctp_subtype_t subtype, enum sctp_state state, union sctp_subtype subtype, enum sctp_state state,
struct sctp_endpoint *ep, struct sctp_association *asoc, struct sctp_endpoint *ep, struct sctp_association *asoc,
void *event_arg, gfp_t gfp); void *event_arg, gfp_t gfp);
......
...@@ -1021,11 +1021,11 @@ static void sctp_assoc_bh_rcv(struct work_struct *work) ...@@ -1021,11 +1021,11 @@ static void sctp_assoc_bh_rcv(struct work_struct *work)
container_of(work, struct sctp_association, container_of(work, struct sctp_association,
base.inqueue.immediate); base.inqueue.immediate);
struct net *net = sock_net(asoc->base.sk); struct net *net = sock_net(asoc->base.sk);
union sctp_subtype subtype;
struct sctp_endpoint *ep; struct sctp_endpoint *ep;
struct sctp_chunk *chunk; struct sctp_chunk *chunk;
struct sctp_inq *inqueue; struct sctp_inq *inqueue;
int state; int state;
sctp_subtype_t subtype;
int error = 0; int error = 0;
/* The association should be held so we should be safe. */ /* The association should be held so we should be safe. */
......
...@@ -60,7 +60,7 @@ static const char *const sctp_cid_tbl[SCTP_NUM_BASE_CHUNK_TYPES] = { ...@@ -60,7 +60,7 @@ static const char *const sctp_cid_tbl[SCTP_NUM_BASE_CHUNK_TYPES] = {
}; };
/* Lookup "chunk type" debug name. */ /* Lookup "chunk type" debug name. */
const char *sctp_cname(const sctp_subtype_t cid) const char *sctp_cname(const union sctp_subtype cid)
{ {
if (cid.chunk <= SCTP_CID_BASE_MAX) if (cid.chunk <= SCTP_CID_BASE_MAX)
return sctp_cid_tbl[cid.chunk]; return sctp_cid_tbl[cid.chunk];
...@@ -130,7 +130,7 @@ static const char *const sctp_primitive_tbl[SCTP_NUM_PRIMITIVE_TYPES] = { ...@@ -130,7 +130,7 @@ static const char *const sctp_primitive_tbl[SCTP_NUM_PRIMITIVE_TYPES] = {
}; };
/* Lookup primitive debug name. */ /* Lookup primitive debug name. */
const char *sctp_pname(const sctp_subtype_t id) const char *sctp_pname(const union sctp_subtype id)
{ {
if (id.primitive <= SCTP_EVENT_PRIMITIVE_MAX) if (id.primitive <= SCTP_EVENT_PRIMITIVE_MAX)
return sctp_primitive_tbl[id.primitive]; return sctp_primitive_tbl[id.primitive];
...@@ -143,7 +143,7 @@ static const char *const sctp_other_tbl[] = { ...@@ -143,7 +143,7 @@ static const char *const sctp_other_tbl[] = {
}; };
/* Lookup "other" debug name. */ /* Lookup "other" debug name. */
const char *sctp_oname(const sctp_subtype_t id) const char *sctp_oname(const union sctp_subtype id)
{ {
if (id.other <= SCTP_EVENT_OTHER_MAX) if (id.other <= SCTP_EVENT_OTHER_MAX)
return sctp_other_tbl[id.other]; return sctp_other_tbl[id.other];
...@@ -165,7 +165,7 @@ static const char *const sctp_timer_tbl[] = { ...@@ -165,7 +165,7 @@ static const char *const sctp_timer_tbl[] = {
}; };
/* Lookup timer debug name. */ /* Lookup timer debug name. */
const char *sctp_tname(const sctp_subtype_t id) const char *sctp_tname(const union sctp_subtype id)
{ {
BUILD_BUG_ON(SCTP_EVENT_TIMEOUT_MAX + 1 != ARRAY_SIZE(sctp_timer_tbl)); BUILD_BUG_ON(SCTP_EVENT_TIMEOUT_MAX + 1 != ARRAY_SIZE(sctp_timer_tbl));
......
...@@ -382,7 +382,7 @@ static void sctp_endpoint_bh_rcv(struct work_struct *work) ...@@ -382,7 +382,7 @@ static void sctp_endpoint_bh_rcv(struct work_struct *work)
struct sctp_transport *transport; struct sctp_transport *transport;
struct sctp_chunk *chunk; struct sctp_chunk *chunk;
struct sctp_inq *inqueue; struct sctp_inq *inqueue;
sctp_subtype_t subtype; union sctp_subtype subtype;
enum sctp_state state; enum sctp_state state;
int error = 0; int error = 0;
int first_time = 1; /* is this the first time through the loop */ int first_time = 1; /* is this the first time through the loop */
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
int sctp_primitive_ ## name(struct net *net, struct sctp_association *asoc, \ int sctp_primitive_ ## name(struct net *net, struct sctp_association *asoc, \
void *arg) { \ void *arg) { \
int error = 0; \ int error = 0; \
enum sctp_event event_type; sctp_subtype_t subtype; \ enum sctp_event event_type; union sctp_subtype subtype; \
enum sctp_state state; \ enum sctp_state state; \
struct sctp_endpoint *ep; \ struct sctp_endpoint *ep; \
\ \
......
...@@ -130,7 +130,7 @@ static const struct file_operations sctpprobe_fops = { ...@@ -130,7 +130,7 @@ static const struct file_operations sctpprobe_fops = {
static sctp_disposition_t jsctp_sf_eat_sack(struct net *net, static sctp_disposition_t jsctp_sf_eat_sack(struct net *net,
const struct sctp_endpoint *ep, const struct sctp_endpoint *ep,
const struct sctp_association *asoc, const struct sctp_association *asoc,
const sctp_subtype_t type, const union sctp_subtype type,
void *arg, void *arg,
sctp_cmd_seq_t *commands) sctp_cmd_seq_t *commands)
{ {
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
#include <net/sctp/sm.h> #include <net/sctp/sm.h>
static int sctp_cmd_interpreter(enum sctp_event event_type, static int sctp_cmd_interpreter(enum sctp_event event_type,
sctp_subtype_t subtype, union sctp_subtype subtype,
enum sctp_state state, enum sctp_state state,
struct sctp_endpoint *ep, struct sctp_endpoint *ep,
struct sctp_association *asoc, struct sctp_association *asoc,
...@@ -60,7 +60,8 @@ static int sctp_cmd_interpreter(enum sctp_event event_type, ...@@ -60,7 +60,8 @@ static int sctp_cmd_interpreter(enum sctp_event event_type,
sctp_disposition_t status, sctp_disposition_t status,
sctp_cmd_seq_t *commands, sctp_cmd_seq_t *commands,
gfp_t gfp); gfp_t gfp);
static int sctp_side_effects(enum sctp_event event_type, sctp_subtype_t subtype, static int sctp_side_effects(enum sctp_event event_type,
union sctp_subtype subtype,
enum sctp_state state, enum sctp_state state,
struct sctp_endpoint *ep, struct sctp_endpoint *ep,
struct sctp_association **asoc, struct sctp_association **asoc,
...@@ -603,7 +604,7 @@ static void sctp_cmd_init_failed(sctp_cmd_seq_t *commands, ...@@ -603,7 +604,7 @@ static void sctp_cmd_init_failed(sctp_cmd_seq_t *commands,
static void sctp_cmd_assoc_failed(sctp_cmd_seq_t *commands, static void sctp_cmd_assoc_failed(sctp_cmd_seq_t *commands,
struct sctp_association *asoc, struct sctp_association *asoc,
enum sctp_event event_type, enum sctp_event event_type,
sctp_subtype_t subtype, union sctp_subtype subtype,
struct sctp_chunk *chunk, struct sctp_chunk *chunk,
unsigned int error) unsigned int error)
{ {
...@@ -1140,7 +1141,7 @@ static void sctp_cmd_send_asconf(struct sctp_association *asoc) ...@@ -1140,7 +1141,7 @@ static void sctp_cmd_send_asconf(struct sctp_association *asoc)
* good place to start. * good place to start.
*/ */
int sctp_do_sm(struct net *net, enum sctp_event event_type, int sctp_do_sm(struct net *net, enum sctp_event event_type,
sctp_subtype_t subtype, enum sctp_state state, union sctp_subtype subtype, enum sctp_state state,
struct sctp_endpoint *ep, struct sctp_association *asoc, struct sctp_endpoint *ep, struct sctp_association *asoc,
void *event_arg, gfp_t gfp) void *event_arg, gfp_t gfp)
{ {
...@@ -1148,7 +1149,7 @@ int sctp_do_sm(struct net *net, enum sctp_event event_type, ...@@ -1148,7 +1149,7 @@ int sctp_do_sm(struct net *net, enum sctp_event event_type,
const sctp_sm_table_entry_t *state_fn; const sctp_sm_table_entry_t *state_fn;
sctp_disposition_t status; sctp_disposition_t status;
int error = 0; int error = 0;
typedef const char *(printfn_t)(sctp_subtype_t); typedef const char *(printfn_t)(union sctp_subtype);
static printfn_t *table[] = { static printfn_t *table[] = {
NULL, sctp_cname, sctp_tname, sctp_oname, sctp_pname, NULL, sctp_cname, sctp_tname, sctp_oname, sctp_pname,
}; };
...@@ -1176,7 +1177,8 @@ int sctp_do_sm(struct net *net, enum sctp_event event_type, ...@@ -1176,7 +1177,8 @@ int sctp_do_sm(struct net *net, enum sctp_event event_type,
/***************************************************************** /*****************************************************************
* This the master state function side effect processing function. * This the master state function side effect processing function.
*****************************************************************/ *****************************************************************/
static int sctp_side_effects(enum sctp_event event_type, sctp_subtype_t subtype, static int sctp_side_effects(enum sctp_event event_type,
union sctp_subtype subtype,
enum sctp_state state, enum sctp_state state,
struct sctp_endpoint *ep, struct sctp_endpoint *ep,
struct sctp_association **asoc, struct sctp_association **asoc,
...@@ -1262,7 +1264,7 @@ static int sctp_side_effects(enum sctp_event event_type, sctp_subtype_t subtype, ...@@ -1262,7 +1264,7 @@ static int sctp_side_effects(enum sctp_event event_type, sctp_subtype_t subtype,
/* This is the side-effect interpreter. */ /* This is the side-effect interpreter. */
static int sctp_cmd_interpreter(enum sctp_event event_type, static int sctp_cmd_interpreter(enum sctp_event event_type,
sctp_subtype_t subtype, union sctp_subtype subtype,
enum sctp_state state, enum sctp_state state,
struct sctp_endpoint *ep, struct sctp_endpoint *ep,
struct sctp_association *asoc, struct sctp_association *asoc,
......
This diff is collapsed.
...@@ -77,10 +77,11 @@ static const sctp_sm_table_entry_t bug = { ...@@ -77,10 +77,11 @@ static const sctp_sm_table_entry_t bug = {
rtn; \ rtn; \
}) })
const sctp_sm_table_entry_t *sctp_sm_lookup_event(struct net *net, const sctp_sm_table_entry_t *sctp_sm_lookup_event(
enum sctp_event event_type, struct net *net,
enum sctp_state state, enum sctp_event event_type,
sctp_subtype_t event_subtype) enum sctp_state state,
union sctp_subtype event_subtype)
{ {
switch (event_type) { switch (event_type) {
case SCTP_EVENT_T_CHUNK: case SCTP_EVENT_T_CHUNK:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment