diff --git a/src/base.h b/src/base.h index 7831b2cd..b8a243e8 100644 --- a/src/base.h +++ b/src/base.h @@ -669,14 +669,19 @@ __extern_C key_t ftok(const char *, int); #endif #endif /* MDBX_GOOFY_MSVC_STATIC_ANALYZER */ -#if MDBX_GOOFY_MSVC_STATIC_ANALYZER +#if MDBX_GOOFY_MSVC_STATIC_ANALYZER || (defined(_MSC_VER) && _MSC_VER > 1919) #define MDBX_ANALYSIS_ASSUME(expr) __analysis_assume(expr) -#define MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(warn_id, note) \ - _Pragma(MDBX_STRINGIFY(prefast(suppress : warn_id))) +#ifdef _PREFAST_ +#define MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(warn_id) \ + __pragma(prefast(suppress : warn_id)) +#else +#define MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(warn_id) \ + __pragma(warning(suppress : warn_id)) +#endif #else #define MDBX_ANALYSIS_ASSUME(expr) assert(expr) -#define MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(warn_id, note) -#endif +#define MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(warn_id) +#endif /* MDBX_GOOFY_MSVC_STATIC_ANALYZER */ /*----------------------------------------------------------------------------*/ diff --git a/src/core.c b/src/core.c index c4681f7e..7b55cf63 100644 --- a/src/core.c +++ b/src/core.c @@ -8317,8 +8317,8 @@ static void cursors_eot(MDBX_txn *txn, const bool merge) { if (bk) { MDBX_xcursor *mx = mc->mc_xcursor; tASSERT(txn, txn->mt_parent != NULL); - MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER( - 6001, "Using uninitialized memory '*mc->mc_backup'."); + /* Zap: Using uninitialized memory '*mc->mc_backup'. */ + MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(6001); ENSURE(txn->mt_env, bk->mc_signature == MDBX_MC_LIVE); tASSERT(txn, mx == bk->mc_xcursor); if (stage == MDBX_MC_WAIT4EOT /* Cursor was closed by user */) diff --git a/src/lck-windows.c b/src/lck-windows.c index 10c24503..8ffccb1b 100644 --- a/src/lck-windows.c +++ b/src/lck-windows.c @@ -195,9 +195,9 @@ int mdbx_txn_lock(MDBX_env *env, bool dontwait) { } if (env->me_flags & MDBX_EXCLUSIVE) { - MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER( - 26115, "Failing to release lock 'env->me_windowsbug_lock' in function " - "'mdbx_txn_lock'"); + /* Zap: Failing to release lock 'env->me_windowsbug_lock' + * in function 'mdbx_txn_lock' */ + MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(26115); return MDBX_SUCCESS; } @@ -218,9 +218,9 @@ int mdbx_txn_lock(MDBX_env *env, bool dontwait) { } } if (rc == MDBX_SUCCESS) { - MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER( - 26115, "Failing to release lock 'env->me_windowsbug_lock' in function " - "'mdbx_txn_lock'"); + /* Zap: Failing to release lock 'env->me_windowsbug_lock' + * in function 'mdbx_txn_lock' */ + MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(26115); return rc; } diff --git a/src/osal.c b/src/osal.c index 748767ba..db70dc0b 100644 --- a/src/osal.c +++ b/src/osal.c @@ -48,7 +48,8 @@ static int ntstatus2errcode(NTSTATUS status) { OVERLAPPED ov; memset(&ov, 0, sizeof(ov)); ov.Internal = status; - MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(6387, "'_Param_(1)' could be '0'"); + /* Zap: '_Param_(1)' could be '0' */ + MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(6387); return GetOverlappedResult(NULL, &ov, &dummy, FALSE) ? MDBX_SUCCESS : (int)GetLastError(); } @@ -83,8 +84,8 @@ extern NTSTATUS NTAPI NtMapViewOfSection( extern NTSTATUS NTAPI NtUnmapViewOfSection(IN HANDLE ProcessHandle, IN OPTIONAL PVOID BaseAddress); -MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(28251, - "Inconsistent annotation for 'NtClose'...") +/* Zap: Inconsistent annotation for 'NtClose'... */ +MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(28251) extern NTSTATUS NTAPI NtClose(HANDLE Handle); extern NTSTATUS NTAPI NtAllocateVirtualMemory( @@ -804,8 +805,8 @@ MDBX_INTERNAL_FUNC void osal_ioring_walk( if (bytes & ior_WriteFile_flag) { data = Ptr64ToPtr(item->sgv[0].Buffer); bytes = ior->pagesize; - MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER( - 6385, "Reading invalid data from 'item->sgv'"); + /* Zap: Reading invalid data from 'item->sgv' */ + MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(6385); while (item->sgv[i].Buffer) { if (data + ior->pagesize != item->sgv[i].Buffer) { callback(ctx, offset, data, bytes); @@ -852,8 +853,8 @@ osal_ioring_write(osal_ioring_t *ior, mdbx_filehandle_t fd) { if (bytes & ior_WriteFile_flag) { assert(ior->overlapped_fd && fd == ior->overlapped_fd); bytes = ior->pagesize; - MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER( - 6385, "Reading invalid data from 'item->sgv'"); + /* Zap: Reading invalid data from 'item->sgv' */ + MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(6385); while (item->sgv[i].Buffer) { bytes += ior->pagesize; ++i; @@ -992,8 +993,8 @@ osal_ioring_write(osal_ioring_t *ior, mdbx_filehandle_t fd) { size_t i = 1, bytes = item->single.iov_len - ior_WriteFile_flag; if (bytes & ior_WriteFile_flag) { bytes = ior->pagesize; - MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER( - 6385, "Reading invalid data from 'item->sgv'"); + /* Zap: Reading invalid data from 'item->sgv' */ + MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(6385); while (item->sgv[i].Buffer) { bytes += ior->pagesize; ++i; @@ -1088,8 +1089,8 @@ MDBX_INTERNAL_FUNC void osal_ioring_reset(osal_ioring_t *ior) { ior_put_event(ior, item->ov.hEvent); size_t i = 1; if ((item->single.iov_len & ior_WriteFile_flag) == 0) { - MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER( - 6385, "Reading invalid data from 'item->sgv'"); + /* Zap: Reading invalid data from 'item->sgv' */ + MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(6385); while (item->sgv[i].Buffer) ++i; } @@ -1108,8 +1109,8 @@ static void ior_cleanup(osal_ioring_t *ior, const size_t since) { osal_ioring_reset(ior); #if defined(_WIN32) || defined(_WIN64) for (size_t i = since; i < ior->event_stack; ++i) { - MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER( - 6001, "Using uninitialized memory '**ior.event_pool'"); + /* Zap: Using uninitialized memory '**ior.event_pool' */ + MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(6001); CloseHandle(ior->event_pool[i]); } ior->event_stack = 0; @@ -2749,7 +2750,8 @@ retry_mapview:; #endif /* POSIX / Windows */ - MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(6287, "Redundant code"); + /* Zap: Redundant code */ + MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(6287); assert(rc != MDBX_SUCCESS || (map->base != nullptr && map->base != MAP_FAILED && map->current == size && map->limit == limit &&