Merge pull request #10580 from akallabeth/more-warn-fixes
More warn fixes
This commit is contained in:
commit
9d10923524
@ -37,6 +37,7 @@ Checks: >
|
||||
-cppcoreguidelines-avoid-non-const-global-variables,
|
||||
-cppcoreguidelines-macro-to-enum,
|
||||
-cppcoreguidelines-pro-type-vararg,
|
||||
-cppcoreguidelines-no-malloc,
|
||||
-google-readability-braces-around-statements,
|
||||
-google-readability-todo,
|
||||
-hicpp-braces-around-statements,
|
||||
@ -45,6 +46,7 @@ Checks: >
|
||||
-hicpp-signed-bitwise,
|
||||
-hicpp-uppercase-literal-suffix,
|
||||
-hicpp-vararg,
|
||||
-hicpp-no-malloc,
|
||||
-llvm-header-guard,
|
||||
-llvm-include-order,
|
||||
-llvm-qualified-auto,
|
||||
@ -60,7 +62,8 @@ Checks: >
|
||||
-readability-magic-numbers,
|
||||
-readability-qualified-auto,
|
||||
-readability-uppercase-literal-suffix,
|
||||
-performance-no-int-to-ptr
|
||||
-performance-no-int-to-ptr,
|
||||
-performance-avoid-endl
|
||||
WarningsAsErrors: ''
|
||||
HeaderFilterRegex: ''
|
||||
FormatStyle: file
|
||||
|
@ -335,7 +335,8 @@ static UINT location_send(LocationClientContext* context, LOCATION_PDUTYPE type,
|
||||
IWTSVirtualChannel* channel = cb->channel;
|
||||
WINPR_ASSERT(channel);
|
||||
|
||||
LOCATION_CALLBACK* callback = (LOCATION_CALLBACK*)loc->baseDynPlugin.channel_callbacks;
|
||||
const LOCATION_CALLBACK* callback =
|
||||
(const LOCATION_CALLBACK*)loc->baseDynPlugin.channel_callbacks;
|
||||
WINPR_ASSERT(callback);
|
||||
|
||||
UINT32 res = ERROR_INTERNAL_ERROR;
|
||||
|
@ -1536,7 +1536,9 @@ static UINT rdpdr_server_receive_io_lock_control_request(RdpdrServerContext* con
|
||||
|
||||
WLog_Print(context->priv->log, WLOG_WARN,
|
||||
"[MS-RDPEFS] 2.2.3.3.12 Server Drive Lock Control Request (DR_DRIVE_LOCK_REQ) "
|
||||
"not implemented");
|
||||
"[Lock=0x%08" PRIx32 "]"
|
||||
"not implemented",
|
||||
Lock);
|
||||
WLog_Print(context->priv->log, WLOG_WARN, "TODO");
|
||||
|
||||
return CHANNEL_RC_OK;
|
||||
|
@ -91,6 +91,8 @@ bool SDLConnectionDialog::showError(const char* fmt, ...)
|
||||
va_start(ap, fmt);
|
||||
auto rc = show(MSG_ERROR, fmt, ap);
|
||||
va_end(ap);
|
||||
if (!rc)
|
||||
return rc;
|
||||
return setTimer();
|
||||
}
|
||||
|
||||
|
@ -188,10 +188,24 @@ static BOOL sdl_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y)
|
||||
|
||||
BOOL sdl_register_pointer(rdpGraphics* graphics)
|
||||
{
|
||||
const rdpPointer pointer = { sizeof(sdlPointer), sdl_Pointer_New,
|
||||
sdl_Pointer_Free, sdl_Pointer_Set,
|
||||
sdl_Pointer_SetNull, sdl_Pointer_SetDefault,
|
||||
sdl_Pointer_SetPosition, { 0 } };
|
||||
const rdpPointer pointer = { sizeof(sdlPointer),
|
||||
sdl_Pointer_New,
|
||||
sdl_Pointer_Free,
|
||||
sdl_Pointer_Set,
|
||||
sdl_Pointer_SetNull,
|
||||
sdl_Pointer_SetDefault,
|
||||
sdl_Pointer_SetPosition,
|
||||
{},
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr,
|
||||
{} };
|
||||
graphics_register_pointer(graphics, &pointer);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -91,6 +91,8 @@ bool SDLConnectionDialog::showError(const char* fmt, ...)
|
||||
va_start(ap, fmt);
|
||||
auto rc = show(MSG_ERROR, fmt, ap);
|
||||
va_end(ap);
|
||||
if (!rc)
|
||||
return rc;
|
||||
return setTimer();
|
||||
}
|
||||
|
||||
|
@ -186,10 +186,10 @@ static BOOL sdl_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y)
|
||||
|
||||
BOOL sdl_register_pointer(rdpGraphics* graphics)
|
||||
{
|
||||
const rdpPointer pointer = { sizeof(sdlPointer), sdl_Pointer_New,
|
||||
sdl_Pointer_Free, sdl_Pointer_Set,
|
||||
sdl_Pointer_SetNull, sdl_Pointer_SetDefault,
|
||||
sdl_Pointer_SetPosition, { 0 } };
|
||||
const rdpPointer pointer = {
|
||||
sizeof(sdlPointer), sdl_Pointer_New, sdl_Pointer_Free, sdl_Pointer_Set, sdl_Pointer_SetNull,
|
||||
sdl_Pointer_SetDefault, sdl_Pointer_SetPosition, {}, 0, 0, 0, 0, 0, 0, 0, nullptr, nullptr,
|
||||
{};
|
||||
graphics_register_pointer(graphics, &pointer);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1001,9 +1001,7 @@ static char* extract_authorization_code(char* url)
|
||||
|
||||
end = strchr(p, '&');
|
||||
if (end)
|
||||
*end = 0;
|
||||
else
|
||||
end = strchr(p, '\0');
|
||||
*end = '\0';
|
||||
|
||||
return p;
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ if (ENABLE_WARNING_VERBOSE)
|
||||
-Wall
|
||||
-Wpedantic
|
||||
-Wno-padded
|
||||
-Wno-switch-enum
|
||||
-Wno-cast-align
|
||||
-Wno-declaration-after-statement
|
||||
-Wno-unsafe-buffer-usage
|
||||
|
@ -360,7 +360,8 @@ static BOOL ffmpeg_open_context(FREERDP_DSP_CONTEXT* WINPR_RESTRICT context)
|
||||
context->buffered->format = context->resampled->format;
|
||||
context->buffered->nb_samples = context->context->frame_size;
|
||||
|
||||
if ((ret = av_frame_get_buffer(context->buffered, 1)) < 0)
|
||||
ret = av_frame_get_buffer(context->buffered, 1);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -1065,6 +1065,8 @@ static BOOL test_encode_decode(const char* path)
|
||||
rc = progressive_compress(progressiveEnc, image->data, image->scanline * image->height,
|
||||
ColorFormat, image->width, image->height, image->scanline, NULL,
|
||||
&dstData, &dstSize);
|
||||
if (rc < 0)
|
||||
goto fail;
|
||||
|
||||
// Progressive decode
|
||||
rc = progressive_create_surface_context(progressiveDec, 0, image->width, image->height);
|
||||
|
@ -133,7 +133,6 @@ static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, const
|
||||
UINT32 DstWidth, UINT32 DstHeight, UINT32 bpp, UINT32 length,
|
||||
BOOL compressed, UINT32 codecId)
|
||||
{
|
||||
int status = 0;
|
||||
UINT32 SrcSize = length;
|
||||
rdpGdi* gdi = context->gdi;
|
||||
UINT32 size = DstWidth * DstHeight;
|
||||
@ -169,14 +168,12 @@ static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, const
|
||||
WLog_ERR(TAG, "rfx_process_message failed");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
status = 1;
|
||||
}
|
||||
else if (codecId == RDP_CODEC_ID_NSCODEC)
|
||||
{
|
||||
status = nsc_process_message(context->codecs->nsc, 32, DstWidth, DstHeight, pSrcData,
|
||||
SrcSize, bitmap->data, bitmap->format, 0, 0, 0, DstWidth,
|
||||
DstHeight, FREERDP_FLIP_VERTICAL);
|
||||
const int status = nsc_process_message(
|
||||
context->codecs->nsc, 32, DstWidth, DstHeight, pSrcData, SrcSize, bitmap->data,
|
||||
bitmap->format, 0, 0, 0, DstWidth, DstHeight, FREERDP_FLIP_VERTICAL);
|
||||
|
||||
if (status < 1)
|
||||
{
|
||||
|
@ -96,8 +96,6 @@ static WINPR_NORETURN(void buildconfig(const char* app))
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
proxyConfig* config = NULL;
|
||||
char* config_path = "config.ini";
|
||||
int status = -1;
|
||||
|
||||
pf_server_register_signal_handlers();
|
||||
@ -110,31 +108,29 @@ int main(int argc, char* argv[])
|
||||
if (argc < 2)
|
||||
usage(argv[0]);
|
||||
|
||||
const char* arg = argv[1];
|
||||
|
||||
if (_stricmp(arg, "-h") == 0)
|
||||
usage(argv[0]);
|
||||
else if (_stricmp(arg, "--help") == 0)
|
||||
usage(argv[0]);
|
||||
else if (_stricmp(arg, "--buildconfig") == 0)
|
||||
buildconfig(argv[0]);
|
||||
else if (_stricmp(arg, "--dump-config") == 0)
|
||||
{
|
||||
const char* arg = argv[1];
|
||||
|
||||
if (_stricmp(arg, "-h") == 0)
|
||||
if (argc <= 2)
|
||||
usage(argv[0]);
|
||||
else if (_stricmp(arg, "--help") == 0)
|
||||
usage(argv[0]);
|
||||
else if (_stricmp(arg, "--buildconfig") == 0)
|
||||
buildconfig(argv[0]);
|
||||
else if (_stricmp(arg, "--dump-config") == 0)
|
||||
{
|
||||
if (argc <= 2)
|
||||
usage(argv[0]);
|
||||
pf_server_config_dump(argv[2]);
|
||||
status = 0;
|
||||
goto fail;
|
||||
}
|
||||
else if (_stricmp(arg, "-v") == 0)
|
||||
version(argv[0]);
|
||||
else if (_stricmp(arg, "--version") == 0)
|
||||
version(argv[0]);
|
||||
config_path = argv[1];
|
||||
pf_server_config_dump(argv[2]);
|
||||
status = 0;
|
||||
goto fail;
|
||||
}
|
||||
else if (_stricmp(arg, "-v") == 0)
|
||||
version(argv[0]);
|
||||
else if (_stricmp(arg, "--version") == 0)
|
||||
version(argv[0]);
|
||||
const char* config_path = argv[1];
|
||||
|
||||
config = pf_server_config_load_file(config_path);
|
||||
proxyConfig* config = pf_server_config_load_file(config_path);
|
||||
if (!config)
|
||||
goto fail;
|
||||
|
||||
|
@ -377,7 +377,9 @@ static BOOL filter_dyn_channel_intercept(proxyPlugin* plugin, proxyData* pdata,
|
||||
|
||||
if (state->skip())
|
||||
{
|
||||
state->skip(inputDataLength);
|
||||
if (!state->skip(inputDataLength))
|
||||
return FALSE;
|
||||
|
||||
if (state->drop())
|
||||
{
|
||||
WLog_WARN(TAG,
|
||||
|
@ -70,8 +70,6 @@ typedef struct comm_device COMM_DEVICE;
|
||||
static COMM_DEVICE** sCommDevices = NULL;
|
||||
static CRITICAL_SECTION sCommDevicesLock;
|
||||
|
||||
static HANDLE_CREATOR sCommHandleCreator = { 0 };
|
||||
|
||||
static pthread_once_t sCommInitialized = PTHREAD_ONCE_INIT;
|
||||
|
||||
static int CommGetFd(HANDLE handle)
|
||||
|
@ -70,14 +70,13 @@ static const ULONG SERCX2_SYS_SUPPORTED_EV_MASK =
|
||||
/* use Serial.sys for basis (not SerCx.sys) */
|
||||
static BOOL set_wait_mask(WINPR_COMM* pComm, const ULONG* pWaitMask)
|
||||
{
|
||||
ULONG possibleMask = 0;
|
||||
SERIAL_DRIVER* pSerialSys = SerialSys_s();
|
||||
const SERIAL_DRIVER* pSerialSys = SerialSys_s();
|
||||
|
||||
WINPR_ASSERT(pComm);
|
||||
WINPR_ASSERT(pWaitMask);
|
||||
WINPR_ASSERT(pSerialSys);
|
||||
|
||||
possibleMask = *pWaitMask & SERCX2_SYS_SUPPORTED_EV_MASK;
|
||||
const ULONG possibleMask = *pWaitMask & SERCX2_SYS_SUPPORTED_EV_MASK;
|
||||
|
||||
if (possibleMask != *pWaitMask)
|
||||
{
|
||||
@ -97,7 +96,7 @@ static BOOL set_wait_mask(WINPR_COMM* pComm, const ULONG* pWaitMask)
|
||||
|
||||
static BOOL purge(WINPR_COMM* pComm, const ULONG* pPurgeMask)
|
||||
{
|
||||
SERIAL_DRIVER* pSerialSys = SerialSys_s();
|
||||
const SERIAL_DRIVER* pSerialSys = SerialSys_s();
|
||||
|
||||
WINPR_ASSERT(pComm);
|
||||
WINPR_ASSERT(pPurgeMask);
|
||||
|
@ -32,7 +32,7 @@ static BOOL set_handflow(WINPR_COMM* pComm, const SERIAL_HANDFLOW* pHandflow)
|
||||
{
|
||||
SERIAL_HANDFLOW SerCxHandflow;
|
||||
BOOL result = TRUE;
|
||||
SERIAL_DRIVER* pSerialSys = SerialSys_s();
|
||||
const SERIAL_DRIVER* pSerialSys = SerialSys_s();
|
||||
|
||||
memcpy(&SerCxHandflow, pHandflow, sizeof(SERIAL_HANDFLOW));
|
||||
|
||||
@ -121,10 +121,9 @@ static BOOL set_handflow(WINPR_COMM* pComm, const SERIAL_HANDFLOW* pHandflow)
|
||||
|
||||
static BOOL get_handflow(WINPR_COMM* pComm, SERIAL_HANDFLOW* pHandflow)
|
||||
{
|
||||
BOOL result = 0;
|
||||
SERIAL_DRIVER* pSerialSys = SerialSys_s();
|
||||
const SERIAL_DRIVER* pSerialSys = SerialSys_s();
|
||||
|
||||
result = pSerialSys->get_handflow(pComm, pHandflow);
|
||||
BOOL result = pSerialSys->get_handflow(pComm, pHandflow);
|
||||
|
||||
/* filter out unsupported bits by SerCx.sys
|
||||
*
|
||||
@ -153,10 +152,10 @@ static const ULONG SERCX_SYS_SUPPORTED_EV_MASK = SERIAL_EV_RXCHAR |
|
||||
|
||||
static BOOL set_wait_mask(WINPR_COMM* pComm, const ULONG* pWaitMask)
|
||||
{
|
||||
ULONG possibleMask = 0;
|
||||
SERIAL_DRIVER* pSerialSys = SerialSys_s();
|
||||
const SERIAL_DRIVER* pSerialSys = SerialSys_s();
|
||||
WINPR_ASSERT(pWaitMask);
|
||||
|
||||
possibleMask = *pWaitMask & SERCX_SYS_SUPPORTED_EV_MASK;
|
||||
const ULONG possibleMask = *pWaitMask & SERCX_SYS_SUPPORTED_EV_MASK;
|
||||
|
||||
if (possibleMask != *pWaitMask)
|
||||
{
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include <winpr/windows.h>
|
||||
#include <winpr/interlocked.h>
|
||||
|
||||
#define ITEM_COUNT 23
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WINPR_SLIST_ENTRY ItemEntry;
|
||||
@ -12,14 +14,14 @@ typedef struct
|
||||
|
||||
int TestInterlockedSList(int argc, char* argv[])
|
||||
{
|
||||
ULONG Count = 0;
|
||||
WINPR_PSLIST_ENTRY pFirstEntry = NULL;
|
||||
WINPR_PSLIST_HEADER pListHead = NULL;
|
||||
int rc = -1;
|
||||
|
||||
WINPR_UNUSED(argc);
|
||||
WINPR_UNUSED(argv);
|
||||
|
||||
/* Initialize the list header to a MEMORY_ALLOCATION_ALIGNMENT boundary. */
|
||||
pListHead = (WINPR_PSLIST_HEADER)winpr_aligned_malloc(sizeof(WINPR_SLIST_HEADER),
|
||||
MEMORY_ALLOCATION_ALIGNMENT);
|
||||
WINPR_PSLIST_HEADER pListHead = (WINPR_PSLIST_HEADER)winpr_aligned_malloc(
|
||||
sizeof(WINPR_SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT);
|
||||
|
||||
if (!pListHead)
|
||||
{
|
||||
@ -30,7 +32,7 @@ int TestInterlockedSList(int argc, char* argv[])
|
||||
InitializeSListHead(pListHead);
|
||||
|
||||
/* Insert 10 items into the list. */
|
||||
for (Count = 1; Count <= 10; Count += 1)
|
||||
for (ULONG Count = 0; Count < ITEM_COUNT; Count++)
|
||||
{
|
||||
PPROGRAM_ITEM pProgramItem =
|
||||
(PPROGRAM_ITEM)winpr_aligned_malloc(sizeof(PROGRAM_ITEM), MEMORY_ALLOCATION_ALIGNMENT);
|
||||
@ -38,26 +40,32 @@ int TestInterlockedSList(int argc, char* argv[])
|
||||
if (!pProgramItem)
|
||||
{
|
||||
printf("Memory allocation failed.\n");
|
||||
return -1;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
pProgramItem->Signature = Count;
|
||||
pFirstEntry = InterlockedPushEntrySList(pListHead, &(pProgramItem->ItemEntry));
|
||||
pProgramItem->Signature = Count + 1UL;
|
||||
WINPR_PSLIST_ENTRY pFirstEntry =
|
||||
InterlockedPushEntrySList(pListHead, &(pProgramItem->ItemEntry));
|
||||
if (((Count == 0) && pFirstEntry) || ((Count != 0) && !pFirstEntry))
|
||||
{
|
||||
printf("Error: List is empty.\n");
|
||||
winpr_aligned_free(pProgramItem);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove 10 items from the list and display the signature. */
|
||||
for (Count = 10; Count >= 1; Count -= 1)
|
||||
for (ULONG Count = 0; Count < ITEM_COUNT; Count++)
|
||||
{
|
||||
PPROGRAM_ITEM pProgramItem = NULL;
|
||||
WINPR_PSLIST_ENTRY pListEntry = InterlockedPopEntrySList(pListHead);
|
||||
|
||||
if (!pListEntry)
|
||||
{
|
||||
printf("List is empty.\n");
|
||||
return -1;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
pProgramItem = (PPROGRAM_ITEM)pListEntry;
|
||||
PPROGRAM_ITEM pProgramItem = (PPROGRAM_ITEM)pListEntry;
|
||||
printf("Signature is %" PRIu32 "\n", pProgramItem->Signature);
|
||||
|
||||
/*
|
||||
@ -71,15 +79,17 @@ int TestInterlockedSList(int argc, char* argv[])
|
||||
}
|
||||
|
||||
/* Flush the list and verify that the items are gone. */
|
||||
pFirstEntry = InterlockedPopEntrySList(pListHead);
|
||||
WINPR_PSLIST_ENTRY pFirstEntry = InterlockedPopEntrySList(pListHead);
|
||||
|
||||
if (pFirstEntry)
|
||||
{
|
||||
printf("Error: List is not empty.\n");
|
||||
return -1;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
rc = 0;
|
||||
fail:
|
||||
winpr_aligned_free(pListHead);
|
||||
|
||||
return 0;
|
||||
return rc;
|
||||
}
|
||||
|
@ -608,7 +608,6 @@ static SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
|
||||
SSPI_CREDENTIALS* credentials = NULL;
|
||||
PSecBuffer input_buffer = NULL;
|
||||
PSecBuffer output_buffer = NULL;
|
||||
PSecBuffer channel_bindings = NULL;
|
||||
|
||||
/* behave like windows SSPIs that don't want empty context */
|
||||
if (phContext && !phContext->dwLower && !phContext->dwUpper)
|
||||
@ -619,7 +618,6 @@ static SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
|
||||
if (pInput)
|
||||
{
|
||||
input_buffer = sspi_FindSecBuffer(pInput, SECBUFFER_TOKEN);
|
||||
channel_bindings = sspi_FindSecBuffer(pInput, SECBUFFER_CHANNEL_BINDINGS);
|
||||
}
|
||||
|
||||
if (!context)
|
||||
@ -686,7 +684,7 @@ static SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
|
||||
if (input_buffer->cbBuffer < 1)
|
||||
return SEC_E_INVALID_TOKEN;
|
||||
|
||||
channel_bindings = sspi_FindSecBuffer(pInput, SECBUFFER_CHANNEL_BINDINGS);
|
||||
PSecBuffer channel_bindings = sspi_FindSecBuffer(pInput, SECBUFFER_CHANNEL_BINDINGS);
|
||||
|
||||
if (channel_bindings)
|
||||
{
|
||||
|
@ -396,7 +396,6 @@ static int test_ntlm_server_authenticate(TEST_NTLM_SERVER* ntlm)
|
||||
ntlm->outputBuffer[0].BufferType = SECBUFFER_TOKEN;
|
||||
ntlm->outputBuffer[0].cbBuffer = ntlm->cbMaxToken;
|
||||
ntlm->outputBuffer[0].pvBuffer = malloc(ntlm->outputBuffer[0].cbBuffer);
|
||||
BOOL hash_set = FALSE;
|
||||
|
||||
if (!ntlm->outputBuffer[0].pvBuffer)
|
||||
return -1;
|
||||
@ -406,7 +405,7 @@ static int test_ntlm_server_authenticate(TEST_NTLM_SERVER* ntlm)
|
||||
ntlm->fContextReq, SECURITY_NATIVE_DREP, &ntlm->context, &ntlm->outputBufferDesc,
|
||||
&ntlm->pfContextAttr, &ntlm->expiration);
|
||||
|
||||
if (!hash_set && status == SEC_I_CONTINUE_NEEDED)
|
||||
if (status == SEC_I_CONTINUE_NEEDED)
|
||||
{
|
||||
SecPkgContext_AuthNtlmHash AuthNtlmHash = { 0 };
|
||||
|
||||
@ -424,8 +423,6 @@ static int test_ntlm_server_authenticate(TEST_NTLM_SERVER* ntlm)
|
||||
status =
|
||||
ntlm->table->SetContextAttributes(&ntlm->context, SECPKG_ATTR_AUTH_NTLM_HASH,
|
||||
&AuthNtlmHash, sizeof(SecPkgContext_AuthNtlmHash));
|
||||
|
||||
hash_set = TRUE;
|
||||
}
|
||||
|
||||
if ((status != SEC_E_OK) && (status != SEC_I_CONTINUE_NEEDED))
|
||||
|
@ -271,12 +271,11 @@ static BOOL WLog_PacketMessage_Write_EthernetHeader(wPcap* pcap, wEthernetHeader
|
||||
|
||||
static UINT16 IPv4Checksum(const BYTE* ipv4, int length)
|
||||
{
|
||||
UINT16 tmp16 = 0;
|
||||
long checksum = 0;
|
||||
|
||||
while (length > 1)
|
||||
{
|
||||
tmp16 = *((UINT16*)ipv4);
|
||||
const UINT16 tmp16 = *((const UINT16*)ipv4);
|
||||
checksum += tmp16;
|
||||
length -= 2;
|
||||
ipv4 += 2;
|
||||
|
Loading…
Reference in New Issue
Block a user