Skip to contentSkip to conversation

Checking search results for two enumerations

Cocci Markus Elfring 2 participants 3 messages Apr 30, 2020 – May 1, 2020

lore
Share & tools
lore
#0 lore raw

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
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

#1 lore raw
Quoted 46 lines · Markus Elfring

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 …

(quoted diff) +0 -1
@@ -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 …

(quoted diff) +0 -1
@@ -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 */
…
Quoted 2 lines

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

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

#2 lore raw

Re: [Cocci] Checking SmPL data processing for enumerations

Quoted 6 lines
Quoted 6 lines

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

…

Quoted 5 lines
Quoted 2 lines

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
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci