ltk

GUI toolkit for X11 (WIP)
git clone git://lumidify.org/ltk.git (fast, but not encrypted)
git clone https://lumidify.org/ltk.git (encrypted, but very slow)
git clone git://4kcetb7mo7hj6grozzybxtotsub5bempzo4lirzc3437amof2c2impyd.onion/ltk.git (over tor)
Log | Files | Refs | README | LICENSE

commit 5d7021e4df96c9133cfc51e7a2f75bc62c381a75
parent 9c2187caf6ed1ae879c74854af037777707eb23d
Author: lumidify <nobody@lumidify.org>
Date:   Fri,  3 May 2024 13:42:08 +0200

Remove some undefined behavior

float->double wasn't part of fixing the undefined behavior

Diffstat:
MMakefile | 2+-
Msrc/ltk/grid.c | 12++++++------
2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile @@ -20,7 +20,7 @@ USE_XRANDR = 1 # debug DEV_CFLAGS_1 = -g -Wall -Wextra -pedantic -SANITIZE_FLAGS_1 = -g -fsanitize=address +SANITIZE_FLAGS_1 = -g -fsanitize=address,undefined # don't include default flags when debugging so possible # optimization flags don't interfere with it DEV_CFLAGS_0 = $(CFLAGS) diff --git a/src/ltk/grid.c b/src/ltk/grid.c @@ -203,10 +203,10 @@ ltk_grid_destroy(ltk_widget *self, int shallow) { static void ltk_recalculate_grid(ltk_widget *self) { ltk_grid *grid = LTK_CAST_GRID(self); - unsigned int height_static = 0, width_static = 0; - unsigned int total_row_weight = 0, total_column_weight = 0; - float height_unit = 0, width_unit = 0; - unsigned int currentx = 0, currenty = 0; + int height_static = 0, width_static = 0; + int total_row_weight = 0, total_column_weight = 0; + double height_unit = 0, width_unit = 0; + int currentx = 0, currenty = 0; int i, j; for (i = 0; i < grid->rows; i++) { total_row_weight += grid->row_weights[i]; @@ -222,10 +222,10 @@ ltk_recalculate_grid(ltk_widget *self) { } /* FIXME: what should be done when static height or width is larger than grid? */ if (total_row_weight > 0) { - height_unit = (float) (self->lrect.h - height_static) / (float) total_row_weight; + height_unit = (double)(self->lrect.h - height_static) / (double)total_row_weight; } if (total_column_weight > 0) { - width_unit = (float) (self->lrect.w - width_static) / (float) total_column_weight; + width_unit = (double)(self->lrect.w - width_static) / (double)total_column_weight; } for (i = 0; i < grid->rows; i++) { grid->row_pos[i] = currenty;