Re: [PATCH net-next 03/14] sctp: remove the typedef sctp_scope_policy_t
On Mon, Aug 7, 2017 at 9:28 PM, David Laightwrote: > From: Xin Long >> Sent: 05 August 2017 13:00 >> This patch is to remove the typedef sctp_scope_policy_t and keep >> it's members as an anonymous enum. >> >> It is also to define SCTP_SCOPE_POLICY_MAX to replace the num 3 >> in sysctl.c to make codes clear. >> >> Signed-off-by: Xin Long >> --- >> include/net/sctp/constants.h | 6 -- >> net/sctp/sysctl.c| 2 +- >> 2 files changed, 5 insertions(+), 3 deletions(-) >> >> diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h >> index 922fba5..acb03eb 100644 >> --- a/include/net/sctp/constants.h >> +++ b/include/net/sctp/constants.h >> @@ -341,12 +341,14 @@ typedef enum { >> SCTP_SCOPE_UNUSABLE,/* IPv4 unusable addresses */ >> } sctp_scope_t; >> >> -typedef enum { >> +enum { >> SCTP_SCOPE_POLICY_DISABLE, /* Disable IPv4 address scoping */ >> SCTP_SCOPE_POLICY_ENABLE, /* Enable IPv4 address scoping */ >> SCTP_SCOPE_POLICY_PRIVATE, /* Follow draft but allow IPv4 private >> addresses */ >> SCTP_SCOPE_POLICY_LINK, /* Follow draft but allow IPv4 link >> local addresses */ >> -} sctp_scope_policy_t; >> +}; >> + >> +#define SCTP_SCOPE_POLICY_MAXSCTP_SCOPE_POLICY_LINK > > Perhaps slightly better to end the enum with: > SCTP_SCOPE_POLICY_COUNT,/* Number of policies */ > SCTP_SCOPE_POLICY_MAX = SCTP_SCOPE_POLICY_COUNT - 1 /* Last > policy */ > }; It might be, so that new member coming will not change too much. I just copied the idea of SCTP_EVENT__MAX, SCTP_STATE_MAX :-)
RE: [PATCH net-next 03/14] sctp: remove the typedef sctp_scope_policy_t
From: Xin Long > Sent: 05 August 2017 13:00 > This patch is to remove the typedef sctp_scope_policy_t and keep > it's members as an anonymous enum. > > It is also to define SCTP_SCOPE_POLICY_MAX to replace the num 3 > in sysctl.c to make codes clear. > > Signed-off-by: Xin Long> --- > include/net/sctp/constants.h | 6 -- > net/sctp/sysctl.c| 2 +- > 2 files changed, 5 insertions(+), 3 deletions(-) > > diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h > index 922fba5..acb03eb 100644 > --- a/include/net/sctp/constants.h > +++ b/include/net/sctp/constants.h > @@ -341,12 +341,14 @@ typedef enum { > SCTP_SCOPE_UNUSABLE,/* IPv4 unusable addresses */ > } sctp_scope_t; > > -typedef enum { > +enum { > SCTP_SCOPE_POLICY_DISABLE, /* Disable IPv4 address scoping */ > SCTP_SCOPE_POLICY_ENABLE, /* Enable IPv4 address scoping */ > SCTP_SCOPE_POLICY_PRIVATE, /* Follow draft but allow IPv4 private > addresses */ > SCTP_SCOPE_POLICY_LINK, /* Follow draft but allow IPv4 link > local addresses */ > -} sctp_scope_policy_t; > +}; > + > +#define SCTP_SCOPE_POLICY_MAXSCTP_SCOPE_POLICY_LINK Perhaps slightly better to end the enum with: SCTP_SCOPE_POLICY_COUNT,/* Number of policies */ SCTP_SCOPE_POLICY_MAX = SCTP_SCOPE_POLICY_COUNT - 1 /* Last policy */ }; David
[PATCH net-next 03/14] sctp: remove the typedef sctp_scope_policy_t
This patch is to remove the typedef sctp_scope_policy_t and keep it's members as an anonymous enum. It is also to define SCTP_SCOPE_POLICY_MAX to replace the num 3 in sysctl.c to make codes clear. Signed-off-by: Xin Long--- include/net/sctp/constants.h | 6 -- net/sctp/sysctl.c| 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h index 922fba5..acb03eb 100644 --- a/include/net/sctp/constants.h +++ b/include/net/sctp/constants.h @@ -341,12 +341,14 @@ typedef enum { SCTP_SCOPE_UNUSABLE,/* IPv4 unusable addresses */ } sctp_scope_t; -typedef enum { +enum { SCTP_SCOPE_POLICY_DISABLE, /* Disable IPv4 address scoping */ SCTP_SCOPE_POLICY_ENABLE, /* Enable IPv4 address scoping */ SCTP_SCOPE_POLICY_PRIVATE, /* Follow draft but allow IPv4 private addresses */ SCTP_SCOPE_POLICY_LINK, /* Follow draft but allow IPv4 link local addresses */ -} sctp_scope_policy_t; +}; + +#define SCTP_SCOPE_POLICY_MAX SCTP_SCOPE_POLICY_LINK /* Based on IPv4 scoping , * SCTP IPv4 unusable addresses: 0.0.0.0/8, 224.0.0.0/4, 198.18.0.0/24, diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c index 0e732f6..ef7ca44 100644 --- a/net/sctp/sysctl.c +++ b/net/sctp/sysctl.c @@ -46,7 +46,7 @@ static int timer_max = 8640; /* ms in one day */ static int int_max = INT_MAX; static int sack_timer_min = 1; static int sack_timer_max = 500; -static int addr_scope_max = 3; /* check sctp_scope_policy_t in include/net/sctp/constants.h for max entries */ +static int addr_scope_max = SCTP_SCOPE_POLICY_MAX; static int rwnd_scale_max = 16; static int rto_alpha_min = 0; static int rto_beta_min = 0; -- 2.1.0