From 91beb70d949aff1d1e25acc2935dbe6d2882eefc Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Wed, 30 Oct 2024 13:41:38 +0100 Subject: [PATCH 01/11] 2dlib: Fix unused variable compiler warning in pen.cpp This removes some unused variables in 2dlib/pen.cpp. --- 2dlib/pen.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/2dlib/pen.cpp b/2dlib/pen.cpp index 2e019f87f..c9261d306 100644 --- a/2dlib/pen.cpp +++ b/2dlib/pen.cpp @@ -129,18 +129,9 @@ void grViewport::hline(ddgr_color col, int x1, int x2, int y1) { rend_DrawLine(x1, y1, x2, y1); } -// grViewport::line -// draws a clipped line - void grViewport::line(ddgr_color color, int x1, int y1, int x2, int y2) { - int xa, ya, xb, yb; ASSERT(vp_Locked); - xa = global_x(x1); - ya = global_y(y1); - xb = global_x(x2); - yb = global_y(y2); - rend_SetFlatColor(color); rend_DrawLine(x1, y1, x2, y2); } From 50c6b95fe76e4ead9201fa8fd40d5a48ae8483cf Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Wed, 30 Oct 2024 13:57:52 +0100 Subject: [PATCH 02/11] 2dlib: Fix an integer signedness compiler warning in pentext.cpp This fixes an integer signedness compiler warning and cleans up the grViewport::draw_text_line method in 2dlib/pentext.cpp. --- 2dlib/pentext.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/2dlib/pentext.cpp b/2dlib/pentext.cpp index 6d93fbc90..6b54fa95d 100644 --- a/2dlib/pentext.cpp +++ b/2dlib/pentext.cpp @@ -334,23 +334,18 @@ void grViewport::draw_text_line_clip(int x, int y, char *str) { } void grViewport::draw_text_line(int x, int y, char *str) { - unsigned i, cur_x; - /* perform string drawing without viewport clipping. supports bitmap fonts or color(alpha) mapped fonts. */ - cur_x = x; - for (i = 0; i < (int)strlen(str); i++) { - uint8_t ch; - - ch = (uint8_t)str[i]; - + uint32_t cur_x = x; + for (size_t i = 0; i < strlen(str); i++) { + uint8_t ch = (uint8_t)str[i]; if (ch == GR_COLOR_CHAR) { - if ((i + 3) >= (int)strlen(str)) + if ((i + 3) >= strlen(str)) Int3(); // This shouldn't happen! bad string! set_text_color(GR_RGB(str[i + 1], str[i + 2], str[i + 3])); i += 4; - if (i >= (int)strlen(str)) + if (i >= strlen(str)) Int3(); // This shouldn't happen too. ch = (uint8_t)str[i]; } else if (ch == '\t') { // tab char From ce8531b09c93a22e50fb24520a206b5dfa8ce81c Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Wed, 30 Oct 2024 14:03:34 +0100 Subject: [PATCH 03/11] 2dlib: Remove unused static string buffer in pentext.cpp This removes an unused static string buffer in 2dlib/pentext.cpp. --- 2dlib/pentext.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/2dlib/pentext.cpp b/2dlib/pentext.cpp index 6b54fa95d..4b1fd4dbc 100644 --- a/2dlib/pentext.cpp +++ b/2dlib/pentext.cpp @@ -96,7 +96,6 @@ #define STR_BUF_SIZE 512 static char Str_buf[STR_BUF_SIZE]; // String buffer for variable arguments -static char Draw_str_buf[STR_BUF_SIZE]; // used to buffer words in a string // --------------------------------------------------------------------------- // Viewport font and text funcitons From e6538ca6d30992417e39114e86e9db917a230501 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Wed, 30 Oct 2024 14:15:22 +0100 Subject: [PATCH 04/11] 2dlib: Remove unused static mem_bitmap struct in memsurf.cpp This removes an unused static mem_bitmap struct in memsurf.cpp to fix a compiler warning. --- 2dlib/memsurf.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/2dlib/memsurf.cpp b/2dlib/memsurf.cpp index cab2d97de..e27063e43 100644 --- a/2dlib/memsurf.cpp +++ b/2dlib/memsurf.cpp @@ -140,8 +140,6 @@ bool grMemorySurface::init(int w, int h, int bpp, char *data, int rowsize, unsig // internal functions // --------------------------------------------------------------------------- -static mem_bitmap grMemSurf_object; - bool gr_bm_mem_Blt16(ddgr_surface *dsf, int dx, int dy, ddgr_surface *ssf, int sx, int sy, int sw, int sh); bool gr_bm_mem_Blt16ck(ddgr_surface *dsf, int dx, int dy, ddgr_surface *ssf, int sx, int sy, int sw, int sh); From 472fd5bee400e5c5165767a5a7285c0d0db473b6 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Wed, 30 Oct 2024 14:26:25 +0100 Subject: [PATCH 05/11] 2dlib: Fix integer signedness missmatch in comparison in font.cpp --- 2dlib/font.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/2dlib/font.cpp b/2dlib/font.cpp index 5618661f8..adaa36f8a 100644 --- a/2dlib/font.cpp +++ b/2dlib/font.cpp @@ -168,15 +168,12 @@ inline int READ_FONT_DATA(FONTFILE ffile, void *buf, int size, int nelem) { } inline FONTFILE OPEN_FONT(const char *filename, bool &success) { - FONTFILE fp; - int file_id; - success = false; - fp = (FONTFILE)cfopen(filename, "rb"); + FONTFILE fp = (FONTFILE)cfopen(filename, "rb"); if (!fp) return NULL; - file_id = READ_FONT_INT(fp); + uint32_t file_id = READ_FONT_INT(fp); if (file_id != 0xfeedbaba) return (FONTFILE)(-1); From eb815ce5c90e45b7f33e563732c60cb7446facae Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Wed, 30 Oct 2024 14:36:30 +0100 Subject: [PATCH 06/11] 2dlib: Fix set but not used variable compiler warning in surface.cpp --- 2dlib/surface.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/2dlib/surface.cpp b/2dlib/surface.cpp index 0ce7266b8..d6be4f2c2 100644 --- a/2dlib/surface.cpp +++ b/2dlib/surface.cpp @@ -319,7 +319,6 @@ void grSurface::uniblt(int dx, int dy, grSurface *ssf, int sx, int sy, int sw, i // mode 11b = dd_to_dd, 01b = mem_to_dd, 10b = dd_to_mem, 00b = mem_to_mem int mode = 0; ddgr_surface *dsfs = &ddsfObj, *ssfs = &ssf->ddsfObj; - bool err; // setup blitting mode if (ssfs->type == SURFTYPE_GENERIC || ssfs->type == SURFTYPE_VIDEOSCREEN) @@ -332,7 +331,7 @@ void grSurface::uniblt(int dx, int dy, grSurface *ssf, int sx, int sy, int sw, i */ if (mode == 0x3) { ASSERT(!surf_Locked); - err = ddgr_surf_Blt(dsfs, dx, dy, ssfs, sx, sy, sw, sh); + ddgr_surf_Blt(dsfs, dx, dy, ssfs, sx, sy, sw, sh); return; } @@ -340,7 +339,7 @@ void grSurface::uniblt(int dx, int dy, grSurface *ssf, int sx, int sy, int sw, i just lock both surfaces and do a memory blt. */ if (mode == 0) { - err = gr_mem_surf_Blt(dsfs, dx, dy, ssfs, sx, sy, sw, sh); + gr_mem_surf_Blt(dsfs, dx, dy, ssfs, sx, sy, sw, sh); return; } @@ -359,7 +358,7 @@ void grSurface::uniblt(int dx, int dy, grSurface *ssf, int sx, int sy, int sw, i grSurface::scratch_mem_surf->flags = ssfs->flags; gr_mem_surf_Init(grSurface::scratch_mem_surf, data, rowsize); - err = gr_mem_surf_Blt(dsfs, dx, dy, grSurface::scratch_mem_surf, sx, sy, sw, sh); + gr_mem_surf_Blt(dsfs, dx, dy, grSurface::scratch_mem_surf, sx, sy, sw, sh); ssf->unlock(); return; @@ -380,7 +379,7 @@ void grSurface::uniblt(int dx, int dy, grSurface *ssf, int sx, int sy, int sw, i grSurface::scratch_mem_surf->flags = dsfs->flags; gr_mem_surf_Init(grSurface::scratch_mem_surf, m_DataPtr, m_DataRowsize); - err = gr_mem_surf_Blt(grSurface::scratch_mem_surf, dx, dy, ssfs, sx, sy, sw, sh); + gr_mem_surf_Blt(grSurface::scratch_mem_surf, dx, dy, ssfs, sx, sy, sw, sh); grSurface::unlock(); return; From 443edb2152a595735a2cdc1c40e031f8f51608e0 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Wed, 30 Oct 2024 14:40:54 +0100 Subject: [PATCH 07/11] 2dlib: Fix another set but not used variable compiler warning in surface.cpp --- 2dlib/surface.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/2dlib/surface.cpp b/2dlib/surface.cpp index d6be4f2c2..95025f27d 100644 --- a/2dlib/surface.cpp +++ b/2dlib/surface.cpp @@ -512,18 +512,16 @@ char *grSurface::lock(int x, int y, int *rowsize) { } void grSurface::unlock() { - bool grerr; - ASSERT(m_SurfInit); ASSERT(surf_Locked); switch (ddsfObj.type) { case SURFTYPE_VIDEOSCREEN: case SURFTYPE_GENERIC: - grerr = ddgr_surf_Unlock(&ddsfObj, m_OrigDataPtr); + ddgr_surf_Unlock(&ddsfObj, m_OrigDataPtr); break; case SURFTYPE_MEMORY: - grerr = gr_mem_surf_Unlock(&ddsfObj, m_OrigDataPtr); + gr_mem_surf_Unlock(&ddsfObj, m_OrigDataPtr); break; default: Int3(); // invalid type!! From 3a96d37cb093ffb0907d7cd402204121b4b470bf Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Wed, 30 Oct 2024 14:44:37 +0100 Subject: [PATCH 08/11] 2dlib: Fix another set but not used variable compiler warning in surface.cpp --- 2dlib/surface.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/2dlib/surface.cpp b/2dlib/surface.cpp index 95025f27d..2ae519b6e 100644 --- a/2dlib/surface.cpp +++ b/2dlib/surface.cpp @@ -667,11 +667,10 @@ void grSurface::xlat24_16(char *data, int w, int h) { char *sptr; uint16_t *dptr; int scol, dcol, row; - int rowsize_w, height, width; + int height, width; dptr = (uint16_t *)m_DataPtr; sptr = (char *)data; - rowsize_w = m_DataRowsize / 2; height = std::min(h, ddsfObj.h); width = std::min(w, ddsfObj.w); From b44e4220b88630c9706e01391f343728e75ce435 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Wed, 30 Oct 2024 18:54:31 +0100 Subject: [PATCH 09/11] 2dlib: Fix uninitialized bool compiler warning in surface.cpp --- 2dlib/surface.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/2dlib/surface.cpp b/2dlib/surface.cpp index 2ae519b6e..cb1b1e7fc 100644 --- a/2dlib/surface.cpp +++ b/2dlib/surface.cpp @@ -435,10 +435,9 @@ void grSurface::replace_color(ddgr_color sc, ddgr_color dc) { // --------------------------------------------------------------------------- char *grSurface::lock(int *rowsize) { - bool grerr; - ASSERT(m_SurfInit); + bool grerr = false; switch (ddsfObj.type) { case SURFTYPE_VIDEOSCREEN: case SURFTYPE_GENERIC: From b7a35fde4abdff32e2a55e903315e6ed1af70ecf Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Wed, 30 Oct 2024 18:59:56 +0100 Subject: [PATCH 10/11] 2dlib: Fix unused variable compiler warning in memsurf.cpp This fixes an unused variable compiler warning in Release builds in 2dlib/memsurf.cpp. --- 2dlib/memsurf.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/2dlib/memsurf.cpp b/2dlib/memsurf.cpp index e27063e43..900b1f471 100644 --- a/2dlib/memsurf.cpp +++ b/2dlib/memsurf.cpp @@ -265,7 +265,8 @@ void gr_mem_surf_Clear(ddgr_surface *dsf, ddgr_color col, int l, int t, int w, i bool gr_mem_surf_Blt(ddgr_surface *dsf, int dx, int dy, ddgr_surface *ssf, int sx, int sy, int sw, int sh) { // Maybe we should allow slow 16bpp to 24bpp and vice-versa blts. // for now, we wont. - mem_bitmap *sbm = (mem_bitmap *)ssf->obj, *dbm = (mem_bitmap *)dsf->obj; + [[maybe_unused]] mem_bitmap *sbm = (mem_bitmap *)ssf->obj; + mem_bitmap *dbm = (mem_bitmap *)dsf->obj; ASSERT(dbm->bpp == sbm->bpp); From a289cf93c02a1904c79d2c2afba63ba4420bb389 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Wed, 30 Oct 2024 19:05:49 +0100 Subject: [PATCH 11/11] 2dlib: Fix set but not used compiler warning in font.cpp This fixes a set but not used compiler warning in Release builds in 2dlib/font.cpp. --- 2dlib/font.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/2dlib/font.cpp b/2dlib/font.cpp index adaa36f8a..2dfd9cc95 100644 --- a/2dlib/font.cpp +++ b/2dlib/font.cpp @@ -631,7 +631,7 @@ int grFont::draw_char(grSurface *sf, int x, int y, int ch, tCharProperties *chpr int grFont::draw_char(grSurface *sf, int x, int y, int ch, int sx, int sy, int sw, int sh, tCharProperties *chprop) { gr_font_record *ft; - int next_x = 0, width, index; + int next_x = 0, index; ASSERT(m_FontHandle > -1); if ((ch < min_ascii()) || (ch > max_ascii())) @@ -643,6 +643,7 @@ int grFont::draw_char(grSurface *sf, int x, int y, int ch, int sx, int sy, int s index = ch - ft->font.min_ascii; // draw either a color bitmap or mono font. + [[maybe_unused]] int width; if (ft->font.flags & FT_PROPORTIONAL) { width = (int)ft->font.char_widths[index]; } else {