Skip to contentSkip to conversation

staging: lustre: lnet: Replace typedef with struct

PATCH In review Bhaktipriya Shridhar 2 participants 3 messages Feb 27, 2016 – Mar 2, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: lustre: lnet: Replace typedef with struct

As per the Linux kernel coding style guidelines, using typedef for a structure type is not recommended. Hence, occurences of typedefs have been removed.

This was done with Coccinelle.

@r1@
type T;
@@

typedef struct { ... } T;

@script:python c1@
T2;
T << r1.T;
@@
coccinelle.T2 = T;

@@
type r1.T;
identifier c1.T2;
@@
-typedef
struct
+ T2
{ ... }
-T
;
@@ type r1.T;
identifier c1.T2;
@@
-T
+ struct T2

The '_t' suffix has not been removed since there is a variable with the same name.

---
Changes in v2:
-Fixed typo "lusture" to "lustre" in the subject

 drivers/staging/lustre/lnet/selftest/ping_test.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/lustre/lnet/selftest/ping_test.c +3 -3
index 9d27e39..617a641 100644
@@ -48,12 +48,12 @@ static int ping_srv_workitems = SFW_TEST_WI_MAX;
 module_param(ping_srv_workitems, int, 0644);
 MODULE_PARM_DESC(ping_srv_workitems, "# PING server workitems");
 
-typedef struct {
+struct lst_ping_data_t {
 	spinlock_t	pnd_lock;	/* serialize */
 	int		pnd_counter;	/* sequence counter */
-} lst_ping_data_t;
+};
 
-static lst_ping_data_t  lst_ping_data;
+static struct lst_ping_data_t  lst_ping_data;
 
 static int
 ping_client_init(sfw_test_instance_t *tsi)

--
2.1.4

maintainer
#1 lore raw
Quoted 50 lines · Bhaktipriya Shridhar

As per the Linux kernel coding style guidelines, using typedef for a structure type is not recommended. Hence, occurences of typedefs have been removed.

This was done with Coccinelle.

@r1@
type T;
@@

typedef struct { ... } T;

@script:python c1@
T2;
T << r1.T;
@@
coccinelle.T2 = T;

@@
type r1.T;
identifier c1.T2;
@@
-typedef
struct
+ T2
{ ... }
-T
;
@@ type r1.T;
identifier c1.T2;
@@
-T
+ struct T2

The '_t' suffix has not been removed since there is a variable with the same name.

---
Changes in v2:
-Fixed typo "lusture" to "lustre" in the subject

 drivers/staging/lustre/lnet/selftest/ping_test.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/lustre/lnet/selftest/ping_test.c +0 -0
index 9d27e39..617a641 100644

drivers/staging/lustre/lnet/selftest/ping_test.c static int ping_srv_workitems = SFW_TEST_WI_MAX; · line 51

Quoted 5 lines
drivers/staging/lustre/lnet/selftest/ping_test.c +1 -1
@@ -48,12 +48,12 @@ static int ping_srv_workitems = SFW_TEST_WI_MAX;
 module_param(ping_srv_workitems, int, 0644);
 MODULE_PARM_DESC(ping_srv_workitems, "# PING server workitems");
 
-typedef struct {
+struct lst_ping_data_t {

Don't put "_t" at the end of a typedef :(

maintainer
#2 lore raw
In reply to Bhaktipriya Shridhar
Quoted 50 lines · Bhaktipriya Shridhar

As per the Linux kernel coding style guidelines, using typedef for a structure type is not recommended. Hence, occurences of typedefs have been removed.

This was done with Coccinelle.

@r1@
type T;
@@

typedef struct { ... } T;

@script:python c1@
T2;
T << r1.T;
@@
coccinelle.T2 = T;

@@
type r1.T;
identifier c1.T2;
@@
-typedef
struct
+ T2
{ ... }
-T
;
@@ type r1.T;
identifier c1.T2;
@@
-T
+ struct T2

The '_t' suffix has not been removed since there is a variable with the same name.

---
Changes in v2:
-Fixed typo "lusture" to "lustre" in the subject

 drivers/staging/lustre/lnet/selftest/ping_test.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/lustre/lnet/selftest/ping_test.c +0 -0
index 9d27e39..617a641 100644

drivers/staging/lustre/lnet/selftest/ping_test.c static int ping_srv_workitems = SFW_TEST_WI_MAX; · line 51

Quoted 5 lines
drivers/staging/lustre/lnet/selftest/ping_test.c +1 -1
@@ -48,12 +48,12 @@ static int ping_srv_workitems = SFW_TEST_WI_MAX;
 module_param(ping_srv_workitems, int, 0644);
 MODULE_PARM_DESC(ping_srv_workitems, "# PING server workitems");
 
-typedef struct {
+struct lst_ping_data_t {

Don't put "_t" at the end of a typedef :(