| id | REF-021 | |||||
|---|---|---|---|---|---|---|
| workflow | github | |||||
| github_issue | emulebb/emulebb#88 | |||||
| title | Remove blanket warning suppressions and replace deprecated Winsock APIs | |||||
| status | DEFERRED | |||||
| priority | Minor | |||||
| category | refactor | |||||
| labels |
|
|||||
| milestone | ||||||
| created | 2026-04-08 | |||||
| source | AUDIT-WWMOD.md (WWMOD_007, WWMOD_008, WWMOD_030) |
Workflow status is tracked in GitHub: emulebb/emulebb#88. This local document is retained as an engineering spec/evidence record.
Historical reference only:
stale-v0.72a-experimental-cleanandanalysis\stale-v0.72a-experimental-cleanare retired reference sources, not active branch targets or current baselines. Use them only as provenance or idea-extraction sources; landed status is determined againstmain. See Historical References.
Two blanket #define suppressions in stdafx.h silence entire classes of
security and deprecation warnings, hiding real issues. In parallel, a handful
of deprecated Winsock IPv4-only APIs (inet_addr, inet_ntoa) remain in use
despite being unsafe and deprecated since Vista.
2026-04-19: Explicitly deferred by product decision.
This item is tracked as Deferred to preserve that decision in the active
backlog.
Current rationale:
- the remaining deprecated-Winsock usage is real but low practical impact for the current branch
- the cleanup is broad and mechanical, not a targeted correctness/stability fix
- current quality work is prioritizing narrower runtime-risk items first
This item remains valid backlog work, but it should stay deferred unless the warning-floor reduction effort or networking modernization work is explicitly reprioritized.
The current Stdafx.h blanket warning pragmas are not benign, but they are also
not the only source of warning debt. The active Release|x64 app build on
2026-05-02 succeeded while still reporting warnings:
- reference log:
EMULEBB_WORKSPACE_ROOT\workspaces\workspace\state\build-logs\20260502-112930 - workspace summary:
862warnings forAPP main - raw MSBuild footer:
391 Warning(s) - de-duplicated located compiler warning sites:
379
The broad Stdafx.h:43-69 suppressions currently hide warning families such as
unsafe function-pointer casts (C4191), hidden virtual overrides
(C4263-C4266), signed/unsigned conversions (C4365), switch-enum coverage
(C4061/C4062), local-static initialization concerns (C4640), and object
layout/generated-member noise (C4625, C4626, C4820, C5026, C5027).
Removing all of them in one pass would produce a large mixed queue of real
defects, MFC-era framework noise, and low-value style cleanup.
Actual risk split:
- high correctness value: pointer/handle truncation, integer narrowing, implicit fallthroughs, non-portable varargs, throwing C/Win32 callbacks, and hidden virtual overrides
- medium value: numeric precision warnings in transfer, scheduling, scoring, rate-limit, and persisted-value code
- low value unless adjacent code is already being changed:
registercleanup, unused parameters, padding/layout noise, inline decisions, and unreferenced internal functions
The detailed current warning map, including counts by warning code, hotspot
files, concrete example call sites, and linker/dependency impact, is tracked in
CI-010. Use that item to prioritize app-local source fixes before attempting
to remove the global suppression block wholesale.
Current main still defines:
Stdafx.h:73-74—_CRT_SECURE_NO_DEPRECATEStdafx.h:99-100—_WINSOCK_DEPRECATED_NO_WARNINGSemule.vcxproj:310—_CRT_SECURE_NO_DEPRECATEinjected again via project settings
Current deprecated / legacy call-site counts in srchybrid:
15inet_addr4inet_ntoa0gethostbyname49printf-family legacy calls (_stprintf,_sntprintf,wsprintf,sprintf)
Representative live Winsock sites include:
AddSourceDlg.cpp:130AsyncProxySocketLayer.cpp:732AsyncSocketEx.cpp:896,1001,1029AsyncSocketExLayer.cpp:404,448IPFilterDlg.cpp:545KademliaUDPListener.cpp:81Preferences.cpp:2489ServerConnect.cpp:540ServerSocket.cpp:230UDPSocket.cpp:470,786URLClient.cpp:118WebServer.cpp:374,1187WebSocket.cpp:434UPnPImplWinServ.cpp:574
Deeper revalidation on 2026-04-14 tightened two parts of the picture:
- all
4remaininginet_ntoasites are concentrated inAsyncSocketEx.cpp(1001,1029) andAsyncSocketExLayer.cpp(404,448) WSAAsyncGetHostByNameis still live inAsyncSocketEx.cpp,DownloadQueue.cpp,EmuleDlg.cpp, andUDPSocket.cpp, but that resolver redesign is tracked separately byREF-030
Also note that several raw copy sites (CustomAutoComplete.cpp:230,
EmuleDlg.cpp:3770, FileInfoDialog.cpp:756) will re-surface once the blanket
warning suppressions are removed. They are adjacent cleanup, even though they
are not Winsock calls.
// stdafx.h — near top:
#define _CRT_SECURE_NO_DEPRECATEThis silences all CRT security deprecation warnings (strcpy → strcpy_s,
sprintf → sprintf_s, etc.). Removing it will reveal real unsafe-string
call sites. Fix the revealed warnings rather than re-suppressing them.
Expected newly-visible warnings: sprintf, _stprintf, strcat, etc. —
coordinate with REF-023 (unsafe printf replacement) to address them.
// stdafx.h:
#define _WINSOCK_DEPRECATED_NO_WARNINGSThis silences warnings about deprecated Winsock functions (inet_addr,
inet_ntoa, gethostbyname, etc.). Removing it will identify all call sites
that need updating.
Known deprecated-Winsock call sites (partially fixed on stale branch — NOT in main for most files):
| Function | Replacement |
|---|---|
inet_addr(str) |
inet_pton(AF_INET, str, &addr) |
inet_ntoa(addr) |
inet_ntop(AF_INET, &addr, buf, sizeof(buf)) |
gethostbyname(host) |
getaddrinfo(host, ...) |
Primary files to audit:
srchybrid/ServerConnect.cppsrchybrid/IPFilter.cppsrchybrid/ClientUDPSocket.cppsrchybrid/KademliaUDPListener.cppsrchybrid/BaseClient.cpp- Any file using
inet_addrorinet_ntoa
Two-pass approach recommended:
- Remove the
#define _WINSOCK_DEPRECATED_NO_WARNINGSsuppression - Fix all newly-surfaced warnings using
inet_pton/inet_ntop
- Remove
_CRT_SECURE_NO_DEPRECATE(will reveal sprintf sites — do NOT blindly re-add; fix sites incrementally or coordinate with REF-023) - Remove
_WINSOCK_DEPRECATED_NO_WARNINGS - Fix all
inet_addr/inet_ntoacall sites - Rebuild clean with zero new warnings
| File | Change |
|---|---|
srchybrid/stdafx.h |
Remove both #define suppressions |
srchybrid/emule.vcxproj |
Remove project-wide _CRT_SECURE_NO_DEPRECATE injection |
srchybrid/ServerConnect.cpp |
Replace deprecated Winsock calls |
srchybrid/IPFilter.cpp |
Replace deprecated Winsock calls |
| Other files surfaced by compiler | Replace deprecated CRT / Winsock calls |
-
_CRT_SECURE_NO_DEPRECATEremoved fromstdafx.h -
_CRT_SECURE_NO_DEPRECATEremoved from project-wide preprocessor definitions -
_WINSOCK_DEPRECATED_NO_WARNINGSremoved fromstdafx.h - Zero deprecated-Winsock warnings in a clean build
- Zero CRT security deprecation warnings from files touched in this change
-
inet_addr/inet_ntoareplaced withinet_pton/inet_ntopthroughout the codebase
Status in stale-v0.72a-experimental-clean: Done. Deprecated Winsock call count dropped from 28 in main to ~0 in experimental. Done in two steps:
d0a1c11(WIP: replace inet_addr in socket connect paths) —inet_addrreplaced withinet_ptoninServerConnect.cpp,BindAddressResolver.cpp, and other connect paths8656e2dand related —_WINSOCK_DEPRECATED_NO_WARNINGSsuppression removed fromstdafx.h;gethostbynamereplaced withgetaddrinfod8a4af3(BUILD: enable C++20 and remove bootstrap build) + warning cleanup removed_CRT_SECURE_NO_DEPRECATE
Note on warning suppressions: Main still has 64 #pragma warning(disable/suppress) directives; experimental brought this down to 63 (near-identical), so the blanket per-file suppressions remain. The primary win in experimental was removing the global stdafx.h defines and fixing the actual sites they were covering.
Porting note: Start with removing _WINSOCK_DEPRECATED_NO_WARNINGS from stdafx.h and fixing the inet_addr/inet_ntoa sites one file at a time. The experimental branch has BindAddressResolver.cpp/h (new file) that abstracts the bind-address resolution — consider porting that too.