coccinelle: use ROUND_UP()

pull/4/head
Boris Faure 2 months ago
parent 69eb930f97
commit e1924c7fa0
Signed by: borisfaure
GPG Key ID: EAA9CD729F522998
  1. 6
      scripts/coccinelle/coccicheck.sh
  2. 11
      scripts/coccinelle/div_round_up.cocci
  3. 26
      scripts/coccinelle/macros.cocci
  4. 2
      src/bin/backlog.c

@ -13,14 +13,14 @@ notnull.cocci
null_ref.cocci
unused.cocci
use_after_iter.cocci
div_round_up.cocci
macros.cocci
"
HAS_ERROR=0
for f in $COCCI_FILES; do
OPTIONS=""
if [ "$f" = "div_round_up.cocci" ]; then
OPTIONS="--defined DIV_ROUND_UP"
if [ "$f" = "macros.cocci" ]; then
OPTIONS="--defined DIV_ROUND_UP --defined ROUND_UP"
fi
CMD="spatch --timeout 200 --very-quiet --cocci-file scripts/coccinelle/$f --include-headers --dir $DIR $OPTIONS"
OUT=$($CMD)

@ -1,11 +0,0 @@
@@
expression n, d;
@@
(
- (((n + d) - 1) / d)
+ DIV_ROUND_UP(n, d)
|
- ((n + (d - 1)) / d)
+ DIV_ROUND_UP(n, d)
)

@ -0,0 +1,26 @@
// DIV_ROUND_UP
@@
expression n, d;
@@
(
- (((n + d) - 1) / d)
+ DIV_ROUND_UP(n, d)
|
- ((n + (d - 1)) / d)
+ DIV_ROUND_UP(n, d)
)
// ROUND_UP
@@
expression n, d;
@@
(
- ((((n + d) - 1) / d) * d)
+ ROUND_UP(n, d)
|
- (((n + (d - 1)) / d) * d)
+ ROUND_UP(n, d)
|
- (DIV_ROUND_UP(n,d) * d)
+ ROUND_UP(n, d)
)

@ -16,7 +16,7 @@ _accounting_change(int64_t diff)
{
if (diff > 0)
{
diff = DIV_ROUND_UP(diff, 16) * 16;
diff = ROUND_UP(diff, 16);
}
else
{

Loading…
Cancel
Save