Coccinelle: understanding its output
I think that I don't yet understand Coccinelle's output.
I've just run the following command:
spatch --sp-file scripts/coccinelle/free/kfree.cocci --dir drivers/staging/ wlan-ng/prism2fw.c
It outputs something that looks like a patch:
HANDLING: drivers/staging/wlan-ng/prism2fw.c
(ONCE) already tagged but only removed, so safe
tmp/cocci-output-17844-0c6c7c-prism2fw.c renamed from staging/wlan-ng/prism2fw.c +0 -0
First, what is /tmp/cocci-output-17844-0c6c7c-prism2fwc? It is not a file in / tmp. If it is a file, where is it?
The output goes on with lines like the following ones:
@@ -1008,8 +1005,6 @@ static int writeimage(struct wlandevice
rstmsg = kzalloc(sizeof(*rstmsg), GFP_KERNEL);
rwrmsg = kzalloc(sizeof(*rwrmsg), GFP_KERNEL);
if (!rstmsg || !rwrmsg) {- kfree(rstmsg);
- kfree(rwrmsg);
netdev_err(wlandev->netdev,
"%s: no memory for firmware download, aborting
download\n",
__func__);
Please read the two lines with a trailing '-'... Does Coccinelle mean that they should be removed? If yes, I'm not able to understand why, because I think they must not be removed. Am I wrong?
I'd appreciate some help.
Thanks,
Fabio
Quoted 28 lines · Fabio M. De Francesco
I think that I don't yet understand Coccinelle's output.
I've just run the following command:
spatch --sp-filescripts/coccinelle/free/kfree.cocci--dirdrivers/staging/wlan-ng/prism2fw.cIt outputs something that looks like a patch:
HANDLING:
drivers/staging/wlan-ng/prism2fw.c
(ONCE) already tagged but only removed, so safe
diff =tmp/cocci-output-17844-0c6c7c-prism2fw.c renamed from staging/wlan-ng/prism2fw.c +0
-0First, what is
/tmp/cocci-output-17844-0c6c7c-prism2fwc? It is not a file in / tmp. If it is a file, where is it?The output goes on with lines like the following ones:
@@ -1008,8 +1005,6 @@ static int writeimage(struct wlandevice rstmsg = kzalloc(sizeof(*rstmsg), GFP_KERNEL); rwrmsg = kzalloc(sizeof(*rwrmsg), GFP_KERNEL); if (!rstmsg || !rwrmsg) {tmp/cocci-output-17844-0c6c7c-prism2fw.c renamed from staging/wlan-ng/prism2fw.c +0
-2-kfree (rstmsg); -kfree (rwrmsg); netdev_err(wlandev->netdev, "%s: no memory for firmware download, abortingdownload\n",
Quoted 5 lines
__func__);Please read the two lines with a trailing '-'... Does Coccinelle mean that they should be removed? If yes, I'm not able to understand why, because I think they must not be removed. Am I wrong?
Sorry. I think that the *s are a left over from a version of the semantic patch that was trying to do more. The semantic patches in the Linux kernel are meant to be used with make coccicheck, which would have avoided this problem. The key is the lines
virtual org
virtual report
near the top of the file. This means that the semantic patch should only be run with either the option -D org (producing emacs org mode) or the option -D report (producing text). Both of these modes suppress the - that you are seeing.
The - comes from the uses of * in the semantic patch, that is used to highlight lines of interest, where the highlighting is done by putting a - at the beginning of the line. It's not meant as a suggestion to remove the line, just that you might want to look at it. But in this case, as you noted, there is nothing interesting to see. I will remove the *s.
julia
Quoted 5 lines · CEST Julia Lawall
Quoted 4 lines · Fabio M. De Francesco
I think that I don't yet understand Coccinelle's output.
I've just run the following command:
spatch --sp-filescripts/coccinelle/free/kfree.cocci--dirdrivers/
staging/
Quoted 6 lines
Quoted 6 lines
wlan-ng/prism2fw.cIt outputs something that looks like a patch:
HANDLING:
drivers/staging/wlan-ng/prism2fw.c
Quoted 7 lines
Quoted 7 lines
(ONCE) already tagged but only removed, so safe
diff =
tmp/cocci-output-17844-0c6c7c-prism2fw.c renamed from staging/wlan-ng/prism2fw.c +0
-0First, what is
/tmp/cocci-output-17844-0c6c7c-prism2fwc? It is not a file
in
Quoted 20 lines
Quoted 20 lines
/ tmp. If it is a file, where is it?
The output goes on with lines like the following ones:
@@ -1008,8 +1005,6 @@ static int writeimage(struct wlandevicerstmsg = kzalloc(sizeof(*rstmsg), GFP_KERNEL); rwrmsg = kzalloc(sizeof(*rwrmsg), GFP_KERNEL); if (!rstmsg || !rwrmsg) {tmp/cocci-output-17844-0c6c7c-prism2fw.c renamed from staging/wlan-ng/prism2fw.c +0
-2-kfree (rstmsg); -kfree (rwrmsg); netdev_err(wlandev->netdev, "%s: no memory for firmware download, abortingdownload\n",
__func__);
Quoted 9 lines
Quoted 3 lines
Please read the two lines with a trailing '-'... Does Coccinelle mean that they should be removed? If yes, I'm not able to understand why, because I think they must not be removed. Am I wrong?
Sorry. I think that the *s are a left over from a version of the semantic patch that was trying to do more. The semantic patches in the Linux kernel are meant to be used with make coccicheck, which would have avoided this problem. The key is the lines
"make coccicheck" fails with the following message:
Python error: No module named coccilib.elems
coccicheck failed
make: *** [Makefile:1937: coccicheck] Error 255
Quoted 9 lines
virtual org
virtual reportnear the top of the file. This means that the semantic patch should only be run with either the option -D org (producing emacs org mode) or the option -D report (producing text). Both of these modes suppress the - that you are seeing.
Run of "spatch -D report --sp-file scripts/coccinelle/api/kfree_mismatch.cocci --dir drivers/staging/" fails too:
init_defs_builtins: /usr/bin/../lib/coccinelle/standard.h Python error: No module named coccilib.elems
I think that it depends on some package I have not yet installed, or to some environment variable that must be set for the Python interpreter to find the coccili.elems module... I really don't know.
Do you have any idea for solving this problem?
Thanks,
Fabio
Quoted 8 lines
The - comes from the uses of * in the semantic patch, that is used to highlight lines of interest, where the highlighting is done by putting a - at the beginning of the line. It's not meant as a suggestion to remove the line, just that you might want to look at it. But in this case, as you noted, there is nothing interesting to see. I will remove the *s.
julia
Quoted 67 lines · Fabio M. De Francesco
Quoted 5 lines · CEST Julia Lawall
Quoted 4 lines · Fabio M. De Francesco
I think that I don't yet understand Coccinelle's output.
I've just run the following command:
spatch --sp-filescripts/coccinelle/free/kfree.cocci--dirdrivers/staging/
Quoted 6 lines
Quoted 6 lines
wlan-ng/prism2fw.cIt outputs something that looks like a patch:
HANDLING:
drivers/staging/wlan-ng/prism2fw.cQuoted 7 lines
Quoted 7 lines
(ONCE) already tagged but only removed, so safe
diff =
tmp/cocci-output-17844-0c6c7c-prism2fw.c renamed from staging/wlan-ng/prism2fw.c +0
-0First, what is
/tmp/cocci-output-17844-0c6c7c-prism2fwc? It is not a filein
Quoted 20 lines
Quoted 20 lines
/ tmp. If it is a file, where is it?
The output goes on with lines like the following ones:
@@ -1008,8 +1005,6 @@ static int writeimage(struct wlandevicerstmsg = kzalloc(sizeof(*rstmsg), GFP_KERNEL); rwrmsg = kzalloc(sizeof(*rwrmsg), GFP_KERNEL); if (!rstmsg || !rwrmsg) {tmp/cocci-output-17844-0c6c7c-prism2fw.c renamed from staging/wlan-ng/prism2fw.c +0
-2-kfree (rstmsg); -kfree (rwrmsg); netdev_err(wlandev->netdev, "%s: no memory for firmware download, abortingdownload\n",
__func__);Quoted 9 lines
Quoted 3 lines
Please read the two lines with a trailing '-'... Does Coccinelle mean that they should be removed? If yes, I'm not able to understand why, because I think they must not be removed. Am I wrong?
Sorry. I think that the *s are a left over from a version of the semantic patch that was trying to do more. The semantic patches in the Linux kernel are meant to be used with make coccicheck, which would have avoided this problem. The key is the lines
"make coccicheck" fails with the following message:
Python error: No module named coccilib.elems
coccicheck failed
make: *** [Makefile:1937: coccicheck] Error 255Quoted 9 lines
virtual org
virtual reportnear the top of the file. This means that the semantic patch should only be run with either the option -D org (producing emacs org mode) or the option -D report (producing text). Both of these modes suppress the - that you are seeing.
Run of "spatch -D report --sp-file
scripts/coccinelle/api/kfree_mismatch.cocci--dirdrivers/staging/" fails too:
Quoted 8 lines
init_defs_builtins:/usr/bin/../lib/coccinelle/standard.hPython error: No module named coccilib.elemsI think that it depends on some package I have not yet installed, or to some environment variable that must be set for the Python interpreter to find the coccili.elems module... I really don't know.
Do you have any idea for solving this problem?
How did you install Coccinelle?
julia
Quoted 44 lines · CEST Julia Lawall
Quoted 43 lines · Fabio M. De Francesco
Quoted 5 lines · CEST Julia Lawall
Quoted 4 lines · Fabio M. De Francesco
I think that I don't yet understand Coccinelle's output.
I've just run the following command:
spatch --sp-filescripts/coccinelle/free/kfree.cocci--dirdrivers/staging/
Quoted 6 lines
Quoted 6 lines
wlan-ng/prism2fw.cIt outputs something that looks like a patch:
HANDLING:
drivers/staging/wlan-ng/prism2fw.cQuoted 8 lines
Quoted 8 lines
(ONCE) already tagged but only removed, so safe
diff =
tmp/cocci-output-17844-0c6c7c-prism2fw.c renamed from staging/wlan-ng/prism2fw.c +0
-0First, what is
/tmp/cocci-output-17844-0c6c7c-prism2fwc? It is not a filein
Quoted 17 lines
Quoted 17 lines
/ tmp. If it is a file, where is it?
The output goes on with lines like the following ones:
@@ -1008,8 +1005,6 @@ static int writeimage(struct wlandevicerstmsg = kzalloc(sizeof(*rstmsg), GFP_KERNEL); rwrmsg = kzalloc(sizeof(*rwrmsg), GFP_KERNEL); if (!rstmsg || !rwrmsg) {tmp/cocci-output-17844-0c6c7c-prism2fw.c renamed from staging/wlan-ng/prism2fw.c +0
-2-kfree (rstmsg); -kfree (rwrmsg); netdev_err(wlandev->netdev, "%s: no memory for firmware download, aborting
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
download\n",
__func__);Please read the two lines with a trailing '-'... Does Coccinelle mean that
they should be removed? If yes, I'm not able to understand why,
because
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
I
think they must not be removed. Am I wrong?Sorry. I think that the *s are a left over from a version of the
semantic
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
patch that was trying to do more. The semantic patches in the Linux kernel are meant to be used with make coccicheck, which would have
avoided
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
this problem. The key is the lines
"make coccicheck" fails with the following message:
Quoted 8 lines
Quoted 8 lines
Python error: No module named coccilib.elems
coccicheck failed
make: *** [Makefile:1937: coccicheck] Error 255Quoted 4 lines
virtual org
virtual reportnear the top of the file. This means that the semantic patch should
only
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
be run with either the option -D org (producing emacs org mode) or the option -D report (producing text). Both of these modes suppress the - that you are seeing.
Quoted 8 lines
Quoted 8 lines
Run of "spatch -D report --sp-file
scripts/coccinelle/api/kfree_mismatch.cocci--dirdrivers/staging/" fails too:
init_defs_builtins:/usr/bin/../lib/coccinelle/standard.hPython error: No module named coccilib.elemsI think that it depends on some package I have not yet installed, or to
some
Quoted 1 line
Quoted 1 line
environment variable that must be set for the Python interpreter to find
the
Quoted 8 lines
Quoted 3 lines
coccili.elems module... I really don't know.
Do you have any idea for solving this problem?
How did you install Coccinelle?
julia
My laptop runs openSuSE Tumbleweed. Therefore I installed Coccinelle with a simple "zypper install coccinelle". I see that it is (properly?) installed and that also coccigrep has been installed, even though I didn't ask explicitly for it.
Perhaps it would be better to reinstall Coccinelle from sources. I read on a Vaishali Thakkar series of slides that they are clonable from github.com/ coccinelle/coccinelle. I hope that I also find there some documentation that guides me to installing prerequisites and configure the tool for integrating with Tumbleweed environment.
Is it a good solution?
Thanks,
Fabio