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:
ZyX
2017-05-20 04:19:57 +03:00
parent 40444e9186
commit 7d895ee053

View File

@@ -54,6 +54,7 @@
#include "nvim/memory.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
#include "nvim/assert.h"
#include "nvim/os/os.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)) {
uint64_t blocksize = os_fileinfo_blocksize(&file_info);
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;
}
}