Discussion:
[PATCH] xfs: Remove typedef xfs_uu_t
Himangi Saraogi
2014-08-06 14:13:43 UTC
Permalink
The Linux kernel coding style guidelines suggest not using typedefs
for structure types. This patch gets rid of the typedef for xfs_uu_t.
Also the names of the struct is changed to drop the _t, to make the
name look less typedef-like.

The following Coccinelle semantic patch detects the case.

@tn1@
type td;
@@

typedef struct { ... } td;

@script:python tf@
td << tn1.td;
tdres;
@@

coccinelle.tdres = td;

@@
type tn1.td;
identifier tf.tdres;
@@

-typedef
struct
+ tdres
{ ... }
-td
;

@@
type tn1.td;
identifier tf.tdres;
@@

(
-td
+ struct tdres
|
const
- td
+ struct tdres
)

Signed-off-by: Himangi Saraogi <***@gmail.com>
Acked-by: Julia Lawall <***@lip6.fr>
---
fs/xfs/uuid.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/uuid.c b/fs/xfs/uuid.c
index b83f76b..1f21d8f 100644
--- a/fs/xfs/uuid.c
+++ b/fs/xfs/uuid.c
@@ -18,13 +18,13 @@
#include <xfs.h>

/* IRIX interpretation of an uuid_t */
-typedef struct {
+struct xfs_uu {
__be32 uu_timelow;
__be16 uu_timemid;
__be16 uu_timehi;
__be16 uu_clockseq;
__be16 uu_node[3];
-} xfs_uu_t;
+};

/*
* uuid_getnodeuniq - obtain the node unique fields of a UUID.
@@ -35,7 +35,7 @@ typedef struct {
void
uuid_getnodeuniq(uuid_t *uuid, int fsid [2])
{
- xfs_uu_t *uup = (xfs_uu_t *)uuid;
+ struct xfs_uu *uup = (struct xfs_uu *)uuid;

fsid[0] = (be16_to_cpu(uup->uu_clockseq) << 16) |
be16_to_cpu(uup->uu_timemid);
--
1.9.1
Christoph Hellwig
2014-08-06 14:28:47 UTC
Permalink
Post by Himangi Saraogi
The Linux kernel coding style guidelines suggest not using typedefs
for structure types. This patch gets rid of the typedef for xfs_uu_t.
Also the names of the struct is changed to drop the _t, to make the
name look less typedef-like.
The right fix is to just kill the type, and read the values directly
from the uuid_t type using get_unaligned_be16.

Loading...