All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: lustre: Replace typedef with struct
@ 2017-02-28  5:23 Gargi Sharma
  2017-02-28  6:44 ` [Outreachy kernel] " Julia Lawall
  0 siblings, 1 reply; 5+ messages in thread
From: Gargi Sharma @ 2017-02-28  5:23 UTC (permalink / raw)
  To: outreachy-kernel
  Cc: gregkh, oleg.drokin, andreas.dilger, jsimmons, Gargi Sharma

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

Coccinelle script:

@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
;

Signed-off-by: Gargi Sharma <gs051095@gmail.com>
---
 drivers/staging/lustre/lustre/include/lustre_eacl.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_eacl.h b/drivers/staging/lustre/lustre/include/lustre_eacl.h
index 1e71a86..c198eda 100644
--- a/drivers/staging/lustre/lustre/include/lustre_eacl.h
+++ b/drivers/staging/lustre/lustre/include/lustre_eacl.h
@@ -49,17 +49,17 @@
 #include <linux/fs.h>
 #include <linux/posix_acl_xattr.h>
 
-typedef struct {
+struct ext_acl_xattr_entry {
 	__u16		   e_tag;
 	__u16		   e_perm;
 	__u32		   e_id;
 	__u32		   e_stat;
-} ext_acl_xattr_entry;
+};
 
-typedef struct {
-	__u32		   a_count;
-	ext_acl_xattr_entry     a_entries[0];
-} ext_acl_xattr_header;
+struct ext_acl_xattr_header {
+	__u32 a_count;
+	struct ext_acl_xattr_entry a_entries[0];
+};
 
 #define CFS_ACL_XATTR_SIZE(count, prefix) \
 	(sizeof(prefix ## _header) + (count) * sizeof(prefix ## _entry))
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Outreachy kernel] [PATCH] staging: lustre: Replace typedef with struct
  2017-02-28  5:23 [PATCH] staging: lustre: Replace typedef with struct Gargi Sharma
@ 2017-02-28  6:44 ` Julia Lawall
  2017-02-28  6:48   ` Gargi Sharma
  0 siblings, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2017-02-28  6:44 UTC (permalink / raw)
  To: Gargi Sharma
  Cc: outreachy-kernel, gregkh, oleg.drokin, andreas.dilger, jsimmons



On Tue, 28 Feb 2017, Gargi Sharma wrote:

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

You have only changed the type definitions and not any uses.  Were there
no uses?

julia

>
> Coccinelle script:
>
> @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
> ;
>
> Signed-off-by: Gargi Sharma <gs051095@gmail.com>
> ---
>  drivers/staging/lustre/lustre/include/lustre_eacl.h | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/staging/lustre/lustre/include/lustre_eacl.h b/drivers/staging/lustre/lustre/include/lustre_eacl.h
> index 1e71a86..c198eda 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_eacl.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_eacl.h
> @@ -49,17 +49,17 @@
>  #include <linux/fs.h>
>  #include <linux/posix_acl_xattr.h>
>
> -typedef struct {
> +struct ext_acl_xattr_entry {
>  	__u16		   e_tag;
>  	__u16		   e_perm;
>  	__u32		   e_id;
>  	__u32		   e_stat;
> -} ext_acl_xattr_entry;
> +};
>
> -typedef struct {
> -	__u32		   a_count;
> -	ext_acl_xattr_entry     a_entries[0];
> -} ext_acl_xattr_header;
> +struct ext_acl_xattr_header {
> +	__u32 a_count;
> +	struct ext_acl_xattr_entry a_entries[0];
> +};
>
>  #define CFS_ACL_XATTR_SIZE(count, prefix) \
>  	(sizeof(prefix ## _header) + (count) * sizeof(prefix ## _entry))
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1488259405-19730-1-git-send-email-gs051095%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Outreachy kernel] [PATCH] staging: lustre: Replace typedef with struct
  2017-02-28  6:44 ` [Outreachy kernel] " Julia Lawall
