From: kieranbingham@gmail.com (Kieran Bingham)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Dependencies between spatch hunks
Date: Wed, 20 Apr 2016 14:45:20 +0100 [thread overview]
Message-ID: <571787F0.7050200@gmail.com> (raw)
Hi all,
I am finding that a rule which matches a part of code, sometimes causes
hunks which depend on it to act, and sometimes not to act
My spatch is successfully removing and converting hunks that I desire
changed, however the requirement became apparent *to not process the
file at all* if the variable is used in the probe function, so I added
in a dependency on probe_id_unused (established in my previous mail thread).
Therefore, I would expect to be able to set the 'depends on' to be on
'probe_id_unused' for each of the actions, and have actions only taken
if the full dependency chain (C4->C1 below) is met.
However, I get a non-consistent application of this, where some hunks
operate when (I believe) they shouldn't:
My full spatch for reference, is at:
https://gist.github.com/kbingham/96477177dd20a72b1c2f
In essence, it does the following {C}hecks:
C1 - of_dev_id_present : Check for a struct of_device_id
C2 - dev_id : Check for a struct i2c_device_id
C3 - driver : Check and identify the probefunc in the driver structure
C4 - probe_id_unused : Establish if the id is used in the probe function
Where C4 depends on C3 depends on C2 depends on C1
The aim is that if all of the above checks/identifiers are met, it will
take the following actions:
A rewrite the probe function declaration
B re-point the function pointer in the driver structure
C remove the i2c_device_id reference
D remove the i2c_device_id array
E remove the MODULE_DEVICE_TABLE macro
For this example, I'll take three files from the kernel source, all of
which meet conditions C1 - > C3 (but only F3 meets C4):
F1: drivers/gpio/gpio-pca953x.c : probe id used ( ! C4 )
F2: drivers/staging/iio/light/isl29018.c : probe id used ( ! C4 )
F3: sound/soc/codecs/wm8737.c : probe id UNUSED ( C4 )
If all the actions (A->E) start with @ depends on driver @ (to depend on
C3) all the actions complete on these files. (Shown in sequence in the c
file)
F1 : D E A B C
F2 : A D E B C
F3 : A D E B C
However, if all the actions depend on @ depends on probe_id_unused @
(depends on C4), Some actions complete, and some do not!
F1 : D E C (Unexpected behaviour - I expect F1 : <no change>)
F2 : D E C (Unexpected behaviour - I expect F2 : <no change>)
F3 : A D E B C (Expected behaviour)
So of course, I want actions D E and C to *not* complete on F1 and F2,
but I can't understand why they do not comply with their 'depends'
chain. Am I looking at a bug in Coccinelle here or a bug with my
interpretation of the depends keyword?
Sorry for the long mail, and look forward to any ideas!
--
Regards
Kieran
next reply other threads:[~2016-04-20 13:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-20 13:45 Kieran Bingham [this message]
2016-04-20 15:53 ` [Cocci] Dependencies between spatch hunks Julia Lawall
2016-04-20 16:26 ` Kieran Bingham
2016-04-20 16:31 ` Julia Lawall
2016-04-20 16:51 ` Kieran Bingham
2016-04-20 17:07 ` Julia Lawall
2016-04-20 16:46 ` Julia Lawall
2016-04-20 16:55 ` Kieran Bingham
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=571787F0.7050200@gmail.com \
--to=kieranbingham@gmail.com \
--cc=cocci@systeme.lip6.fr \
/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.