Coccinelle archive on lore.kernel.org
 help / color / Atom feed
* [Cocci] Checking search results for two enumerations
@ 2020-04-30 17:06 Markus Elfring
  2020-04-30 17:16 ` Julia Lawall
  0 siblings, 1 reply; 3+ messages in thread
From: Markus Elfring @ 2020-04-30 17:06 UTC (permalink / raw)
  To: Coccinelle

Hello,

I have tried another tiny script out for the semantic patch language
(according to the software combination “Coccinelle 1.0.8-00029-ga549b9f0”).


@display@
int i;
@@
 return
*       -i
 ;


Are the following search results worth for further software development considerations?

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/drivers/net/wireless/intersil/hostap/hostap_main.c

elfring@Sonne:~/Projekte/Linux/next-patched> spatch ~/Projekte/Coccinelle/janitor/show_returns_of_negative_integers2.cocci drivers/net/wireless/intersil/hostap/hostap_main.c
…
@@ -328,7 +327,6 @@ int hostap_set_encryption(local_info_t *
 	u16 val, old_val;
 	int i, keylen, len, idx;
 	char keybuf[WEP_KEY_LEN + 1];
-	enum { NONE, WEP, OTHER } encrypt_type;

 	idx = local->crypt_info.tx_keyidx;
 	if (local->crypt_info.crypt[idx] == NULL ||
…


https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/sound/drivers/opl3/opl3_midi.c

elfring@Sonne:~/Projekte/Linux/next-patched> spatch ~/Projekte/Coccinelle/janitor/show_returns_of_negative_integers2.cocci sound/drivers/opl3/opl3_midi.c
…
@@ -136,7 +136,6 @@ static int opl3_get_voice(struct snd_opl

 	/* This is our "allocation cost" table */
 	enum {
-		FREE = 0, CHEAP, EXPENSIVE, END
 	};

 	/* Keeps track of what we are finding */
…


Why are source code places presented which do not contain a key word
I was looking for this test approach?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Cocci] Checking search results for two enumerations
  2020-04-30 17:06 [Cocci] Checking search results for two enumerations Markus Elfring
@ 2020-04-30 17:16 ` Julia Lawall
  2020-05-01  5:15   ` [Cocci] Checking SmPL data processing for enumerations Markus Elfring
  0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2020-04-30 17:16 UTC (permalink / raw)
  To: Markus Elfring; +Cc: Coccinelle


[-- Attachment #1: Type: text/plain, Size: 1687 bytes --]



On Thu, 30 Apr 2020, Markus Elfring wrote:

> Hello,
>
> I have tried another tiny script out for the semantic patch language
> (according to the software combination “Coccinelle 1.0.8-00029-ga549b9f0”).
>
>
> @display@
> int i;
> @@
>  return
> *       -i
>  ;
>
>
> Are the following search results worth for further software development considerations?
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/drivers/net/wireless/intersil/hostap/hostap_main.c
>
> elfring@Sonne:~/Projekte/Linux/next-patched> spatch ~/Projekte/Coccinelle/janitor/show_returns_of_negative_integers2.cocci drivers/net/wireless/intersil/hostap/hostap_main.c
> …
> @@ -328,7 +327,6 @@ int hostap_set_encryption(local_info_t *
>  	u16 val, old_val;
>  	int i, keylen, len, idx;
>  	char keybuf[WEP_KEY_LEN + 1];
> -	enum { NONE, WEP, OTHER } encrypt_type;
>
>  	idx = local->crypt_info.tx_keyidx;
>  	if (local->crypt_info.crypt[idx] == NULL ||
> …
>
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/sound/drivers/opl3/opl3_midi.c
>
> elfring@Sonne:~/Projekte/Linux/next-patched> spatch ~/Projekte/Coccinelle/janitor/show_returns_of_negative_integers2.cocci sound/drivers/opl3/opl3_midi.c
> …
> @@ -136,7 +136,6 @@ static int opl3_get_voice(struct snd_opl
>
>  	/* This is our "allocation cost" table */
>  	enum {
> -		FREE = 0, CHEAP, EXPENSIVE, END
>  	};
>
>  	/* Keeps track of what we are finding */
> …
>
>
> Why are source code places presented which do not contain a key word
> I was looking for this test approach?

I don't know.  With --debug you can see that there are only two matches.
So maybe it is a pretty printing problem.

julia

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Cocci] Checking SmPL data processing for enumerations
  2020-04-30 17:16 ` Julia Lawall
@ 2020-05-01  5:15   ` Markus Elfring
  0 siblings, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2020-05-01  5:15 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Coccinelle

>> @display@
>> int i;
>> @@
>>  return
>> *       -i
>>  ;
>> Why are source code places presented which do not contain a key word
>> I was looking for this test approach?
>
> I don't know.  With --debug you can see that there are only two matches.
> So maybe it is a pretty printing problem.

Can another tiny source file example help here for further clarification?

elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch show_returns_of_negative_integers2.cocci ../Probe/enum-test1.c
…
@@ -1,5 +1,3 @@
 int my_test(void)
 {
-enum { x } e;
-return -1;
 }


How can such a software situation be improved?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-30 17:06 [Cocci] Checking search results for two enumerations Markus Elfring
2020-04-30 17:16 ` Julia Lawall
2020-05-01  5:15   ` [Cocci] Checking SmPL data processing for enumerations Markus Elfring

Coccinelle archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/cocci/0 cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ https://lore.kernel.org/cocci \
		cocci@systeme.lip6.fr
	public-inbox-index cocci

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/fr.lip6.systeme.cocci


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git