staging: lustre: Replace typedef with struct
PATCH 1/1 staging: lustre: Replace typedef with struct
Using typedef for a structure type is not suggested in Linux kernel coding style guidelines. Hence, occurences of typedefs have been removed in the lib-types.h file. Grep was also used to ensure that all occurence of the typedefs have been removed. The module compiles without any warnings or errors.
Script 1:
@r1@
type T;
@@
typedef struct { ... } T;
@script:python c1@
T2;
T << r1.T;
@@
if T[-2:] =="_t":
coccinelle.T2 = T[:-2];
print T
else:
coccinelle.T2=T;
@r2@
type r1.T;
identifier c1.T2;
@@
-typedef
struct
+ T2
{ ... }
-T
;
@r3@
type r1.T;
identifier c1.T2;
@@
- T
+ struct T2
Script 2:
@@
typedef lnet_rc_data_t;
typedef lnet_remotenet_t;
typedef lnet_route_t;
typedef lnet_rtrbuf_t;
typedef lnet_rtrbufpool_t;
typedef lnet_test_peer_t;
@@
(
- lnet_rc_data_t
+ struct lnet_rc_data
|
- lnet_remotenet_t
+ struct lnet_remotenet
|
- lnet_route_t
+ struct lnet_route
|
- lnet_rtrbuf_t
+ struct lnet_rtrbuf
|
- lnet_rtrbufpool_t
+ struct lnet_rtrbufpool
|
- lnet_test_peer_t
+ struct lnet_test_peer
)
--- .../staging/lustre/include/linux/lnet/lib-lnet.h | 8 +- .../staging/lustre/include/linux/lnet/lib-types.h | 32 +++---- drivers/staging/lustre/lnet/lnet/api-ni.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-move.c | 48 +++++----- drivers/staging/lustre/lnet/lnet/router.c | 103 +++++++++++---------- drivers/staging/lustre/lnet/lnet/router_proc.c | 15 +-- 6 files changed, 106 insertions(+), 102 deletions(-)
drivers/staging/lustre/include/linux/lnet/lib-lnet.h +4 -4
@@ -65,7 +65,7 @@ extern lnet_t the_lnet; /* THE network *//** exclusive lock */ #define LNET_LOCK_EX CFS_PERCPT_LOCK_EX -static inline int lnet_is_route_alive (lnet_route_t *route) +static inline int lnet_is_route_alive (struct lnet_route *route) {/* gateway is down */ if (!route->lr_gateway->lp_alive)
@@ -468,12 +468,12 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg);void lnet_router_debugfs_init (void );void lnet_router_debugfs_fini (void );int lnet_rtrpools_alloc (int im_a_router); -void lnet_destroy_rtrbuf (lnet_rtrbuf_t *rb,int npages); +void lnet_destroy_rtrbuf (struct lnet_rtrbuf *rb,int npages);int lnet_rtrpools_adjust (int tiny,int small,int large);int lnet_rtrpools_enable (void );void lnet_rtrpools_disable (void );void lnet_rtrpools_free (int keep_pools); -lnet_remotenet_t *lnet_find_net_locked (__u32 net); +struct lnet_remotenet *lnet_find_net_locked (__u32 net);int lnet_dyn_add_ni (lnet_pid_t requested_pid,struct lnet_ioctl_config_data *conf);int lnet_dyn_del_ni (__u32 net);
@@ -496,7 +496,7 @@ void lnet_prep_send(lnet_msg_t *msg, int type, lnet_process_id_t target,int lnet_send (lnet_nid_t nid,lnet_msg_t *msg,lnet_nid_t rtr_nid);void lnet_return_tx_credits_locked (lnet_msg_t *msg);void lnet_return_rx_credits_locked (lnet_msg_t *msg); -void lnet_schedule_blocked_locked (lnet_rtrbufpool_t *rbp); +void lnet_schedule_blocked_locked (struct lnet_rtrbufpool *rbp);void lnet_drop_routed_msgs_locked (struct list_head *list,int cpt);/* portals functions */
drivers/staging/lustre/include/linux/lnet/lib-types.h +16 -16
@@ -164,12 +164,12 @@ typedef struct lnet_libmd {#define LNET_MD_FLAG_AUTO_UNLINK (1 << 1)#define LNET_MD_FLAG_ABORTED (1 << 2) -typedef struct { +struct lnet_test_peer {/* info about peers we are trying to fail */ struct list_head tp_list;/* ln_test_peers */ lnet_nid_t tp_nid;/* matching nid */ unsigned int tp_threshold;/* # failures to simulate */ -}lnet_test_peer_t ; +};#define LNET_COOKIE_TYPE_MD 1#define LNET_COOKIE_TYPE_ME 2
@@ -296,13 +296,13 @@ typedef struct lnet_ni {/* router checker data, per router */ #define LNET_MAX_RTR_NIS 16#define LNET_PINGINFO_SIZE offsetof(struct lnet_ping_info, pi_ni[LNET_MAX_RTR_NIS]) -typedef struct { +struct lnet_rc_data {/* chain on the_lnet.ln_zombie_rcd or ln_deathrow_rcd */ struct list_head rcd_list;lnet_handle_md_t rcd_mdh;/* ping buffer MD */ struct lnet_peer *rcd_gateway;/* reference to gateway */ struct lnet_ping_info *rcd_pinginfo;/* ping buffer */ -}lnet_rc_data_t ; +}; typedef struct lnet_peer { struct list_head lp_hashlist; /* chain on peer hash */
@@ -339,12 +339,12 @@ typedef struct lnet_peer {lnet_nid_t lp_nid;/* peer's NID */ int lp_refcount;/* # refs */ int lp_cpt;/* CPT this peer attached on */ -/* # refs from lnet_route_t::lr_gateway */ +/* # refs from struct lnet_route::lr_gateway */ int lp_rtr_refcount;/* returned RC ping features */ unsigned int lp_ping_feats;struct list_head lp_routes;/* routers on this peer */ -lnet_rc_data_t *lp_rcd;/* router checker state */ +struct lnet_rc_data *lp_rcd;/* router checker state */ } lnet_peer_t;/* peer hash size */
@@ -368,7 +368,7 @@ struct lnet_peer_table {#define lnet_peer_aliveness_enabled (lp) (the_lnet.ln_routing && \ (lp)->lp_ni->ni_peertimeout > 0) -typedef struct { +struct lnet_route {struct list_head lr_list;/* chain on net */ struct list_head lr_gwlist;/* chain on gateway */ lnet_peer_t *lr_gateway;/* router node */
@@ -377,25 +377,25 @@ typedef struct {unsigned int lr_downis;/* number of down NIs */ __u32 lr_hops;/* how far I am */ unsigned int lr_priority;/* route priority */ -} lnet_route_t; +};#define LNET_REMOTE_NETS_HASH_DEFAULT (1U << 7)#define LNET_REMOTE_NETS_HASH_MAX (1U << 16)#define LNET_REMOTE_NETS_HASH_SIZE (1 << the_lnet.ln_remote_nets_hbits) -typedef struct { +struct lnet_remotenet {struct list_head lrn_list;/* chain on ln_remote_nets_hash */ struct list_head lrn_routes;/* routes to me */ __u32 lrn_net;/* my net number */ -}lnet_remotenet_t ; +};/** lnet message has credit and can be submitted to lnd for send/receive */ #define LNET_CREDIT_OK 0/** lnet message is waiting for credit */ #define LNET_CREDIT_WAIT 1 -typedef struct { +struct lnet_rtrbufpool {struct list_head rbp_bufs;/* my free buffer pool */ struct list_head rbp_msgs;/* messages blocking for a buffer */
@@ -407,13 +407,13 @@ typedef struct {int rbp_credits;/* # free buffers / blocked messages */ int rbp_mincredits;/* low water mark */ -} lnet_rtrbufpool_t; +}; -typedef struct { +struct lnet_rtrbuf {struct list_head rb_list;/* chain on rbp_bufs */ -lnet_rtrbufpool_t *rb_pool;/* owning pool */ +struct lnet_rtrbufpool *rb_pool;/* owning pool */ lnet_kiov_t rb_kiov[0 ];/* the buffer space */ -}lnet_rtrbuf_t ; +};#define LNET_PEER_HASHSIZE 503/* prime! */
@@ -595,7 +595,7 @@ typedef struct {/* validity stamp */ __u64 ln_routers_version;/* percpt router buffer pools */ -lnet_rtrbufpool_t **ln_rtrpools; +struct lnet_rtrbufpool **ln_rtrpools;lnet_handle_md_t ln_ping_target_md;lnet_handle_eq_t ln_ping_target_eq;
drivers/staging/lustre/lnet/lnet/api-ni.c +1 -1
@@ -1758,7 +1758,7 @@ lnet_dyn_add_ni(lnet_pid_t requested_pid, struct lnet_ioctl_config_data *conf)lnet_handle_md_t md_handle;struct lnet_ni *ni;struct list_head net_head; -lnet_remotenet_t *rnet; +struct lnet_remotenet *rnet;int rc;INIT_LIST_HEAD (&net_head);
drivers/staging/lustre/lnet/lnet/lib-move.c +24 -24
136 lines not on this page · raw message
drivers/staging/lustre/lnet/lnet/router.c +53 -50
313 lines not on this page · raw message
drivers/staging/lustre/lnet/lnet/router_proc.c +8 -7
@@ -171,8 +171,8 @@ static int proc_lnet_routes(struct ctl_table *table, int write, }else {struct list_head *n;struct list_head *r; -lnet_route_t *route =NULL ; -lnet_remotenet_t *rnet =NULL ; +struct lnet_route *route =NULL ; +struct lnet_remotenet *rnet =NULL ;int skip = off -1 ;struct list_head *rn_list;int i;
@@ -191,14 +191,15 @@ static int proc_lnet_routes(struct ctl_table *table, int write, n = rn_list->next;while (n != rn_list && !route) { - rnet =list_entry (n, lnet_remotenet_t, + rnet = list_entry(n, struct lnet_remotenet, lrn_list); r = rnet->lrn_routes.next;while (r != &rnet->lrn_routes) { -lnet_route_t *re = -list_entry (r, lnet_route_t, +struct lnet_route *re = +list_entry (r, + struct lnet_route, lr_list);if (!skip) { route = re;
@@ -331,7 +332,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,int last_ping =cfs_duration_sec (cfs_time_sub (now, peer->lp_ping_timestamp));int down_ni =0 ; -lnet_route_t *rtr; +struct lnet_route *rtr;if ((peer->lp_ping_feats &LNET_PING_FEAT_NI_STATUS )) {
@@ -589,7 +590,7 @@ static int __proc_lnet_buffers(void *data, int write, goto out;/* I'm not a router */ for (idx =0 ; idx <LNET_NRBPOOLS ; idx++) { -lnet_rtrbufpool_t *rbp; +struct lnet_rtrbufpool *rbp;lnet_net_lock (LNET_LOCK_EX );cfs_percpt_for_each (rbp, i, the_lnet.ln_rtrpools) {
Signature · 1 line
2.7.4
Greg KH
maintainerQuoted 60 lines · Gargi Sharma
Using typedef for a structure type is not suggested in Linux kernel coding style guidelines. Hence, occurences of typedefs have been removed in the
lib-types.hfile. Grep was also used to ensure that all occurence of the typedefs have been removed. The module compiles without any warnings or errors.Script 1:
@r1@
type T;
@@typedef struct { ... } T;
@script:python c1@
T2;
T << r1.T;
@@
if T[-2:] =="_t":
coccinelle.T2 = T[:-2];
print T
else:
coccinelle.T2=T;@r2@
type r1.T;
identifier c1.T2;
@@
-typedef
struct
+ T2
{ ... }
-T
;@r3@
type r1.T;
identifier c1.T2;
@@
- T
+ struct T2Script 2:
@@
typedeflnet_rc_data_t;
typedeflnet_remotenet_t;
typedeflnet_route_t;
typedeflnet_rtrbuf_t;
typedeflnet_rtrbufpool_t;
typedeflnet_test_peer_t;
@@
(
-lnet_rc_data_t
+ structlnet_rc_data
|
-lnet_remotenet_t
+ structlnet_remotenet
|
-lnet_route_t
+ structlnet_route
|
Quoted 8 lines
-
lnet_rtrbuf_t
+ structlnet_rtrbuf
|
-lnet_rtrbufpool_t
+ structlnet_rtrbufpool
|
-lnet_test_peer_t
+ structlnet_test_peer
Please only search/replace one typedef at a time, to make it easier (actually, possible) to review.
That's the way other typedefs were fixed up in this code base, please always look at the history to make sure you do things the same way.
thanks,
greg k-h