coccinelle: use macro MIN/MAX

pull/4/head
Boris Faure 2 months ago
parent e1924c7fa0
commit 7a9d852a0d
Signed by: borisfaure
GPG Key ID: EAA9CD729F522998
  1. 2
      scripts/coccinelle/coccicheck.sh
  2. 12
      scripts/coccinelle/macros.cocci
  3. 4
      src/bin/termpty.c

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

@ -24,3 +24,15 @@ expression n, d;
- (DIV_ROUND_UP(n,d) * d)
+ ROUND_UP(n, d)
)
// MIN / MAX
@@
expression x, y;
@@
(
- (((x) > (y)) ? (y) : (x))
+ MIN(x, y)
|
- (((x) > (y)) ? (x) : (y))
+ MAX(x, y)
)

@ -1431,8 +1431,8 @@ termpty_resize(Termpty *ty, int new_w, int new_h)
free(ty->screen);
ty->screen = new_screen;
ty->cursor_state.cy = (new_si.cy >= 0) ? new_si.cy : 0;
ty->cursor_state.cx = (new_si.cx >= 0) ? new_si.cx : 0;
ty->cursor_state.cy = MAX(new_si.cy, 0);
ty->cursor_state.cx = MAX(new_si.cx, 0);
ty->circular_offset = new_si.circular_offset;
ty->circular_offset2 = 0;

Loading…
Cancel
Save