From: Elizabeth Ferdman <gnudevliz@gmail.com>
To: julia.lawall@lip6.fr
Cc: outreachy-kernel@googlegroups.com
Subject: Coccinelle Challenge 1
Date: Tue, 11 Oct 2016 16:32:03 -0700 [thread overview]
Message-ID: <20161011233203.GB11666@localhost> (raw)
Hi Julia,
I worked on the first challenge and I wanted to run my findings and
questions by you. Please confirm whether these observations are correct.
I looked at the difference between local idexpression, expression, and
identifier for ret.cocci.
Local idexpression basically means what local identifier
would mean-- just local vars-- except that's invalid.
Using expression in place of local identifier included results like
this:
- a->b = c;
- return a->b;
+ return c;
I don't know whether or not that's always the right thing to do. I think
that if the changes are only local, it'd be fine to compress the lines.
But if a->b happens to have a global effect than it'd be wrong. I'm not
sure about this, but if the function receives *a as a parameter, then
would a->b = c be a persistent change?
Using identifier included results where 'ret' was not necessarily local,
so compressing the lines would be bad because the global assignment
would be deleted.
I noticed some potentially bad results with ret.cocci:
1. When the type of 'ret' happens to be important, lines shouldn't be
compressed. For example, a function receives a variable of type u64 but
then returns it as u32. Deleting the assignment line means that the
value will be returned as the wrong type.
2. spatch deletes a comment between the assignment and the return
statement. E.g.:
- start = iwe(info);
- /* how to translate rssi to ?% */
- return start;
+ return iwe(info);
}
3. readability issues--
- the return value is very long with many |'s or ||'s
- the name of the variable might be meaningful to the reader
- there are if blocks with return statements:
same variable name but different values might provide meaning/order to
the program.
In these cases the variable reassignment or creation isn't actually
necessary, but does it increase readability?
Questions:
I'm pretty confused about how these lines work:
-ret =
+return
e;
-return ret;
The first line deletes the name of the variable and the equals sign,
but what happens to the expression on the right?
I'm confused as to why it doesn't say -ret = e to signify that the
expression on the right is what we want 'e' to be. Then return gets
added, and it's replacing 'ret ='. But why is 'e' even necessary if it
wasn't deleted? And why is it on a new line with spaces in front?
The last line '-return ret;' makes sense, we just want to delete the
word return followed by the variable name.
I've read some basics of coccinelle, went through the slides, and read
some articles people wrote about it but I'm still pretty confused. :/
Thanks for your time,
Elizabeth
next reply other threads:[~2016-10-11 23:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-11 23:32 Elizabeth Ferdman [this message]
2016-10-12 5:37 ` Coccinelle Challenge 1 Julia Lawall
-- strict thread matches above, loose matches on Subject: below --
2016-10-11 23:23 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=20161011233203.GB11666@localhost \
--to=gnudevliz@gmail.com \
--cc=julia.lawall@lip6.fr \
--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.