I've got a situation where I want to check 2 things before a 3rd thing, but
the order of the first 2 don't matter. What's the best way to do this?

Currently, I have two rules, but with the get_ and PAGE_SIZE tests swapped
between them:

@cfu_page1@
position cfu.p;
expression f, s, I, E1, E2, E3;
type T;
@@

  I =
(
  (T)get_zeroed_page(...)
|
  (T)__get_free_page(...)
)
  ... when != I = E1
(
  if ( s != PAGE_SIZE || ... ) { ... return ...; }
|
  if ( s >  PAGE_SIZE || ... ) { ... return ...; }
)
  ... when != s = E2
      when != I = E3
  copy_from_u...@p(I, f, s)

Instead of the two rules, is there some way to simplify this?

Thanks,

-Kees

-- 
Kees Cook
Ubuntu Security Team
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to