[PATCH] netfilter: h323: Remove typedefs from structs
This patch does away with typedefs field_t and bitstr_t as they are unnecessary. Also the names of the structs are changed to drop the _t, to make the names look less typedef-like. The following Coccinelle semantic patch detects the case. @tn@ identifier i; type td; @@ -typedef struct i { ... } -td ; @@ type tn.td; identifier tn.i; @@ -td + struct i Signed-off-by: Himangi Saraogi Acked-by: Julia Lawall --- net/netfilter/nf_conntrack_h323_asn1.c | 110 +- net/netfilter/nf_conntrack_h323_types.c | 346 2 files changed, 234 insertions(+), 222 deletions(-) diff --git a/net/netfilter/nf_conntrack_h323_asn1.c b/net/netfilter/nf_conntrack_h323_asn1.c index bcd5ed6..deeb368 100644 --- a/net/netfilter/nf_conntrack_h323_asn1.c +++ b/net/netfilter/nf_conntrack_h323_asn1.c @@ -77,7 +77,7 @@ /* ASN.1 Field Structure */ -typedef struct field_t { +struct field { #if H323_TRACE char *name; #endif @@ -87,45 +87,57 @@ typedef struct field_t { unsigned char ub; unsigned short attr; unsigned short offset; - const struct field_t *fields; -} field_t; + const struct field *fields; +}; /* Bit Stream */ -typedef struct { +struct bitstr { unsigned char *buf; unsigned char *beg; unsigned char *end; unsigned char *cur; unsigned int bit; -} bitstr_t; +}; /* Tool Functions */ #define INC_BIT(bs) if((++(bs)->bit)>7){(bs)->cur++;(bs)->bit=0;} #define INC_BITS(bs,b) if(((bs)->bit+=(b))>7){(bs)->cur+=(bs)->bit>>3;(bs)->bit&=7;} #define BYTE_ALIGN(bs) if((bs)->bit){(bs)->cur++;(bs)->bit=0;} #define CHECK_BOUND(bs,n) if((bs)->cur+(n)>(bs)->end)return(H323_ERROR_BOUND) -static unsigned int get_len(bitstr_t *bs); -static unsigned int get_bit(bitstr_t *bs); -static unsigned int get_bits(bitstr_t *bs, unsigned int b); -static unsigned int get_bitmap(bitstr_t *bs, unsigned int b); -static unsigned int get_uint(bitstr_t *bs, int b); +static unsigned int get_len(struct bitstr *bs); +static unsigned int get_bit(struct bitstr *bs); +static unsigned int get_bits(struct bitstr *bs, unsigned int b); +static unsigned int get_bitmap(struct bitstr *bs, unsigned int b); +static unsigned int get_uint(struct bitstr *bs, int b); /* Decoder Functions */ -static int decode_nul(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_bool(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_oid(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_int(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_enum(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_bitstr(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_numstr(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_octstr(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_bmpstr(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_seq(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_seqof(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_choice(bitstr_t *bs, const struct field_t *f, char *base, int level); +static int decode_nul(struct bitstr *bs, const struct field *f, char *base, + int level); +static int decode_bool(struct bitstr *bs, const struct field *f, char *base, + int level); +static int decode_oid(struct bitstr *bs, const struct field *f, char *base, + int level); +static int decode_int(struct bitstr *bs, const struct field *f, char *base, + int level); +static int decode_enum(struct bitstr *bs, const struct field *f, char *base, + int level); +static int decode_bitstr(struct bitstr *bs, const struct field *f, char *base, +int level); +static int decode_numstr(struct bitstr *bs, const struct field *f, char *base, +int level); +static int decode_octstr(struct bitstr *bs, const struct field *f, char *base, +int level); +static int decode_bmpstr(struct bitstr *bs, const struct field *f, char *base, +int level); +static int decode_seq(struct bitstr *bs, const struct field *f, char *base, + int level); +static int decode_seqof(struct bitstr *bs, const struct field *f, char *base, + int level); +static int decode_choice(struct bitstr *bs, const struct field *f, char *base, +int level); /* Decoder Functions Vector */ -typedef int (*decoder_t)(bitstr_t *, const struct field_t *, char *, int); +typedef int (*decoder_t)(struct bitstr *, const struct field *, char *, int); static const decoder_t Decoders[] = { decode_nul, decode_bool,
[PATCH] netfilter: h323: Remove typedefs from structs
This patch does away with typedefs field_t and bitstr_t as they are unnecessary. Also the names of the structs are changed to drop the _t, to make the names look less typedef-like. The following Coccinelle semantic patch detects the case. @tn@ identifier i; type td; @@ -typedef struct i { ... } -td ; @@ type tn.td; identifier tn.i; @@ -td + struct i Signed-off-by: Himangi Saraogi himangi...@gmail.com Acked-by: Julia Lawall julia.law...@lip6.fr --- net/netfilter/nf_conntrack_h323_asn1.c | 110 +- net/netfilter/nf_conntrack_h323_types.c | 346 2 files changed, 234 insertions(+), 222 deletions(-) diff --git a/net/netfilter/nf_conntrack_h323_asn1.c b/net/netfilter/nf_conntrack_h323_asn1.c index bcd5ed6..deeb368 100644 --- a/net/netfilter/nf_conntrack_h323_asn1.c +++ b/net/netfilter/nf_conntrack_h323_asn1.c @@ -77,7 +77,7 @@ /* ASN.1 Field Structure */ -typedef struct field_t { +struct field { #if H323_TRACE char *name; #endif @@ -87,45 +87,57 @@ typedef struct field_t { unsigned char ub; unsigned short attr; unsigned short offset; - const struct field_t *fields; -} field_t; + const struct field *fields; +}; /* Bit Stream */ -typedef struct { +struct bitstr { unsigned char *buf; unsigned char *beg; unsigned char *end; unsigned char *cur; unsigned int bit; -} bitstr_t; +}; /* Tool Functions */ #define INC_BIT(bs) if((++(bs)-bit)7){(bs)-cur++;(bs)-bit=0;} #define INC_BITS(bs,b) if(((bs)-bit+=(b))7){(bs)-cur+=(bs)-bit3;(bs)-bit=7;} #define BYTE_ALIGN(bs) if((bs)-bit){(bs)-cur++;(bs)-bit=0;} #define CHECK_BOUND(bs,n) if((bs)-cur+(n)(bs)-end)return(H323_ERROR_BOUND) -static unsigned int get_len(bitstr_t *bs); -static unsigned int get_bit(bitstr_t *bs); -static unsigned int get_bits(bitstr_t *bs, unsigned int b); -static unsigned int get_bitmap(bitstr_t *bs, unsigned int b); -static unsigned int get_uint(bitstr_t *bs, int b); +static unsigned int get_len(struct bitstr *bs); +static unsigned int get_bit(struct bitstr *bs); +static unsigned int get_bits(struct bitstr *bs, unsigned int b); +static unsigned int get_bitmap(struct bitstr *bs, unsigned int b); +static unsigned int get_uint(struct bitstr *bs, int b); /* Decoder Functions */ -static int decode_nul(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_bool(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_oid(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_int(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_enum(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_bitstr(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_numstr(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_octstr(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_bmpstr(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_seq(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_seqof(bitstr_t *bs, const struct field_t *f, char *base, int level); -static int decode_choice(bitstr_t *bs, const struct field_t *f, char *base, int level); +static int decode_nul(struct bitstr *bs, const struct field *f, char *base, + int level); +static int decode_bool(struct bitstr *bs, const struct field *f, char *base, + int level); +static int decode_oid(struct bitstr *bs, const struct field *f, char *base, + int level); +static int decode_int(struct bitstr *bs, const struct field *f, char *base, + int level); +static int decode_enum(struct bitstr *bs, const struct field *f, char *base, + int level); +static int decode_bitstr(struct bitstr *bs, const struct field *f, char *base, +int level); +static int decode_numstr(struct bitstr *bs, const struct field *f, char *base, +int level); +static int decode_octstr(struct bitstr *bs, const struct field *f, char *base, +int level); +static int decode_bmpstr(struct bitstr *bs, const struct field *f, char *base, +int level); +static int decode_seq(struct bitstr *bs, const struct field *f, char *base, + int level); +static int decode_seqof(struct bitstr *bs, const struct field *f, char *base, + int level); +static int decode_choice(struct bitstr *bs, const struct field *f, char *base, +int level); /* Decoder Functions Vector */ -typedef int (*decoder_t)(bitstr_t *, const struct field_t *, char *, int); +typedef int (*decoder_t)(struct bitstr *, const struct field *, char *, int); static const decoder_t Decoders[] = {