zephyr/scripts/coccinelle/irq_lock.cocci
Flavio Ceolin 0866d18d03 irq: Fix irq_lock api usage
irq_lock returns an unsigned int, though, several places was using
signed int. This commit fix this behaviour.

In order to avoid this error happens again, a coccinelle script was
added and can be used to check violations.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-08-16 19:47:41 -07:00

48 lines
617 B
Plaintext

// Copyright (c) 2017 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
@find@
type T;
position p;
identifier i;
@@
T@p i = irq_lock();
@script:python raise_error@
t << find.T;
@@
if t in ["uint32_t", "unsigned int", "u32_t"]:
cocci.include_match(False)
@replacement@
type find.T;
position find.p;
@@
- T@p
+ unsigned int
@find2@
type T;
position p;
identifier i;
@@
T@p i;
...
i = irq_lock();
@script:python raise_error2@
t << find2.T;
@@
if t in ["uint32_t", "unsigned int", "u32_t"]:
cocci.include_match(False)
@replacement2@
type find2.T;
identifier find2.i;
@@
- T i;
+ unsigned int i;