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 62a8e0a021598a478c76ce2af36f2d214285fc1f
Author: Boris Faure <[email protected]>
AuthorDate: Sun Jun 19 21:41:03 2022 +0200
use DIV_ROUND_UP()
---
scripts/coccinelle/coccicheck.sh | 20 ++++++++++++--------
src/bin/backlog.c | 6 +++---
src/bin/sel.c | 4 ++--
src/bin/termpty.c | 10 +++++-----
src/bin/tycat.c | 8 ++++----
5 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/scripts/coccinelle/coccicheck.sh b/scripts/coccinelle/coccicheck.sh
index 8016b1f..545ad8e 100755
--- a/scripts/coccinelle/coccicheck.sh
+++ b/scripts/coccinelle/coccicheck.sh
@@ -13,17 +13,21 @@ notnull.cocci
null_ref.cocci
unused.cocci
use_after_iter.cocci
+div_round_up.cocci
"
HAS_ERROR=0
for f in $COCCI_FILES; do
- CMD="spatch --timeout 200 --very-quiet --cocci-file scripts/coccinelle/$f --include-headers --dir $DIR"
- #CMD="spatch --very-quiet --cocci-file scripts/coccinelle/$f --dir $DIR -allow_inconsistent_paths"
- OUT=$($CMD)
- echo "$CMD"
- if [ -n "$OUT" ]; then
- echo "$OUT"
- HAS_ERROR=1
- fi
+ OPTIONS=""
+ if [ "$COCCI_FILES" = "div_round_up" ]; then
+ OPTIONS="--defined DIV_ROUND_UP"
+ fi
+ CMD="spatch --timeout 200 --very-quiet --cocci-file scripts/coccinelle/$f --include-headers --dir $DIR $OPTIONS"
+ OUT=$($CMD)
+ echo "$CMD"
+ if [ -n "$OUT" ]; then
+ echo "$OUT"
+ HAS_ERROR=1
+ fi
done
exit $HAS_ERROR
diff --git a/src/bin/backlog.c b/src/bin/backlog.c
index 6c92dfb..aa8765d 100644
--- a/src/bin/backlog.c
+++ b/src/bin/backlog.c
@@ -16,11 +16,11 @@ _accounting_change(int64_t diff)
{
if (diff > 0)
{
- diff = ((diff + 16-1) / 16) * 16;
+ diff = DIV_ROUND_UP(diff, 16) * 16;
}
else
{
- diff = ((-1 * diff + 16-1) / 16) * -16;
+ diff = DIV_ROUND_UP(-1 * diff, 16) * -16;
}
_mem_used += diff;
}
@@ -167,7 +167,7 @@ termpty_backlog_length(Termpty *ty)
if (!ts->cells)
goto end;
- nb_lines = (ts->w == 0) ? 1 : (ts->w + ty->w - 1) / ty->w;
+ nb_lines = (ts->w == 0) ? 1 : DIV_ROUND_UP(ts->w, ty->w);
screen_y += nb_lines;
ty->backlog_beacon.screen_y = screen_y;
ty->backlog_beacon.backlog_y = backlog_y;
diff --git a/src/bin/sel.c b/src/bin/sel.c
index 1a1f52d..febe598 100644
--- a/src/bin/sel.c
+++ b/src/bin/sel.c
@@ -147,7 +147,7 @@ _mouse_move_cb(void *data,
return;
iw = sqrt(eina_list_count(sd->items));
if (iw < 1) iw = 1;
- ih = (eina_list_count(sd->items) + (iw - 1)) / iw;
+ ih = DIV_ROUND_UP(eina_list_count(sd->items), iw);
if (ih < 1) ih = 1;
evas_object_geometry_get(sd->self, &x, &y, &w, &h);
sw = w * sd->zoom;
@@ -366,7 +366,7 @@ _layout(Sel *sd)
iw = sqrt(eina_list_count(sd->items));
if (iw < 1) iw = 1;
- ih = (eina_list_count(sd->items) + (iw - 1)) / iw;
+ ih = DIV_ROUND_UP(eina_list_count(sd->items), iw);
if (ih < 1) ih = 1;
evas_object_geometry_get(sd->self, &ox, &oy, &ow, &oh);
w = ow * sd->zoom;
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 154365d..d2e41ef 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -992,8 +992,8 @@ termpty_text_save_top(Termpty *ty, Termcell *cells, ssize_t w_max)
{
int old_len = ts->w;
termpty_save_expand(ty, ts, cells, w);
- ty->backlog_beacon.screen_y += (ts->w + ty->w - 1) / ty->w
- - (old_len + ty->w - 1) / ty->w;
+ ty->backlog_beacon.screen_y += DIV_ROUND_UP(ts->w, ty->w)
+ - DIV_ROUND_UP(old_len, ty->w);
return;
}
}
@@ -1060,7 +1060,7 @@ termpty_backscroll_adjust(Termpty *ty, int *scroll)
*scroll = ty->backlog_beacon.screen_y;
return;
}
- nb_lines = (ts->w == 0) ? 1 : (ts->w + ty->w - 1) / ty->w;
+ nb_lines = (ts->w == 0) ? 1 : DIV_ROUND_UP(ts->w, ty->w);
screen_y += nb_lines;
ty->backlog_beacon.screen_y = screen_y;
ty->backlog_beacon.backlog_y = backlog_y;
@@ -1099,7 +1099,7 @@ _termpty_cellrow_from_beacon_get(Termpty *ty, int requested_y, ssize_t *wret)
{
return NULL;
}
- nb_lines = (ts->w == 0) ? 1 : (ts->w + ty->w - 1) / ty->w;
+ nb_lines = (ts->w == 0) ? 1 : DIV_ROUND_UP(ts->w, ty->w);
/* Only update the beacon if working on different line than the one
* from the beacon */
@@ -1130,7 +1130,7 @@ _termpty_cellrow_from_beacon_get(Termpty *ty, int requested_y, ssize_t *wret)
{
return NULL;
}
- nb_lines = (ts->w == 0) ? 1 : (ts->w + ty->w - 1) / ty->w;
+ nb_lines = (ts->w == 0) ? 1 : DIV_ROUND_UP(ts->w, ty->w);
ty->backlog_beacon.screen_y = screen_y;
ty->backlog_beacon.backlog_y = backlog_y;
diff --git a/src/bin/tycat.c b/src/bin/tycat.c
index 3a044b6..9395af6 100644
--- a/src/bin/tycat.c
+++ b/src/bin/tycat.c
@@ -52,17 +52,17 @@ scaleterm(int w, int h, int *iw, int *ih)
if (w > (width * cw))
{
*iw = width;
- *ih = ((h * (width * cw) / w) + (ch - 1)) / ch;
+ *ih = DIV_ROUND_UP((h * (width * cw) / w), ch);
}
else
{
- *iw = (w + (cw - 1)) / cw;
- *ih = (h + (ch - 1)) / ch;
+ *iw = DIV_ROUND_UP(w, cw);
+ *ih = DIV_ROUND_UP(h, ch);
}
if (maxh && *ih > maxh)
{
*ih = maxh;
- *iw = ((w * (maxh * ch) / h) + (cw - 1)) / cw;
+ *iw = DIV_ROUND_UP((w * (maxh * ch) / h), cw);
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.