From 9141e1364088445567437ee25948d5f94aa9c1c6 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Thu, 15 Sep 2022 15:01:30 +0800 Subject: [PATCH] suppress some warnings reported by GCC 12 --- src/control/scrollview.c | 13 +++++++++---- src/ex_ctrl/coolbar.c | 4 ++-- src/gui/lf_manager.c | 4 ++-- src/gui/window.c | 3 +++ src/kernel/Makefile.am | 1 + src/kernel/compsor-manager.c | 4 ++-- src/kernel/desktop.c | 2 +- src/mybmp/webp.c | 8 +++++--- src/server/layer.c | 3 +++ 9 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/control/scrollview.c b/src/control/scrollview.c index 3c0d3a51..98aa7d1f 100644 --- a/src/control/scrollview.c +++ b/src/control/scrollview.c @@ -15,7 +15,7 @@ * and Graphics User Interface (GUI) support system for embedded systems * and smart IoT devices. * - * Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd. + * Copyright (C) 2002~2022, Beijing FMSoft Technologies Co., Ltd. * Copyright (C) 1998~2002, WEI Yongming * * This program is free software: you can redistribute it and/or modify @@ -493,10 +493,15 @@ LRESULT ScrollViewCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara break; } - case MSG_DESTROY: - scrollview_destroy (psvdata); - free (psvdata); + case MSG_DESTROY: { + /* suppress a warning about calling free() before using the pointer */ + PSVDATA svdata = (PSVDATA) GetWindowAdditionalData2 (hWnd); + if (svdata) { + scrollview_destroy(svdata); + free (svdata); + } break; + } case MSG_GETDLGCODE: return DLGC_WANTARROWS; diff --git a/src/ex_ctrl/coolbar.c b/src/ex_ctrl/coolbar.c index 36659c14..60cfd78d 100644 --- a/src/ex_ctrl/coolbar.c +++ b/src/ex_ctrl/coolbar.c @@ -15,7 +15,7 @@ * and Graphics User Interface (GUI) support system for embedded systems * and smart IoT devices. * - * Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd. + * Copyright (C) 2002~2022, Beijing FMSoft Technologies Co., Ltd. * Copyright (C) 1998~2002, WEI Yongming * * This program is free software: you can redistribute it and/or modify @@ -283,7 +283,7 @@ static void DrawCoolBox (HWND hWnd, HDC hdc, PCOOLBARCTRL pdata) WINDOWINFO *info; RECT rc; - if (tmpdata->Caption == NULL || tmpdata->Caption [0] == '\0') + if (tmpdata->Caption [0] == '\0') break; GetTextExtent (hdc, tmpdata->Caption, -1, &size); diff --git a/src/gui/lf_manager.c b/src/gui/lf_manager.c index 45a745a8..9fd60544 100644 --- a/src/gui/lf_manager.c +++ b/src/gui/lf_manager.c @@ -15,7 +15,7 @@ * and Graphics User Interface (GUI) support system for embedded systems * and smart IoT devices. * - * Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd. + * Copyright (C) 2002~2022, Beijing FMSoft Technologies Co., Ltd. * Copyright (C) 1998~2002, WEI Yongming * * This program is free software: you can redistribute it and/or modify @@ -803,7 +803,7 @@ BOOL GUIAPI InitWindowElementAttrs (PWERENDERER rdr) char buff [20]; DWORD rgba; - if (!rdr || !rdr->name || rdr->name[0] == '\0') + if (!rdr || rdr->name[0] == '\0') return FALSE; _DBG_PRINTF ("GUI>InitWEA: Initialize %s renderer window element attributes.\n", diff --git a/src/gui/window.c b/src/gui/window.c index b8370f22..d26c2f0b 100644 --- a/src/gui/window.c +++ b/src/gui/window.c @@ -3704,6 +3704,8 @@ BOOL GUIAPI ShowScrollBar (HWND hWnd, int iSBar, BOOL bShow) return TRUE; } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" /* moved here from desktop.c; can be used on virtual window */ static void guiAddNewHostedMainWindow (PMAINWIN pHosting, PMAINWIN pHosted) { @@ -3755,6 +3757,7 @@ static void guiRemoveHostedMainWindow (PMAINWIN pHosting, PMAINWIN pHosted) } #endif /* debug code */ } +#pragma GCC diagnostic pop /************************* Support for virtual window ************************/ #ifdef _MGHAVE_VIRTUAL_WINDOW diff --git a/src/kernel/Makefile.am b/src/kernel/Makefile.am index da431827..1a2a65d5 100644 --- a/src/kernel/Makefile.am +++ b/src/kernel/Makefile.am @@ -1,5 +1,6 @@ # also for makefile.ng and makefile.msvc AM_CPPFLAGS = -I$(abs_top_srcdir)/src/include -I$(abs_top_srcdir)/include +AM_CFLAGS = -Wno-zero-length-bounds noinst_LTLIBRARIES = libkernel.la diff --git a/src/kernel/compsor-manager.c b/src/kernel/compsor-manager.c index 18c000dc..000381d2 100644 --- a/src/kernel/compsor-manager.c +++ b/src/kernel/compsor-manager.c @@ -15,7 +15,7 @@ * and Graphics User Interface (GUI) support system for embedded systems * and smart IoT devices. * - * Copyright (C) 2002~2021, Beijing FMSoft Technologies Co., Ltd. + * Copyright (C) 2002~2022, Beijing FMSoft Technologies Co., Ltd. * Copyright (C) 1998~2002, WEI Yongming * * This program is free software: you can redistribute it and/or modify @@ -489,7 +489,7 @@ const CompositorOps* GUIAPI ServerGetCompositorOps (const char* name) return NULL; for (i = 0; i < MAX_NR_COMPOSITORS; i++) { - if (compositors [i].name && strcmp (compositors [i].name, name) == 0) { + if (strcmp (compositors [i].name, name) == 0) { return compositors [i].ops; } } diff --git a/src/kernel/desktop.c b/src/kernel/desktop.c index b583cbe7..01d6d36a 100644 --- a/src/kernel/desktop.c +++ b/src/kernel/desktop.c @@ -15,7 +15,7 @@ * and Graphics User Interface (GUI) support system for embedded systems * and smart IoT devices. * - * Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd. + * Copyright (C) 2002~2022, Beijing FMSoft Technologies Co., Ltd. * Copyright (C) 1998~2002, WEI Yongming * * This program is free software: you can redistribute it and/or modify diff --git a/src/mybmp/webp.c b/src/mybmp/webp.c index 2cfa61e1..2fe75d9c 100644 --- a/src/mybmp/webp.c +++ b/src/mybmp/webp.c @@ -15,7 +15,7 @@ * and Graphics User Interface (GUI) support system for embedded systems * and smart IoT devices. * - * Copyright (C) 2002~2021, Beijing FMSoft Technologies Co., Ltd. + * Copyright (C) 2002~2022, Beijing FMSoft Technologies Co., Ltd. * Copyright (C) 1998~2002, WEI Yongming * * This program is free software: you can redistribute it and/or modify @@ -106,7 +106,8 @@ void* __mg_init_webp(MG_RWops *fp, MYBITMAP *mybmp, RGB *pal) else goto error; - sc = WebPGetFeatures(info->data, info->sz_data, &info->config.input); + sc = WebPGetFeatures((const uint8_t *)info->data, info->sz_data, + &info->config.input); if (sc == VP8_STATUS_OK) { break; } @@ -210,7 +211,8 @@ int __mg_load_webp(MG_RWops *fp, void *init_info, MYBITMAP *mybmp, while (1) { int n; - VP8StatusCode status = WebPIAppend(idec, info->data, info->sz_data); + VP8StatusCode status = WebPIAppend(idec, + (const uint8_t *)info->data, info->sz_data); if (status != VP8_STATUS_OK && status != VP8_STATUS_SUSPENDED) { _ERR_PRINTF ("__mg_load_webp: WebPIAppend failed: %d\n", status); rc = ERR_BMP_LOAD; diff --git a/src/server/layer.c b/src/server/layer.c index ce684395..e9ae868e 100644 --- a/src/server/layer.c +++ b/src/server/layer.c @@ -747,6 +747,8 @@ void GUIAPI UpdateTopmostLayer (const RECT* dirty_rc) SendMessage (HWND_DESKTOP, MSG_PAINT, 0, 0); } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wzero-length-bounds" int GUIAPI ServerGetTopmostZNodeOfType (MG_Layer* layer, DWORD type, int* cli) { ZORDERINFO* zi; @@ -774,6 +776,7 @@ int GUIAPI ServerGetTopmostZNodeOfType (MG_Layer* layer, DWORD type, int* cli) return topmost; } +#pragma GCC diagnostic pop int GUIAPI ServerGetNextZNode (MG_Layer* layer, int idx_znode, int* cli) {