From 07c56784af7905f3426f80cdfd81eea6e154ee92 Mon Sep 17 00:00:00 2001 From: Dan M Date: Fri, 18 Sep 2026 18:09:59 -0400 Subject: [PATCH 1/2] Fix latent bugs surfaced by compiler warnings Four of these are genuine defects, not style issues: - CWorkspaceBar::OnMouseMove called itself instead of the base class (C4717), guaranteeing a stack overflow whenever the handler ran. Now calls CDockablePane::OnMouseMove. - set_offline_mode is declared bool and dllexport'ed but never returned (C4716), so callers read whatever happened to be in the return register. All five callers ignore the result, so returning the stored value preserves behaviour and keeps the exported signature intact. - intervaltotextfull and intervaltotext_old both returned a pointer to a 12-byte stack local (C4172). Every caller passes an output buffer and ignores the return value, so returning that buffer is equivalent and removes the dangling pointer. The remaining 13 changes add missing return statements on control paths that fell off the end of a non-void function (C4715). Each was checked individually; values follow the convention already used elsewhere in the same function (e.g. mudbus_read_one returns -2 on retry exhaustion, matching its sibling loop) or the surrounding API (S_OK for the WebView2 completion handler, 0 for the MFC ON_MESSAGE handler). Sites where the correct return value could not be determined from the code were deliberately left alone: guessing wrong would turn today's non-determinism into silent, deterministic incorrect behaviour. Verified with a clean Rebuild of "T3000 - VS2019.sln" (x86/Release): 0 errors, and C4702 stays at 0, confirming no inserted return landed in a function that already returned on all paths. Co-Authored-By: Claude Opus 5 --- BacNetDllforVc/Src/tsm.c | 1 + ISP/BacnetMstp.cpp | 1 + ISP/ComWriter.cpp | 1 + ISP/FlashSN.cpp | 1 + ISP/global_function.cpp | 1 + ModbusDllforVc/ModbusDllforVc/common.cpp | 1 + T3000/BacnetScreen.cpp | 3 +++ T3000/BacnetWebView.cpp | 1 + T3000/CM5/BacNetProgram_transplant.cpp | 3 ++- T3000/ModbusToBacnetRouterDlg.cpp | 1 + T3000/ProductRegisterListView.cpp | 2 ++ T3000/WorkspaceBar.cpp | 2 +- T3000/global_function.cpp | 2 +- 13 files changed, 17 insertions(+), 3 deletions(-) diff --git a/BacNetDllforVc/Src/tsm.c b/BacNetDllforVc/Src/tsm.c index 28d8a85fc..bac27be06 100644 --- a/BacNetDllforVc/Src/tsm.c +++ b/BacNetDllforVc/Src/tsm.c @@ -304,6 +304,7 @@ bool dll_offline_mode = false; bool set_offline_mode(bool offline) { dll_offline_mode = offline; + return dll_offline_mode; } /** Check if the invoke ID has been made free by the Transaction State Machine. diff --git a/ISP/BacnetMstp.cpp b/ISP/BacnetMstp.cpp index b058dfd87..818bd3bfa 100644 --- a/ISP/BacnetMstp.cpp +++ b/ISP/BacnetMstp.cpp @@ -435,6 +435,7 @@ int Bacnet_PrivateData_Deal(char * bacnet_apud_point, uint32_t len_value_type, b default: break; } + return 0; } diff --git a/ISP/ComWriter.cpp b/ISP/ComWriter.cpp index fe4a3490d..fda9473a6 100644 --- a/ISP/ComWriter.cpp +++ b/ISP/ComWriter.cpp @@ -1977,6 +1977,7 @@ int CComWriter::Fix_Tstat10_76800_baudrate() } + return 0; } int CComWriter::UpdataDeviceInformation(int& ID) diff --git a/ISP/FlashSN.cpp b/ISP/FlashSN.cpp index 4c0de7f90..14f24927f 100644 --- a/ISP/FlashSN.cpp +++ b/ISP/FlashSN.cpp @@ -240,6 +240,7 @@ unsigned long CFlashSN::Get_SerialNumber_From_Server(CString nipaddress, //m_nHardWareVersion = nHardWareVersion; //m_nProductModel=nProductID; + return 0; } diff --git a/ISP/global_function.cpp b/ISP/global_function.cpp index edb48c49c..fe269ed10 100644 --- a/ISP/global_function.cpp +++ b/ISP/global_function.cpp @@ -1185,6 +1185,7 @@ int mudbus_read_one(unsigned char device_var, unsigned short address, int retry_ return value; } } + return -2; } diff --git a/ModbusDllforVc/ModbusDllforVc/common.cpp b/ModbusDllforVc/ModbusDllforVc/common.cpp index 427f0cd81..77028bfe1 100644 --- a/ModbusDllforVc/ModbusDllforVc/common.cpp +++ b/ModbusDllforVc/ModbusDllforVc/common.cpp @@ -11065,6 +11065,7 @@ OUTPUT int write_ptp_data(unsigned char device_var, char *to_write, unsigned sho } + return -1; } #endif diff --git a/T3000/BacnetScreen.cpp b/T3000/BacnetScreen.cpp index 0d1eeebda..6f84e1f43 100644 --- a/T3000/BacnetScreen.cpp +++ b/T3000/BacnetScreen.cpp @@ -363,6 +363,7 @@ int write_webview_data(int device_instance,int panel_id,int nsel_serialnumber,in } delete temp_buffer; + return 0; } extern int save_button_click ; @@ -638,6 +639,7 @@ bool BacnetScreen::run_old_graphic_screen() { h_read_screenlabel_thread = CreateThread(NULL, NULL, ReadScreenThreadfun, this, NULL, NULL); } + return true; } LRESULT BacnetScreen::OnHotKey(WPARAM wParam,LPARAM lParam) @@ -2243,6 +2245,7 @@ int Write_Webview_Data_Special(int panelid, UINT nserialnumber, int nscreenindex //} + return 0; } diff --git a/T3000/BacnetWebView.cpp b/T3000/BacnetWebView.cpp index 6294c7e07..802f30f87 100644 --- a/T3000/BacnetWebView.cpp +++ b/T3000/BacnetWebView.cpp @@ -715,6 +715,7 @@ HRESULT BacnetWebViewAppWindow::OnCreateCoreWebView2ControllerCompleted( m_webView->Navigate(cacheBustUri.c_str()); } + return S_OK; } bool ParseString2Json(CString strIn, Json::Value& jsonOut) { diff --git a/T3000/CM5/BacNetProgram_transplant.cpp b/T3000/CM5/BacNetProgram_transplant.cpp index c8f55fdec..e5f853ebb 100644 --- a/T3000/CM5/BacNetProgram_transplant.cpp +++ b/T3000/CM5/BacNetProgram_transplant.cpp @@ -1630,7 +1630,7 @@ char* intervaltotext_old(char* textbuf, long seconds, unsigned minutes, unsigned itoa(seconds, textbuffer, 10); if (textbuf) strcpy(textbuf, buf); - return(buf); + return(textbuf); } /*******************intervaltotext ********************/ @@ -8380,6 +8380,7 @@ int get_key_name(int nfunction,CString &temp_cs) (int)strlen((char*)ptr_panel.info[nfunction].name) + 1, temp_cs.GetBuffer(MAX_PATH), MAX_PATH); temp_cs.ReleaseBuffer(); + return 1; } void init_info_table( void ) diff --git a/T3000/ModbusToBacnetRouterDlg.cpp b/T3000/ModbusToBacnetRouterDlg.cpp index bbb689c75..9f11cb2f7 100644 --- a/T3000/ModbusToBacnetRouterDlg.cpp +++ b/T3000/ModbusToBacnetRouterDlg.cpp @@ -1214,4 +1214,5 @@ LRESULT CModbusToBacnetRouterDlg::Fresh_Input_Item(WPARAM wParam, LPARAM lParam) { m_vecMd2BT[Changed_Item].Update_On_Reconnect = New_CString; } + return 0; } \ No newline at end of file diff --git a/T3000/ProductRegisterListView.cpp b/T3000/ProductRegisterListView.cpp index 706eecf5f..70c3413b6 100644 --- a/T3000/ProductRegisterListView.cpp +++ b/T3000/ProductRegisterListView.cpp @@ -1159,6 +1159,7 @@ int CProductRegisterListView::GetFunctionCode(CString FunctionName) return 16; } + return 0; } CString CProductRegisterListView::GetFunctionName(int FunctionCode) @@ -1196,6 +1197,7 @@ CString CProductRegisterListView::GetFunctionName(int FunctionCode) { return m_vecVariableType[7]; } + return _T(""); } int CProductRegisterListView::GetCaculateCode(CString CalName) diff --git a/T3000/WorkspaceBar.cpp b/T3000/WorkspaceBar.cpp index 882b6ad52..b8dcaa148 100644 --- a/T3000/WorkspaceBar.cpp +++ b/T3000/WorkspaceBar.cpp @@ -75,7 +75,7 @@ void CWorkspaceBar::OnMouseMove(UINT nFlags, CPoint point) // // GetDlgItem(IDC_EXPAND)->ModifyStyle(0,preStyle); //} - CWorkspaceBar::OnMouseMove(nFlags, point); + CDockablePane::OnMouseMove(nFlags, point); } CWorkspaceBar::CWorkspaceBar() { diff --git a/T3000/global_function.cpp b/T3000/global_function.cpp index db48fdfa3..6961b372f 100644 --- a/T3000/global_function.cpp +++ b/T3000/global_function.cpp @@ -7891,7 +7891,7 @@ char * intervaltotextfull(char *textbuf, long seconds , unsigned minutes , unsig itoa(seconds,textbuffer,10) ; if(textbuf) strcpy(textbuf, buf); - return( buf ) ; + return( textbuf ) ; } void LocalBacnetRejectHandler(BACNET_ADDRESS* src,uint8_t invoke_id,uint8_t reject_reason) { From b0b5d823987119e42219a0d5d1f1fe478887b281 Mon Sep 17 00:00:00 2001 From: Dan M Date: Fri, 18 Sep 2026 18:10:10 -0400 Subject: [PATCH 2/2] Remove typedef keywords the compiler was already ignoring Seventeen declarations of the form typedef struct Foo { ... }; typedef enum { ... }; have no alias after the closing brace, so the typedef does nothing and MSVC discards it with C4091. These were by far the loudest warning in the build: 253 of 799 warning lines came from a handful of headers, repeated once per translation unit that included them. Dropping the keyword is a no-op by construction -- the compiler was already treating these as plain struct/enum definitions. Existing code referring to the tag names is unaffected. Only declarations whose body closes with a bare "};" were touched. Declarations that do define an alias (e.g. "} URLStruct;") were left alone; stripping typedef there would convert a type alias into a variable definition. C4091 drops from 253 to 4; the remaining 4 originate in Windows SDK headers and cannot be fixed here. Co-Authored-By: Claude Opus 5 --- Modbus Poll/global_struct.h | 4 ++-- T3000/BuildingConfigration.h | 2 +- T3000/CM5/ud_str.h | 10 +++++----- T3000/MainFrm.h | 2 +- T3000/global_define.h | 14 +++++++------- T3000/schedule.h | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Modbus Poll/global_struct.h b/Modbus Poll/global_struct.h index a806879b5..f818f92b9 100644 --- a/Modbus Poll/global_struct.h +++ b/Modbus Poll/global_struct.h @@ -5,11 +5,11 @@ typedef struct T3_Register int regID; CString regName; }T3Register; -typedef struct RegPoint{ +struct RegPoint{ unsigned short Time_offset; unsigned short Value_offset; }; -typedef struct Registers_Infor +struct Registers_Infor { vector Reg_Point; COLORREF Point_Color; diff --git a/T3000/BuildingConfigration.h b/T3000/BuildingConfigration.h index 3dd365583..c516f7307 100644 --- a/T3000/BuildingConfigration.h +++ b/T3000/BuildingConfigration.h @@ -7,7 +7,7 @@ #include "../SQLiteDriver/CppSQLite3.h" // CBuildingConfigration dialog -typedef struct Building_Config +struct Building_Config { bool b_selected; int ID; diff --git a/T3000/CM5/ud_str.h b/T3000/CM5/ud_str.h index 42f8457fb..d81aaf156 100644 --- a/T3000/CM5/ud_str.h +++ b/T3000/CM5/ud_str.h @@ -929,7 +929,7 @@ typedef union }reg; }Str_Setting_Info; -typedef enum +enum { NOUSE, BACNET_MSTP,MAIN_MODBUS,MAIN_PTP,SUB_GSM,MAIN_ZIG,SUB_ZIG,SUB_MODBUS, RS232_METER, MSTP_MASTER,MAX_COM_TYPE }; @@ -1244,20 +1244,20 @@ typedef struct #pragma pack(push) //保存对齐状态 #pragma pack(1) -typedef struct str_viewportTransform +struct str_viewportTransform { unsigned short scale; unsigned short x; unsigned short y; }; -typedef struct str_t3Entry +struct str_t3Entry { unsigned char pid; unsigned char ntype; unsigned char index; }; -typedef struct str_settings +struct str_settings { unsigned char active; char bgColor[JSON_COLOR_LENGTH]; @@ -1277,7 +1277,7 @@ typedef struct str_settings }; -typedef struct myitems +struct myitems { unsigned char ntranslate_count;// 控制结构体 translate 数量 unsigned char item_belong_screen; diff --git a/T3000/MainFrm.h b/T3000/MainFrm.h index 34128b357..4ea5f780a 100644 --- a/T3000/MainFrm.h +++ b/T3000/MainFrm.h @@ -121,7 +121,7 @@ typedef struct _BUILDING_TAG CString strConnectionType; }Building_info; -typedef struct ext_info +struct ext_info { int virtual_device; // 0 default 1 verture device //Corresponds to mini_type in Settings interface diff --git a/T3000/global_define.h b/T3000/global_define.h index 026f3ab83..4c509936c 100644 --- a/T3000/global_define.h +++ b/T3000/global_define.h @@ -166,7 +166,7 @@ typedef struct #pragma pack(pop)//恢复对齐状态 -typedef enum +enum { GET_SERIAL_NUMBER = 1, DOWNLOAD_FILE = 2, @@ -1302,7 +1302,7 @@ const int KEY_INSERT = 1020; const int KEY_INSERT_CONTROL = 1021; -typedef enum +enum { PRODUCT_CM5 = 0, //10A + 8 D //10D //IN //OUT BIG_MINIPANEL = 1, //32 A //12D 12A @@ -2174,7 +2174,7 @@ enum sub_io_type //从机 发起的 FF 55 后面的 请求位; -typedef enum +enum { SEND_MINIPANEL_INFO = 1, GET_MINIPANEL_INFO = 2 @@ -2182,7 +2182,7 @@ typedef enum //主机应答的FF 55 后面的命令位; -typedef enum +enum { RECEIVE_DATA_LEBGTH_ERROR = 1, RECEIVE_MINI_DATA = 2, @@ -2469,7 +2469,7 @@ const CString Wifi_Module_Status[] = _T("Wifi SSID Password Error") }; -typedef enum +enum { WIFI_NONE, WIFI_NO_WIFI, @@ -2676,13 +2676,13 @@ const CString Airlab_Unit_String[] = _T("Lux") }; -typedef struct FloorInfo +struct FloorInfo { CString csName; int xindex; }; -typedef struct RoomInfo +struct RoomInfo { FloorInfo nFloor; CString csName; diff --git a/T3000/schedule.h b/T3000/schedule.h index 4db154745..372b4bfc5 100644 --- a/T3000/schedule.h +++ b/T3000/schedule.h @@ -15,7 +15,7 @@ #define MAX_AR 16 #define MAX_INTERVALS_PER_DAY 4 -typedef enum +enum { WR_DESCRIPTION , AR_DESCRIPTION ,