@ 2017-02-28  6:48   ` Gargi Sharma
  2017-02-28  6:52     ` Julia Lawall
  0 siblings, 1 reply; 5+ messages in thread
From: Gargi Sharma @ 2017-02-28  6:48 UTC (permalink / raw)
  To: Julia Lawall
  Cc: outreachy-kernel, Greg KH, oleg.drokin, andreas.dilger, jsimmons

[-- Attachment #1: Type: text/plain, Size: 3135 bytes --]

On Tue, Feb 28, 2017 at 12:14 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>
>
>
> On Tue, 28 Feb 2017, Gargi Sharma wrote:
>
> > As per the Linux kernel coding style guidelines, using typedef for a
> > structure type is not recommended. Hence, occurences of typedefs have
> > been removed.
>

> You have only changed the type definitions and not any uses.  Were there
> no uses?

I used grep for both the structures and did not find any uses. I also
compiled the
kernel after making these changes and it compiled without any
errors/warnings.

thanks,
gargi
>
> julia
>
> >
> > Coccinelle script:
> >
> > @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
> > ;
> >
> > Signed-off-by: Gargi Sharma <gs051095@gmail.com>
> > ---
> >  drivers/staging/lustre/lustre/include/lustre_eacl.h | 12 ++++++------
> >  1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/staging/lustre/lustre/include/lustre_eacl.h
b/drivers/staging/lustre/lustre/include/lustre_eacl.h
> > index 1e71a86..c198eda 100644
> > --- a/drivers/staging/lustre/lustre/include/lustre_eacl.h
> > +++ b/drivers/staging/lustre/lustre/include/lustre_eacl.h
> > @@ -49,17 +49,17 @@
> >  #include <linux/fs.h>
> >  #include <linux/posix_acl_xattr.h>
> >
> > -typedef struct {
> > +struct ext_acl_xattr_entry {
> >       __u16              e_tag;
> >       __u16              e_perm;
> >       __u32              e_id;
> >       __u32              e_stat;
> > -} ext_acl_xattr_entry;
> > +};
> >
> > -typedef struct {
> > -     __u32              a_count;
> > -     ext_acl_xattr_entry     a_entries[0];
> > -} ext_acl_xattr_header;
> > +struct ext_acl_xattr_header {
> > +     __u32 a_count;
> > +     struct ext_acl_xattr_entry a_entries[0];
> > +};
> >
> >  #define CFS_ACL_XATTR_SIZE(count, prefix) \
> >       (sizeof(prefix ## _header) + (count) * sizeof(prefix ## _entry))
> > --
> > 2.7.4
> >
> > --
> > You received this message because you are subscribed to the Google
Groups "outreachy-kernel" group.
> > To unsubscribe from this group and stop receiving emails from it, send
an email to outreachy-kernel+unsubscribe@googlegroups.com.
> > To post to this group, send email to outreachy-kernel@googlegroups.com.
> > To view this discussion on the web visit
https://groups.google.com/d/msgid/outreachy-kernel/1488259405-19730-1-git-send-email-gs051095%40gmail.com
.
> > For more options, visit https://groups.google.com/d/optout.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
"outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/outreachy-kernel/alpine.DEB.2.20.1702280744060.2078%40hadrien
.
> For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: Type: text/html, Size: 4763 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Outreachy kernel] [PATCH] staging: lustre: Replace typedef with struct
  2017-02-28  6:48   ` Gargi Sharma
@ 2017-02-28  6:52     ` Julia Lawall
  0 siblings, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2017-02-28  6:52 UTC (permalink / raw)
  To: Gargi Sharma
  Cc: Julia Lawall, outreachy-kernel, Greg KH, oleg.drokin,
	andreas.dilger, jsimmons

[-- Attachment #1: Type: text/plain, Size: 4151 bytes --]



On Tue, 28 Feb 2017, Gargi Sharma wrote:

> On Tue, Feb 28, 2017 at 12:14 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >
> >
> >
> > On Tue, 28 Feb 2017, Gargi Sharma wrote:
> >
> > > As per the Linux kernel coding style guidelines, using typedef for a
> > > structure type is not recommended. Hence, occurences of typedefs have
> > > been removed.
> >
> > You have only changed the type definitions and not any uses.  Were there
> > no uses?
> I used grep for both the structures and did not find any uses. I also
> compiled the
> kernel after making these changes and it compiled without any
> errors/warnings.

OK, it could be nice to mention this in the commit log, because it would
improve the reader's understanding of why the change is correct.

julia

>
> thanks,
> gargi
> >
> > julia
> >
> > >
> > > Coccinelle script:
> > >
> > > @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
> > > ;
> > >
> > > Signed-off-by: Gargi Sharma <gs051095@gmail.com>
> > > ---
> > >  drivers/staging/lustre/lustre/include/lustre_eacl.h | 12 ++++++------
> > >  1 file changed, 6 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/drivers/staging/lustre/lustre/include/lustre_eacl.h
> b/drivers/staging/lustre/lustre/include/lustre_eacl.h
> > > index 1e71a86..c198eda 100644
> > > --- a/drivers/staging/lustre/lustre/include/lustre_eacl.h
> > > +++ b/drivers/staging/lustre/lustre/include/lustre_eacl.h
> > > @@ -49,17 +49,17 @@
> > >  #include <linux/fs.h>
> > >  #include <linux/posix_acl_xattr.h>
> > >
> > > -typedef struct {
> > > +struct ext_acl_xattr_entry {
> > >       __u16              e_tag;
> > >       __u16              e_perm;
> > >       __u32              e_id;
> > >       __u32              e_stat;
> > > -} ext_acl_xattr_entry;
> > > +};
> > >
> > > -typedef struct {
> > > -     __u32              a_count;
> > > -     ext_acl_xattr_entry     a_entries[0];
> > > -} ext_acl_xattr_header;
> > > +struct ext_acl_xattr_header {
> > > +     __u32 a_count;
> > > +     struct ext_acl_xattr_entry a_entries[0];
> > > +};
> > >
> > >  #define CFS_ACL_XATTR_SIZE(count, prefix) \
> > >       (sizeof(prefix ## _header) + (count) * sizeof(prefix ## _entry))
> > > --
> > > 2.7.4
> > >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups "outreachy-kernel" group.
> > > To unsubscribe from this group and stop receiving emails from it, send
> an email to outreachy-kernel+unsubscribe@googlegroups.com.
> > > To post to this group, send email to outreachy-kernel@googlegroups.com.
> > > To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/1488259405-19730-1-git-s
> end-email-gs051095%40gmail.com.
> > > For more options, visit https://groups.google.com/d/optout.
> > >
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "outreachy-kernel" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> email to outreachy-kernel+unsubscribe@googlegroups.com.
> > To post to this group, send email to outreachy-kernel@googlegroups.com.
> > To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/alpine.DEB.2.20.17022807
> 44060.2078%40hadrien.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/CAOCi2DF%2BFk0NBasd6QD4m
> fkpEY1o4r0HAyewQVgdfMd%3DOAyW9w%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Outreachy kernel] [PATCH] staging: lustre: Replace typedef with struct
  2017-03-11 15:49 Gargi Sharma
@ 2017-03-12 13:38 ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2017-03-12 13:38 UTC (permalink / raw)
  To: Gargi Sharma; +Cc: outreachy-kernel, oleg.drokin, andreas.dilger, jsimmons

On Sat, Mar 11, 2017 at 09:19:53PM +0530, Gargi Sharma wrote:
> 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

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-03-12 13:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-28  5:23 [PATCH] staging: lustre: Replace typedef with struct Gargi Sharma
2017-02-28  6:44 ` [Outreachy kernel] " Julia Lawall
2017-02-28  6:48   ` Gargi Sharma
2017-02-28  6:52     ` Julia Lawall
2017-03-11 15:49 Gargi Sharma
2017-03-12 13:38 ` [Outreachy kernel] " Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.