All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bhumika Goyal <bhumirks@gmail.com>
To: outreachy-kernel <outreachy-kernel@googlegroups.com>
Subject: Re: Coccinelle Constification
Date: Sat, 15 Oct 2016 22:33:11 -0700 (PDT)	[thread overview]
Message-ID: <d11cf10a-059c-48ae-a33f-7950190831f5@googlegroups.com> (raw)
In-Reply-To: <20161016022145.GA2215@localhost>


[-- Attachment #1.1: Type: text/plain, Size: 1413 bytes --]


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.

I hope this helps :)

Thanks,
Bhumika

[-- Attachment #1.2: Type: text/html, Size: 1577 bytes --]

  parent reply	other threads:[~2016-10-16  5:33 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 [this message]
2016-10-16 18:54   ` [Outreachy kernel] " Elizabeth Ferdman

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=d11cf10a-059c-48ae-a33f-7950190831f5@googlegroups.com \
    --to=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.