Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use warning level 4 by default #359

Merged
merged 2 commits into from
Jul 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions published/external/xdp/datapath.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ DECLARE_HANDLE(XDP_RX_QUEUE_HANDLE);
DECLARE_HANDLE(XDP_TX_QUEUE_HANDLE);
DECLARE_HANDLE(XDP_INTERFACE_HANDLE);

#pragma warning(push)
#pragma warning(disable:4324) // structure was padded due to alignment specifier

typedef struct DECLSPEC_CACHEALIGN _XDP_RING {
UINT32 ProducerIndex;
UINT32 ConsumerIndex;
Expand All @@ -23,6 +26,8 @@ typedef struct DECLSPEC_CACHEALIGN _XDP_RING {
//
} XDP_RING;

#pragma warning(pop)

C_ASSERT(sizeof(XDP_RING) == SYSTEM_CACHE_ALIGNMENT_SIZE);

inline
Expand Down
2 changes: 2 additions & 0 deletions src/xdp.cpp.props
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
POOL_ZERO_DOWN_LEVEL_SUPPORT=1;
%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<!-- Disable C26812: The enum type '' is unscoped. Prefer 'enum class' over 'enum' -->
<DisableSpecificWarnings>26812;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
Expand Down
10 changes: 10 additions & 0 deletions src/xdp/programinspect.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

#pragma once

#pragma warning(push)
#pragma warning(disable:4200) // nonstandard extension used: zero-sized array in struct/union

#pragma pack(push)
#pragma pack(1)
typedef struct QUIC_HEADER_INVARIANT {
Expand Down Expand Up @@ -94,6 +97,9 @@ typedef struct _XDP_PROGRAM_FRAME_CACHE {
XDP_PROGRAM_PAYLOAD_CACHE TransportPayload;
} XDP_PROGRAM_FRAME_CACHE;

#pragma warning(push)
#pragma warning(disable:4324) // structure was padded due to alignment specifier

typedef struct _XDP_PROGRAM {
//
// Storage for discontiguous headers.
Expand All @@ -105,6 +111,10 @@ typedef struct _XDP_PROGRAM {
XDP_RULE Rules[0];
} XDP_PROGRAM;

#pragma warning(pop)

#pragma warning(pop)

VOID
XdpProgramDeleteRule(
_Inout_ XDP_RULE *Rule
Expand Down
13 changes: 9 additions & 4 deletions src/xdpcfg/xdpcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,21 @@ SetDeviceSddl(
_In_ WCHAR **ArgV
)
{
SIZE_T StringLength;

if (ArgC < 3) {
Usage();
}

StringLength = wcslen(ArgV[2]) * sizeof(WCHAR) + sizeof(UNICODE_NULL);
if (StringLength > MAXDWORD) {
fprintf(stderr, "Integer overflow\n");
return EXIT_FAILURE;
}

if (!SetupDiSetClassRegistryPropertyW(
&XDP_DEVICE_CLASS_GUID, SPCRP_SECURITY_SDS, (BYTE *)ArgV[2],
wcslen(ArgV[2]) * sizeof(WCHAR) + sizeof(UNICODE_NULL), NULL, NULL)) {
&XDP_DEVICE_CLASS_GUID, SPCRP_SECURITY_SDS, (BYTE *)ArgV[2], (DWORD)StringLength,
NULL, NULL)) {
fprintf(stderr, "SetupDiSetClassRegistryPropertyW failed: 0x%x\n", GetLastError());
return EXIT_FAILURE;
}
Expand All @@ -63,6 +70,4 @@ wmain(
} else {
Usage();
}

return EXIT_SUCCESS;
}
1 change: 0 additions & 1 deletion test/pktfuzz/pktfuzz.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ LLVMFuzzerTestOneInput(
XDP_INSPECTION_CONTEXT InspectionContext = {0};
UINT32 FrameRingIndex;
UINT32 FragmentRingIndex = 0;
UINT16 BufferDataLength;
XDP_FRAME_WITH_EXTENSIONS *FrameExt = NULL;
XDP_BUFFER *Buffer;

Expand Down
1 change: 1 addition & 0 deletions test/pktfuzz/stubs/program.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ XdpProgramCapturePortSet(
_Inout_ XDP_PORT_SET *KernelPortSet
)
{
UNREFERENCED_PARAMETER(UserPortSet);
UNREFERENCED_PARAMETER(RequestorMode);

KernelPortSet->PortSet = DummyPortSet;
Expand Down
Loading