linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lockd: constify nlmsvc_binding structure
@ 2015-12-23 21:25 Julia Lawall
  2016-01-04 22:49 ` J. Bruce Fields
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2015-12-23 21:25 UTC (permalink / raw)
  To: J. Bruce Fields
  Cc: kernel-janitors, Jeff Layton, Trond Myklebust, Anna Schumaker,
	linux-nfs, linux-kernel

The nlmsvc_binding structure is never modified, so declare it as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---

This assumes that whoever takes advantage of the EXPORT_SYMBOL will also
not want to write in the fields.  Is that reasonable?

 fs/lockd/svc.c             |    2 +-
 fs/nfsd/lockd.c            |    2 +-
 include/linux/lockd/bind.h |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index 44d18ad..0c1a699 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -48,7 +48,7 @@
 
 static struct svc_program	nlmsvc_program;
 
-struct nlmsvc_binding *		nlmsvc_ops;
+const struct nlmsvc_binding	*nlmsvc_ops;
 EXPORT_SYMBOL_GPL(nlmsvc_ops);
 
 static DEFINE_MUTEX(nlmsvc_mutex);
diff --git a/include/linux/lockd/bind.h b/include/linux/lockd/bind.h
index 4d24d64..140edab6 100644
--- a/include/linux/lockd/bind.h
+++ b/include/linux/lockd/bind.h
@@ -29,7 +29,7 @@ struct nlmsvc_binding {
 	void			(*fclose)(struct file *);
 };
 
-extern struct nlmsvc_binding *	nlmsvc_ops;
+extern const struct nlmsvc_binding *nlmsvc_ops;
 
 /*
  * Similar to nfs_client_initdata, but without the NFS-specific
diff --git a/fs/nfsd/lockd.c b/fs/nfsd/lockd.c
index 77e7a5c..1a03bc3 100644
--- a/fs/nfsd/lockd.c
+++ b/fs/nfsd/lockd.c
@@ -58,7 +58,7 @@ nlm_fclose(struct file *filp)
 	fput(filp);
 }
 
-static struct nlmsvc_binding	nfsd_nlm_ops = {
+static const struct nlmsvc_binding nfsd_nlm_ops = {
 	.fopen		= nlm_fopen,		/* open file for locking */
 	.fclose		= nlm_fclose,		/* close file */
 };


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

* Re: [PATCH] lockd: constify nlmsvc_binding structure
  2015-12-23 21:25 [PATCH] lockd: constify nlmsvc_binding structure Julia Lawall
@ 2016-01-04 22:49 ` J. Bruce Fields
  0 siblings, 0 replies; 2+ messages in thread
From: J. Bruce Fields @ 2016-01-04 22:49 UTC (permalink / raw)
  To: Julia Lawall
  Cc: kernel-janitors, Jeff Layton, Trond Myklebust, Anna Schumaker,
	linux-nfs, linux-kernel

On Wed, Dec 23, 2015 at 10:25:13PM +0100, Julia Lawall wrote:
> The nlmsvc_binding structure is never modified, so declare it as const.
> 
> Done with the help of Coccinelle.
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> ---
> 
> This assumes that whoever takes advantage of the EXPORT_SYMBOL will also
> not want to write in the fields.  Is that reasonable?

Looks right to me, thanks, applying.--b.

> 
>  fs/lockd/svc.c             |    2 +-
>  fs/nfsd/lockd.c            |    2 +-
>  include/linux/lockd/bind.h |    2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
> index 44d18ad..0c1a699 100644
> --- a/fs/lockd/svc.c
> +++ b/fs/lockd/svc.c
> @@ -48,7 +48,7 @@
>  
>  static struct svc_program	nlmsvc_program;
>  
> -struct nlmsvc_binding *		nlmsvc_ops;
> +const struct nlmsvc_binding	*nlmsvc_ops;
>  EXPORT_SYMBOL_GPL(nlmsvc_ops);
>  
>  static DEFINE_MUTEX(nlmsvc_mutex);
> diff --git a/include/linux/lockd/bind.h b/include/linux/lockd/bind.h
> index 4d24d64..140edab6 100644
> --- a/include/linux/lockd/bind.h
> +++ b/include/linux/lockd/bind.h
> @@ -29,7 +29,7 @@ struct nlmsvc_binding {
>  	void			(*fclose)(struct file *);
>  };
>  
> -extern struct nlmsvc_binding *	nlmsvc_ops;
> +extern const struct nlmsvc_binding *nlmsvc_ops;
>  
>  /*
>   * Similar to nfs_client_initdata, but without the NFS-specific
> diff --git a/fs/nfsd/lockd.c b/fs/nfsd/lockd.c
> index 77e7a5c..1a03bc3 100644
> --- a/fs/nfsd/lockd.c
> +++ b/fs/nfsd/lockd.c
> @@ -58,7 +58,7 @@ nlm_fclose(struct file *filp)
>  	fput(filp);
>  }
>  
> -static struct nlmsvc_binding	nfsd_nlm_ops = {
> +static const struct nlmsvc_binding nfsd_nlm_ops = {
>  	.fopen		= nlm_fopen,		/* open file for locking */
>  	.fclose		= nlm_fclose,		/* close file */
>  };

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

end of thread, other threads:[~2016-01-04 22:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-23 21:25 [PATCH] lockd: constify nlmsvc_binding structure Julia Lawall
2016-01-04 22:49 ` J. Bruce Fields

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).