mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-21 09:46:59 +02:00
util/nvmutil: even safer pointer comparison
we assert now that ulong is the size of a pointer, therefore we know that it can fit a pointer reliably. this code is written for c90 spec so lacks uintptr Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -246,6 +246,9 @@ typedef char static_assert_int_ge_32[(sizeof(int) >= 4) ? 1 : -1];
|
|||||||
typedef char static_assert_twos_complement[
|
typedef char static_assert_twos_complement[
|
||||||
((-1 & 3) == 3) ? 1 : -1
|
((-1 & 3) == 3) ? 1 : -1
|
||||||
];
|
];
|
||||||
|
typedef char assert_ulong_ptr[
|
||||||
|
(sizeof(ulong) >= sizeof(void *)) ? 1 : -1
|
||||||
|
];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We set _FILE_OFFSET_BITS 64, but we only handle
|
* We set _FILE_OFFSET_BITS 64, but we only handle
|
||||||
@@ -1801,15 +1804,15 @@ static ssize_t
|
|||||||
rw_gbe_file_exact(int fd, u8 *mem, size_t nrw,
|
rw_gbe_file_exact(int fd, u8 *mem, size_t nrw,
|
||||||
off_t off, int rw_type)
|
off_t off, int rw_type)
|
||||||
{
|
{
|
||||||
size_t mem_addr;
|
ulong mem_addr;
|
||||||
size_t buf_addr;
|
ulong buf_addr;
|
||||||
size_t buf_end;
|
ulong buf_end;
|
||||||
|
|
||||||
if (mem == NULL)
|
if (mem == NULL)
|
||||||
goto err_rw_gbe_file_exact;
|
goto err_rw_gbe_file_exact;
|
||||||
|
|
||||||
mem_addr = (size_t)(void *)mem;
|
mem_addr = (ulong)(void *)mem;
|
||||||
buf_addr = (size_t)(void *)buf;
|
buf_addr = (ulong)(void *)buf;
|
||||||
buf_end = buf_addr + GBE_FILE_SIZE;
|
buf_end = buf_addr + GBE_FILE_SIZE;
|
||||||
|
|
||||||
if (mem != (void *)pad &&
|
if (mem != (void *)pad &&
|
||||||
|
|||||||
Reference in New Issue
Block a user