All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rehas Sachdeva <aquannie@gmail.com>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	outreachy-kernel@googlegroups.com,
	Oleg Drokin <oleg.drokin@intel.com>,
	Andreas Dilger <andreas.dilger@intel.com>,
	James Simmons <jsimmons@infradead.org>
Subject: Re: [Outreachy kernel] [PATCH] staging: lustre: Constify kernel_param_ops structures
Date: Sun, 2 Oct 2016 23:50:39 +0530	[thread overview]
Message-ID: <20161002182039.GA31680@toblerone> (raw)
In-Reply-To: <alpine.DEB.2.10.1610021615360.3327@hadrien>

On Sun, Oct 02, 2016 at 04:17:10PM +0200, Julia Lawall wrote:
> 
> 
> On Sun, 2 Oct 2016, Rehas Sachdeva wrote:
> 
> > Hello,
> >
> > I looked into the module_param macro.
> >
> > Consider the struct kernel_param_ops param_ops_debugmb.
> >
> > It gets used in the call module_param(libcfs_debug_mb, debugmb, 0644), which
> >
> > converts to module_param_named(libcfs_debug_mb, libcfs_debug_mb, debugmb, 0644)
> >
> > which converts to module_param_cb(libcfs_debug_mb, &param_ops_debugmb,
> > 				  &libcfs_debug_mb, 0644)
> >
> > which converts to __module_param_call(MODULE_PARAM_PREFIX, libcfs_debug_mb,
> > 				      &param_ops_debugmb, &libcfs_debug_mb,
> > 				      0644, -1, 0)
> >
> > Now this translates to declaration of a variable of type struct kernel_param
> > whose field const struct kernel_param_ops* is assigned the value of
> > &param_ops_debugmb. Since this field is const, we can originally declare
> > struct kernel_param_ops param_ops_debugmb as const as well.
> >
> > A small doubt:
> > Is a successful build after this constification change not sufficient to
> > verify its correctness? Since the preprocessor translates the macros before
> > compilation anyways.
> 
> Yes, but there are always small details.  For example, something could be
> done differently for a different architecture.  Or there could be a cast
> that does not contain the const annotation.  In that case the compiler
> will not complain, but there will be an error at run time if the value
> turns out to be updated.
> 

Alright. Thanks
I'll send a v2 correcting the commit message.

> Thanks for the analysis.  Everything seems fine.
> 
> julia
> 
> >
> > Thanks,
> > Rehas
> >
> > On Sun, Oct 02, 2016 at 12:28:17PM +0200, Greg Kroah-Hartman wrote:
> > > On Sat, Oct 01, 2016 at 07:13:16PM +0200, Julia Lawall wrote:
> > > >
> > > >
> > > > On Sat, 1 Oct 2016, Rehas Sachdeva wrote:
> > > >
> > > > > Check for structs which can are not modified and hence can be declared as
> > > > > const. Done using Coccinelle:
> > > >
> > > > "can are" -> "are"
> > > >
> > > > This merits a little more discussion, though.  I have the impression that
> > > > these structures are used via the module_param macro.  It would be useful
> > > > to look at the expansion of the macros and see what exactly is going on.
> > >
> > > Based on other uses of this structure in the kernel, I think this is
> > > safe.  But verification would be good...
> > >
> > > thanks,
> > >
> > > greg k-h
> >
> > --
> > 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/20161002125804.GA22828%40toblerone.
> > For more options, visit https://groups.google.com/d/optout.
> >


      reply	other threads:[~2016-10-02 18:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-01 17:05 [PATCH] staging: lustre: Constify kernel_param_ops structures Rehas Sachdeva
2016-10-01 17:13 ` [Outreachy kernel] " Julia Lawall
2016-10-01 17:27   ` Rehas Sachdeva
2016-10-02 10:28   ` [Outreachy kernel] " Greg Kroah-Hartman
2016-10-02 12:58     ` Rehas Sachdeva
2016-10-02 14:17       ` Julia Lawall
2016-10-02 18:20         ` Rehas Sachdeva [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161002182039.GA31680@toblerone \
    --to=aquannie@gmail.com \
    --cc=andreas.dilger@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jsimmons@infradead.org \
    --cc=julia.lawall@lip6.fr \
    --cc=oleg.drokin@intel.com \
    --cc=outreachy-kernel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.