cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* Re: [Cocci] linux: special logic in repetitive tests
@ 2020-03-31  6:28 Markus Elfring
  2020-03-31  6:57 ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2020-03-31  6:28 UTC (permalink / raw)
  To: Joe Perches, Julia Lawall; +Cc: cocci

> There is a block of if tests against the same variable
> in include/linux/mtd/pfow.h that likely is defective

I wonder about this interpretation.


> Likely the first test should be something like
>
> 	if ((prog_status & 0x03) == 0x03)

Why would you prefer such a code variant?


> Is there a way for cocci to find this style of bitwise logic defect?

* Probably, yes.

* How often will this implementation detail really be a “defect”?

* Where do you stumble on difficulties to express a corresponding source code
  search pattern by the means of the semantic patch language?

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

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

* Re: [Cocci] linux: special logic in repetitive tests
  2020-03-31  6:28 [Cocci] linux: special logic in repetitive tests Markus Elfring
@ 2020-03-31  6:57 ` Joe Perches
  2020-03-31  7:12   ` Markus Elfring
  2020-04-01  8:55   ` Markus Elfring
  0 siblings, 2 replies; 4+ messages in thread
From: Joe Perches @ 2020-03-31  6:57 UTC (permalink / raw)
  To: Markus Elfring, Julia Lawall; +Cc: cocci

On Tue, 2020-03-31 at 08:28 +0200, Markus Elfring wrote:
> > There is a block of if tests against the same variable
> > in include/linux/mtd/pfow.h that likely is defective
> 
> I wonder about this interpretation.

Wonder harder.

If something is (& 3) it is also either (& 2 || & 1)
so why have both below the first test?

> * How often will this implementation detail really be a “defect”?

Moderately likely.

> * Where do you stumble on difficulties to express a corresponding source code
>   search pattern by the means of the semantic patch language?

#defines, shifts, masks


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

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

* Re: [Cocci] linux: special logic in repetitive tests
  2020-03-31  6:57 ` Joe Perches
@ 2020-03-31  7:12   ` Markus Elfring
  2020-04-01  8:55   ` Markus Elfring
  1 sibling, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2020-03-31  7:12 UTC (permalink / raw)
  To: Joe Perches; +Cc: cocci

> Wonder harder.
>
> If something is (& 3) it is also either (& 2 || & 1)
> so why have both below the first test?

I can interpret the source code example in the way that the number
of set bits are checked.
I can eventually become concerned around the preferred coding style
because of the usage of these constant values.
Would you like to check the use of bit fields?


>> * Where do you stumble on difficulties to express a corresponding source code
>>   search pattern by the means of the semantic patch language?
>
> #defines, shifts, masks

You come along the usual development challenges for the safe handling
of possible code variations.
With which approach would you like to start and perform further
source code analysis?

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

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

* Re: [Cocci] linux: special logic in repetitive tests
  2020-03-31  6:57 ` Joe Perches
  2020-03-31  7:12   ` Markus Elfring
@ 2020-04-01  8:55   ` Markus Elfring
  1 sibling, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2020-04-01  8:55 UTC (permalink / raw)
  To: Joe Perches; +Cc: cocci

> Wonder harder.
>
> If something is (& 3) it is also either (& 2 || & 1)
> so why have both below the first test?

Would you occasionally prefer to use enumeration values together with
switch statements at such source code places?

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

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

end of thread, other threads:[~2020-04-01  8:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-31  6:28 [Cocci] linux: special logic in repetitive tests Markus Elfring
2020-03-31  6:57 ` Joe Perches
2020-03-31  7:12   ` Markus Elfring
2020-04-01  8:55   ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).