This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository terminology.
View the commit online.
commit 7a9d852a0de9e4dddfbbd6a45790821057a02705
Author: Boris Faure <[email protected]>
AuthorDate: Thu Jun 23 22:54:01 2022 +0200
coccinelle: use macro MIN/MAX
---
scripts/coccinelle/coccicheck.sh | 2 +-
scripts/coccinelle/macros.cocci | 12 ++++++++++++
src/bin/termpty.c | 4 ++--
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/scripts/coccinelle/coccicheck.sh b/scripts/coccinelle/coccicheck.sh
index 4d27c42..ec39cfe 100755
--- a/scripts/coccinelle/coccicheck.sh
+++ b/scripts/coccinelle/coccicheck.sh
@@ -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)
diff --git a/scripts/coccinelle/macros.cocci b/scripts/coccinelle/macros.cocci
index 62208e2..eb30304 100644
--- a/scripts/coccinelle/macros.cocci
+++ b/scripts/coccinelle/macros.cocci
@@ -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)
+)
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index d2e41ef..178e342 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -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;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.