Skip to content

Commit

Permalink
Suppress or fix various issues found by clang-tidy v12 and recent cpp…
Browse files Browse the repository at this point in the history
…check. (microsoft#1834)
  • Loading branch information
larseggert authored Jul 21, 2021
1 parent 7e8f28f commit 9219d27
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -567,20 +567,29 @@ if(QUIC_CODE_CHECK)
message(STATUS "Found clang-tidy: ${CLANGTIDY}")
set(CLANG_TIDY_CHECKS *
# add checks to ignore here:
-altera-struct-pack-align
-android-cloexec-fopen
-android-cloexec-socket
-bugprone-macro-parentheses
-bugprone-narrowing-conversions
-bugprone-reserved-identifier
-bugprone-sizeof-expression
-cert-dcl37-c
-cert-dcl51-cpp
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling
-clang-diagnostic-microsoft-anon-tag
-concurrency-mt-unsafe
-cppcoreguidelines-avoid-magic-numbers
-cppcoreguidelines-avoid-non-const-global-variables
-cppcoreguidelines-init-variables
-cppcoreguidelines-narrowing-conversions
-google-readability-todo
-hicpp-no-assembler
-hicpp-signed-bitwise
-llvmlibc-restrict-system-libc-headers
-misc-no-recursion # do you really need recursion?
-readability-avoid-const-params-in-decls
-readability-function-cognitive-complexity
-readability-isolate-declaration
-readability-magic-numbers
-readability-non-const-parameter
Expand All @@ -600,6 +609,7 @@ if(QUIC_CODE_CHECK)
--suppress=varFuncNullUB
# these are finding potential logic issues, may want to suppress when focusing on nits:
--suppress=nullPointer --suppress=nullPointerRedundantCheck
--suppress=knownConditionTrueFalse
--enable=warning,style,performance,portability -D__linux__)
else()
message(STATUS "cppcheck not found")
Expand Down
2 changes: 1 addition & 1 deletion src/core/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ QuicSettingsLoad(
uint32_t Half;
uint64_t Full;
uint8_t Array[sizeof(uint64_t)];
} MultiValue;
} MultiValue = {0};
uint32_t ValueLen;

if (!Settings->IsSet.SendBufferingEnabled) {
Expand Down
8 changes: 4 additions & 4 deletions src/platform/datapath_kqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
#define __APPLE_USE_RFC_3542 1
// See netinet6/in6.h:46 for an explanation
#include "platform_internal.h"
#include <sys/types.h>
#include <fcntl.h>
#include <sys/event.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <sys/event.h>
#include <sys/time.h>
#include <fcntl.h>
#include <sys/types.h>
#ifdef QUIC_CLOG
#include "datapath_kqueue.c.clog.h"
#endif
Expand Down Expand Up @@ -943,7 +943,7 @@ CxPlatSocketContextInitialize(
SocketContext->SocketFd,
F_SETFL,
Flags);
if (Flags < 0) {
if (Result < 0) {
Status = errno;
QuicTraceEvent(
DatapathErrorStatus,
Expand Down
2 changes: 1 addition & 1 deletion src/platform/pcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ CxPlatPcpProcessDatagram(
return;
}

CXPLAT_PCP_EVENT Event;
CXPLAT_PCP_EVENT Event = {0};
CxPlatCopyMemory(Event.FAILURE.Nonce, Response->MAP.MappingNonce, CXPLAT_PCP_NONCE_LENGTH);
QUIC_ADDR InternalAddress;
CxPlatCopyMemory(&InternalAddress, &Datagram->Tuple->LocalAddress, sizeof(QUIC_ADDR));
Expand Down
1 change: 1 addition & 0 deletions src/platform/platform_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ CxPlatCurThreadID(
return syscall(SYS_gettid);

#elif defined(CX_PLATFORM_DARWIN)
// cppcheck-suppress duplicateExpression
CXPLAT_STATIC_ASSERT(sizeof(uint32_t) == sizeof(CXPLAT_THREAD_ID), "The cast depends on thread id being 32 bits");
uint64_t Tid;
int Res = pthread_threadid_np(NULL, &Tid);
Expand Down
2 changes: 1 addition & 1 deletion src/platform/tls_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2028,7 +2028,7 @@ CxPlatTlsParamGet(
const uint8_t* NegotiatedAlpn;
unsigned int NegotiatedAlpnLen = 0;
SSL_get0_alpn_selected(TlsContext->Ssl, &NegotiatedAlpn, &NegotiatedAlpnLen);
if (NegotiatedAlpnLen <= 0) {
if (NegotiatedAlpnLen == 0) {
QuicTraceEvent(
TlsError,
"[ tls][%p] ERROR, %s.",
Expand Down

0 comments on commit 9219d27

Please sign in to comment.