mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-20 05:38:20 +08:00
mdbx: повторное "устранение" предупреждений MSVC Static Analyzer (aka Prefast).
Никаких значимых изменений, только обход "странностей" в MSVC. Как оказалось MSVC распространяет действие директивы `pragma(warning(supppress:#))` строго на следующую строку, даже если эта строка является продолжением комментария начатого в самой директиве и/или не содержит синтаксических конструкций языка. Поэтому большинство из добавленных ранее директив для подавления ложных предупреждений, перестало работать после переформатирования исходного кода.
This commit is contained in:
parent
29d12f1fc3
commit
1b6e32071c
15
src/base.h
15
src/base.h
@ -669,14 +669,19 @@ __extern_C key_t ftok(const char *, int);
|
|||||||
#endif
|
#endif
|
||||||
#endif /* MDBX_GOOFY_MSVC_STATIC_ANALYZER */
|
#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_ANALYSIS_ASSUME(expr) __analysis_assume(expr)
|
||||||
#define MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(warn_id, note) \
|
#ifdef _PREFAST_
|
||||||
_Pragma(MDBX_STRINGIFY(prefast(suppress : warn_id)))
|
#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
|
#else
|
||||||
#define MDBX_ANALYSIS_ASSUME(expr) assert(expr)
|
#define MDBX_ANALYSIS_ASSUME(expr) assert(expr)
|
||||||
#define MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(warn_id, note)
|
#define MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(warn_id)
|
||||||
#endif
|
#endif /* MDBX_GOOFY_MSVC_STATIC_ANALYZER */
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -8317,8 +8317,8 @@ static void cursors_eot(MDBX_txn *txn, const bool merge) {
|
|||||||
if (bk) {
|
if (bk) {
|
||||||
MDBX_xcursor *mx = mc->mc_xcursor;
|
MDBX_xcursor *mx = mc->mc_xcursor;
|
||||||
tASSERT(txn, txn->mt_parent != NULL);
|
tASSERT(txn, txn->mt_parent != NULL);
|
||||||
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(
|
/* Zap: Using uninitialized memory '*mc->mc_backup'. */
|
||||||
6001, "Using uninitialized memory '*mc->mc_backup'.");
|
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(6001);
|
||||||
ENSURE(txn->mt_env, bk->mc_signature == MDBX_MC_LIVE);
|
ENSURE(txn->mt_env, bk->mc_signature == MDBX_MC_LIVE);
|
||||||
tASSERT(txn, mx == bk->mc_xcursor);
|
tASSERT(txn, mx == bk->mc_xcursor);
|
||||||
if (stage == MDBX_MC_WAIT4EOT /* Cursor was closed by user */)
|
if (stage == MDBX_MC_WAIT4EOT /* Cursor was closed by user */)
|
||||||
|
@ -195,9 +195,9 @@ int mdbx_txn_lock(MDBX_env *env, bool dontwait) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (env->me_flags & MDBX_EXCLUSIVE) {
|
if (env->me_flags & MDBX_EXCLUSIVE) {
|
||||||
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(
|
/* Zap: Failing to release lock 'env->me_windowsbug_lock'
|
||||||
26115, "Failing to release lock 'env->me_windowsbug_lock' in function "
|
* in function 'mdbx_txn_lock' */
|
||||||
"'mdbx_txn_lock'");
|
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(26115);
|
||||||
return MDBX_SUCCESS;
|
return MDBX_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,9 +218,9 @@ int mdbx_txn_lock(MDBX_env *env, bool dontwait) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rc == MDBX_SUCCESS) {
|
if (rc == MDBX_SUCCESS) {
|
||||||
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(
|
/* Zap: Failing to release lock 'env->me_windowsbug_lock'
|
||||||
26115, "Failing to release lock 'env->me_windowsbug_lock' in function "
|
* in function 'mdbx_txn_lock' */
|
||||||
"'mdbx_txn_lock'");
|
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(26115);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
30
src/osal.c
30
src/osal.c
@ -48,7 +48,8 @@ static int ntstatus2errcode(NTSTATUS status) {
|
|||||||
OVERLAPPED ov;
|
OVERLAPPED ov;
|
||||||
memset(&ov, 0, sizeof(ov));
|
memset(&ov, 0, sizeof(ov));
|
||||||
ov.Internal = status;
|
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
|
return GetOverlappedResult(NULL, &ov, &dummy, FALSE) ? MDBX_SUCCESS
|
||||||
: (int)GetLastError();
|
: (int)GetLastError();
|
||||||
}
|
}
|
||||||
@ -83,8 +84,8 @@ extern NTSTATUS NTAPI NtMapViewOfSection(
|
|||||||
extern NTSTATUS NTAPI NtUnmapViewOfSection(IN HANDLE ProcessHandle,
|
extern NTSTATUS NTAPI NtUnmapViewOfSection(IN HANDLE ProcessHandle,
|
||||||
IN OPTIONAL PVOID BaseAddress);
|
IN OPTIONAL PVOID BaseAddress);
|
||||||
|
|
||||||
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(28251,
|
/* Zap: Inconsistent annotation for 'NtClose'... */
|
||||||
"Inconsistent annotation for 'NtClose'...")
|
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(28251)
|
||||||
extern NTSTATUS NTAPI NtClose(HANDLE Handle);
|
extern NTSTATUS NTAPI NtClose(HANDLE Handle);
|
||||||
|
|
||||||
extern NTSTATUS NTAPI NtAllocateVirtualMemory(
|
extern NTSTATUS NTAPI NtAllocateVirtualMemory(
|
||||||
@ -804,8 +805,8 @@ MDBX_INTERNAL_FUNC void osal_ioring_walk(
|
|||||||
if (bytes & ior_WriteFile_flag) {
|
if (bytes & ior_WriteFile_flag) {
|
||||||
data = Ptr64ToPtr(item->sgv[0].Buffer);
|
data = Ptr64ToPtr(item->sgv[0].Buffer);
|
||||||
bytes = ior->pagesize;
|
bytes = ior->pagesize;
|
||||||
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(
|
/* Zap: Reading invalid data from 'item->sgv' */
|
||||||
6385, "Reading invalid data from 'item->sgv'");
|
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(6385);
|
||||||
while (item->sgv[i].Buffer) {
|
while (item->sgv[i].Buffer) {
|
||||||
if (data + ior->pagesize != item->sgv[i].Buffer) {
|
if (data + ior->pagesize != item->sgv[i].Buffer) {
|
||||||
callback(ctx, offset, data, bytes);
|
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) {
|
if (bytes & ior_WriteFile_flag) {
|
||||||
assert(ior->overlapped_fd && fd == ior->overlapped_fd);
|
assert(ior->overlapped_fd && fd == ior->overlapped_fd);
|
||||||
bytes = ior->pagesize;
|
bytes = ior->pagesize;
|
||||||
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(
|
/* Zap: Reading invalid data from 'item->sgv' */
|
||||||
6385, "Reading invalid data from 'item->sgv'");
|
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(6385);
|
||||||
while (item->sgv[i].Buffer) {
|
while (item->sgv[i].Buffer) {
|
||||||
bytes += ior->pagesize;
|
bytes += ior->pagesize;
|
||||||
++i;
|
++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;
|
size_t i = 1, bytes = item->single.iov_len - ior_WriteFile_flag;
|
||||||
if (bytes & ior_WriteFile_flag) {
|
if (bytes & ior_WriteFile_flag) {
|
||||||
bytes = ior->pagesize;
|
bytes = ior->pagesize;
|
||||||
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(
|
/* Zap: Reading invalid data from 'item->sgv' */
|
||||||
6385, "Reading invalid data from 'item->sgv'");
|
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(6385);
|
||||||
while (item->sgv[i].Buffer) {
|
while (item->sgv[i].Buffer) {
|
||||||
bytes += ior->pagesize;
|
bytes += ior->pagesize;
|
||||||
++i;
|
++i;
|
||||||
@ -1088,8 +1089,8 @@ MDBX_INTERNAL_FUNC void osal_ioring_reset(osal_ioring_t *ior) {
|
|||||||
ior_put_event(ior, item->ov.hEvent);
|
ior_put_event(ior, item->ov.hEvent);
|
||||||
size_t i = 1;
|
size_t i = 1;
|
||||||
if ((item->single.iov_len & ior_WriteFile_flag) == 0) {
|
if ((item->single.iov_len & ior_WriteFile_flag) == 0) {
|
||||||
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(
|
/* Zap: Reading invalid data from 'item->sgv' */
|
||||||
6385, "Reading invalid data from 'item->sgv'");
|
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(6385);
|
||||||
while (item->sgv[i].Buffer)
|
while (item->sgv[i].Buffer)
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
@ -1108,8 +1109,8 @@ static void ior_cleanup(osal_ioring_t *ior, const size_t since) {
|
|||||||
osal_ioring_reset(ior);
|
osal_ioring_reset(ior);
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
for (size_t i = since; i < ior->event_stack; ++i) {
|
for (size_t i = since; i < ior->event_stack; ++i) {
|
||||||
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(
|
/* Zap: Using uninitialized memory '**ior.event_pool' */
|
||||||
6001, "Using uninitialized memory '**ior.event_pool'");
|
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(6001);
|
||||||
CloseHandle(ior->event_pool[i]);
|
CloseHandle(ior->event_pool[i]);
|
||||||
}
|
}
|
||||||
ior->event_stack = 0;
|
ior->event_stack = 0;
|
||||||
@ -2749,7 +2750,8 @@ retry_mapview:;
|
|||||||
|
|
||||||
#endif /* POSIX / Windows */
|
#endif /* POSIX / Windows */
|
||||||
|
|
||||||
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(6287, "Redundant code");
|
/* Zap: Redundant code */
|
||||||
|
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(6287);
|
||||||
assert(rc != MDBX_SUCCESS ||
|
assert(rc != MDBX_SUCCESS ||
|
||||||
(map->base != nullptr && map->base != MAP_FAILED &&
|
(map->base != nullptr && map->base != MAP_FAILED &&
|
||||||
map->current == size && map->limit == limit &&
|
map->current == size && map->limit == limit &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user