mirror of
https://github.com/neovim/neovim.git
synced 2025-10-01 07:28:34 +00:00
memfile: Fix V547: always true condition
`blocksize` was checked against UINT_MAX after it was checked against MAX_SWAP_PAGE_SIZE which makes it always pass the check. Better use STATIC_ASSERT instead.
This commit is contained in:
@@ -54,6 +54,7 @@
|
|||||||
#include "nvim/memory.h"
|
#include "nvim/memory.h"
|
||||||
#include "nvim/os_unix.h"
|
#include "nvim/os_unix.h"
|
||||||
#include "nvim/path.h"
|
#include "nvim/path.h"
|
||||||
|
#include "nvim/assert.h"
|
||||||
#include "nvim/os/os.h"
|
#include "nvim/os/os.h"
|
||||||
#include "nvim/os/input.h"
|
#include "nvim/os/input.h"
|
||||||
|
|
||||||
@@ -108,7 +109,8 @@ memfile_T *mf_open(char_u *fname, int flags)
|
|||||||
if (mfp->mf_fd >= 0 && os_fileinfo_fd(mfp->mf_fd, &file_info)) {
|
if (mfp->mf_fd >= 0 && os_fileinfo_fd(mfp->mf_fd, &file_info)) {
|
||||||
uint64_t blocksize = os_fileinfo_blocksize(&file_info);
|
uint64_t blocksize = os_fileinfo_blocksize(&file_info);
|
||||||
if (blocksize >= MIN_SWAP_PAGE_SIZE && blocksize <= MAX_SWAP_PAGE_SIZE) {
|
if (blocksize >= MIN_SWAP_PAGE_SIZE && blocksize <= MAX_SWAP_PAGE_SIZE) {
|
||||||
assert(blocksize <= UINT_MAX);
|
STATIC_ASSERT(MAX_SWAP_PAGE_SIZE <= UINT_MAX,
|
||||||
|
"MAX_SWAP_PAGE_SIZE must fit into an unsigned");
|
||||||
mfp->mf_page_size = (unsigned)blocksize;
|
mfp->mf_page_size = (unsigned)blocksize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user