From: Elizabeth Ferdman <gnudevliz@gmail.com>
To: Bhumika Goyal <bhumirks@gmail.com>
Cc: outreachy-kernel <outreachy-kernel@googlegroups.com>
Subject: Re: [Outreachy kernel] Re: Coccinelle Constification
Date: Sun, 16 Oct 2016 11:54:30 -0700 [thread overview]
Message-ID: <20161016185429.GB2242@localhost> (raw)
In-Reply-To: <d11cf10a-059c-48ae-a33f-7950190831f5@googlegroups.com>
On Sat, Oct 15, 2016 at 10:33:11PM -0700, Bhumika Goyal wrote:
>
> Hey Liz,
>
> Eva has already explained the process well but I would like to
> share my approach :
>
> 1. Firstly, I find all structures of the form static struct s i ={...};
> by using the script:
> @r disable optional_qualifier@
> identifier s,i;
> @@
> * static struct s i ={...};
> disable optional_qualifier is used here as we want to look only for
> the non-const structures.
>
> 2. Now pick a structure instance from a file and look how it is used
> in that file.
> If the structure's fields are not getting modified => it can be
> declared as const.
> You will have to analyze the usage carefully so that nothing is missed.
> Also, you can do a grep to be sure that all the referenced are covered.
>
> 3. After this you can write a Coccinelle script to constify all the
> instances that follows this particular pattern of usage.
>
> Make a rule in the script which matches the structure's reference that
> is justified for const declaration and stores the reference position.
> Look for the @ok@ rule in my scripts.
> Now make another rule which looks for any other reference other
> than the above one and stores this position as well.
> Look for @bad@ rule for this step.
> Next, add another rule @depends on !bad disable optional_qualifier@
> that declares the structure as const.
>
> 4. After doing the changes compile the affected drivers and run
> size <affected_file_name> to get the size details of the affected
> file.
>
Hey Bhumika,
Thanks for your reply and all the advice. I understand a little
bit more about what's going on in those scripts now and I will give it a
try...
Liz
> I hope this helps :)
>
> Thanks,
> Bhumika
>
> --
> 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/d11cf10a-059c-48ae-a33f-7950190831f5%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
prev parent reply other threads:[~2016-10-16 18:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-16 2:21 Coccinelle Constification Elizabeth Ferdman
2016-10-16 3:04 ` [Outreachy kernel] " Eva Rachel Retuya
2016-10-16 18:39 ` Elizabeth Ferdman
2016-10-16 5:33 ` Bhumika Goyal
2016-10-16 18:54 ` Elizabeth Ferdman [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=20161016185429.GB2242@localhost \
--to=gnudevliz@gmail.com \
--cc=bhumirks@gmail.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.