coccinelle: use macro MIN/MAX

This commit is contained in:
Boris Faure 2022-06-23 22:54:01 +02:00
parent e1924c7fa0
commit 7a9d852a0d
Signed by: borisfaure
GPG Key ID: EAA9CD729F522998
3 changed files with 15 additions and 3 deletions

View File

@ -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)

View File

@ -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)
)

View File

@ -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;