Fix C4267 warnings in printing subsystem and add lwip suppression

Co-authored-by: tkreuzer <313067+tkreuzer@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-08-21 20:34:44 +00:00
parent 39ed4e5e6b
commit 050be00645
8 changed files with 17 additions and 11 deletions

View File

@@ -6,6 +6,12 @@ set(LWIP_INCLUDE_DIRS
)
include(${LWIP_DIR}/src/Filelists.cmake)
add_dependencies(lwipcore xdk)
if(MSVC AND ARCH STREQUAL "amd64")
# lwip is 3rd party code - suppress C4267 warnings
target_compile_options(lwipcore PRIVATE "/wd4267")
endif()
add_subdirectory(ip)
add_definitions(

View File

@@ -347,7 +347,7 @@ GetPrinterDataExA(HANDLE hPrinter, LPCSTR pKeyName, LPCSTR pValueName, LPDWORD p
if (pKeyName)
{
// Convert pKeyName to a Unicode string pwszKeyName
cch = strlen(pKeyName);
cch = (DWORD)strlen(pKeyName);
pwszKeyName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(WCHAR));
if (!pwszKeyName)
@@ -363,7 +363,7 @@ GetPrinterDataExA(HANDLE hPrinter, LPCSTR pKeyName, LPCSTR pValueName, LPDWORD p
if (pValueName)
{
// Convert pValueName to a Unicode string pwszValueName
cch = strlen(pValueName);
cch = (DWORD)strlen(pValueName);
pwszValueName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(WCHAR));
if (!pwszValueName)
@@ -561,7 +561,7 @@ SetPrinterDataExA(HANDLE hPrinter, LPCSTR pKeyName, LPCSTR pValueName, DWORD Typ
if (pKeyName)
{
// Convert pKeyName to a Unicode string pwszKeyName
cch = strlen(pKeyName);
cch = (DWORD)strlen(pKeyName);
pwszKeyName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(WCHAR));
if (!pwszKeyName)
@@ -577,7 +577,7 @@ SetPrinterDataExA(HANDLE hPrinter, LPCSTR pKeyName, LPCSTR pValueName, DWORD Typ
if (pValueName)
{
// Convert pValueName to a Unicode string pwszValueName
cch = strlen(pValueName);
cch = (DWORD)strlen(pValueName);
pwszValueName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(WCHAR));
if (!pwszValueName)

View File

@@ -45,7 +45,7 @@ _GetNonspooledPortName(PCWSTR pwszPortNameWithoutColon, PWSTR* ppwszNonspooledPo
{
DWORD cchPortNameWithoutColon;
cchPortNameWithoutColon = wcslen(pwszPortNameWithoutColon);
cchPortNameWithoutColon = (DWORD)wcslen(pwszPortNameWithoutColon);
*ppwszNonspooledPortName = DllAllocSplMem((cchNonspooledPrefix + cchPortNameWithoutColon + 1) * sizeof(WCHAR));
if (!*ppwszNonspooledPortName)
@@ -192,7 +192,7 @@ _CreateNonspooledPort(PLOCALMON_PORT pPort)
goto Cleanup;
}
cchPortNameWithoutColon = wcslen(pwszPortNameWithoutColon);
cchPortNameWithoutColon = (DWORD)wcslen(pwszPortNameWithoutColon);
// The spooler has usually remapped the legacy port to a named pipe of the format in wszSpoolerNamedPipe.
// Construct the device name of this pipe.

View File

@@ -144,7 +144,7 @@ GetPortNameWithoutColon(PCWSTR pwszPortName, PWSTR* ppwszPortNameWithoutColon)
DWORD cchPortNameWithoutColon;
// Compute the string length of pwszPortNameWithoutColon.
cchPortNameWithoutColon = wcslen(pwszPortName) - 1;
cchPortNameWithoutColon = (DWORD)wcslen(pwszPortName) - 1;
// Check if pwszPortName really has a colon as the last character.
if (pwszPortName[cchPortNameWithoutColon] != L':')

View File

@@ -330,7 +330,7 @@ CreateJob(PLOCAL_PRINTER_HANDLE pPrinterHandle)
goto Cleanup;
}
cchMachineName = wcslen(pwszMachineName);
cchMachineName = (DWORD)wcslen(pwszMachineName);
pJob->pwszMachineName = DllAllocSplMem((cchMachineName + cchDoubleBackslash + 1) * sizeof(WCHAR));
CopyMemory(pJob->pwszMachineName, wszDoubleBackslash, cchDoubleBackslash * sizeof(WCHAR));
CopyMemory(&pJob->pwszMachineName[cchDoubleBackslash], pwszMachineName, (cchMachineName + 1) * sizeof(WCHAR));

View File

@@ -1465,7 +1465,7 @@ LocalOpenPrinter(PWSTR lpPrinterName, HANDLE* phPrinter, PPRINTER_DEFAULTSW pDef
if (pwszSecondParameter)
cchFirstParameter = pwszSecondParameter - p;
else
cchFirstParameter = wcslen(lpPrinterName);
cchFirstParameter = (DWORD)wcslen(lpPrinterName);
// We must have at least one parameter.
if (!cchFirstParameter && !pwszSecondParameter)

View File

@@ -29,7 +29,7 @@ PrintingThreadProc(PLOCAL_JOB pJob)
// Prepare the pPrinterName parameter.
// This is the string for LocalOpenPrinter to open a port (e.g. "LPT1:, Port").
cchPortName = wcslen(pJob->pPrinter->pPort->pwszName);
cchPortName = (DWORD)wcslen(pJob->pPrinter->pPort->pwszName);
pwszPrinterPort = DllAllocSplMem(cchPortName * sizeof(WCHAR) + sizeof(wszPortAppendix));
if (!pwszPrinterPort)
{

View File

@@ -44,7 +44,7 @@ _OpenEnvironment(PCWSTR pEnvironment, PHKEY hKey)
}
// Construct the registry key of the demanded environment.
cchEnvironment = wcslen(pEnvironment);
cchEnvironment = (DWORD)wcslen(pEnvironment);
pwszEnvironmentKey = DllAllocSplMem((cchEnvironmentsKey + cchEnvironment + 1) * sizeof(WCHAR));
if (!pwszEnvironmentKey)
{