[Cocci] linux: bad logic in repetitive tests

2020-03-30 Thread Joe Perches
There is a block of if tests against the same variable
in include/linux/mtd/pfow.h that likely is defective

if (prog_status & 0x3)
...
else if (prog_status & 0x2)
...
else (prog_status & 0x1)
...

If the first test is true the subsequent 2 tests aren't
possible.

Likely the first test should be something like

if ((prog_status & 0x03) == 0x03)

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



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


Re: [Cocci] [v3 05/10] mmap locking API: Improving the Coccinelle software

2020-03-30 Thread Markus Elfring
>> How will the support evolve for data processing around the application
>> of similar macros?
>
> Not at all.

Will such feedback trigger any collateral evolution?

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


Re: [Cocci] [v3 05/10] mmap locking API: Improving the Coccinelle software

2020-03-30 Thread Julia Lawall


On Mon, 30 Mar 2020, Markus Elfring wrote:

> >> …
> >> (ONCE) CPP-MACRO: found known macro = FNAME
> >> …
> >> parse error
> …
> >> How would you like to improve the affected software areas?
> >
> > This can be addressed by adding a macro definition to standard.h.
>
> A corresponding specification is used already.
> https://github.com/coccinelle/coccinelle/blob/fdf0b68ddd0a518cc6ca64f063bc74ed54e29a7b/standard.h#L508
>
>
> > But once the change is done, I don't see any reason to bother with this.
>
> How will the support evolve for data processing around the application
> of similar macros?

Not at all.

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


Re: [Cocci] [v3 05/10] mmap locking API: Improving the Coccinelle software

2020-03-30 Thread Markus Elfring
>> …
>> (ONCE) CPP-MACRO: found known macro = FNAME
>> …
>> parse error
…
>> How would you like to improve the affected software areas?
>
> This can be addressed by adding a macro definition to standard.h.

A corresponding specification is used already.
https://github.com/coccinelle/coccinelle/blob/fdf0b68ddd0a518cc6ca64f063bc74ed54e29a7b/standard.h#L508


> But once the change is done, I don't see any reason to bother with this.

How will the support evolve for data processing around the application
of similar macros?

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


Re: [Cocci] [v3 05/10] mmap locking API: Improving the Coccinelle software

2020-03-30 Thread Julia Lawall


On Mon, 30 Mar 2020, Markus Elfring wrote:

> >> How will corresponding software development resources evolve?
> >
> > I don't think I understand the question, or, actually, are you asking
> > me or the coccinelle developers ?
>
> I hope that more development challenges will be picked up.
>
> The code from a mentioned source file can be reduced to the following
> test file.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kvm/mmu/paging_tmpl.h?id=7111951b8d4973bda27ff663f2cf18b663d15b48#n122
>
> // deleted part
> static inline int FNAME(is_present_gpte)(unsigned long pte)
> {
> #if PTTYPE != PTTYPE_EPT
>   return pte & PT_PRESENT_MASK;
> #else
>   return pte & 7;
> #endif
> }
> // deleted part
>
>
> Application of the software “Coccinelle 1.0.8-00029-ga549b9f0” (OCaml 4.10.0)
>
> elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --parse-c 
> paging_tmpl-excerpt1.h
> …
> (ONCE) CPP-MACRO: found known macro = FNAME
> …
> parse error
>  = File "paging_tmpl-excerpt1.h", line 2, column 41, charpos = 57
>   around = 'unsigned',
> …
> BAD:! static inline int FNAME(is_present_gpte)(unsigned long pte)
> …
> NB total files = 1; perfect = 0; pbs = 1; timeout = 0; => 0%
> nb good = 1,  nb passed = 1 => 10.00% passed
> nb good = 1,  nb bad = 8 => 20.00% good or passed
>
>
> How would you like to improve the affected software areas?

This can be addressed by adding a macro definition to standard.h.

But once the change is done, I don't see any reason to bother with this.

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


Re: [Cocci] [v3 05/10] mmap locking API: Improving the Coccinelle software

2020-03-30 Thread Markus Elfring
>> How will corresponding software development resources evolve?
>
> I don't think I understand the question, or, actually, are you asking
> me or the coccinelle developers ?

I hope that more development challenges will be picked up.

The code from a mentioned source file can be reduced to the following
test file.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kvm/mmu/paging_tmpl.h?id=7111951b8d4973bda27ff663f2cf18b663d15b48#n122

// deleted part
static inline int FNAME(is_present_gpte)(unsigned long pte)
{
#if PTTYPE != PTTYPE_EPT
return pte & PT_PRESENT_MASK;
#else
return pte & 7;
#endif
}
// deleted part


Application of the software “Coccinelle 1.0.8-00029-ga549b9f0” (OCaml 4.10.0)

elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --parse-c 
paging_tmpl-excerpt1.h
…
(ONCE) CPP-MACRO: found known macro = FNAME
…
parse error
 = File "paging_tmpl-excerpt1.h", line 2, column 41, charpos = 57
  around = 'unsigned',
…
BAD:! static inline int FNAME(is_present_gpte)(unsigned long pte)
…
NB total files = 1; perfect = 0; pbs = 1; timeout = 0; => 0%
nb good = 1,  nb passed = 1 => 10.00% passed
nb good = 1,  nb bad = 8 => 20.00% good or passed


How would you like to improve the affected software areas?

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