summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrooks Davis <[email protected]>2022-10-27 23:28:03 +0100
committerBrian Behlendorf <[email protected]>2022-11-03 09:52:23 -0700
commitb9041e1f27b7b29b27ac3b873c7ba2922bccca01 (patch)
tree9373e5bd74abc3b07b31f18250ff67a079d2ea58
parent877790001e74b6c3b2955e4b7a8c685385e77654 (diff)
Use intptr_t when storing an integer in a pointer
Cast the integer type to (u)intptr_t before casting to "void *". In CHERI C/C++ we warn on bare casts from integers to pointers to catch attempts to create pointers our of thin air. We allow the warning to be supressed with a suitable cast through (u)intptr_t. Reviewed-by: Matthew Ahrens <[email protected]> Reviewed-by: Richard Yao <[email protected]> Signed-off-by: Brooks Davis <[email protected]> Closes #14131
-rw-r--r--cmd/zstream/zstream_decompress.c2
-rw-r--r--module/zfs/zfs_vnops.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/cmd/zstream/zstream_decompress.c b/cmd/zstream/zstream_decompress.c
index e5527777b..6e0da0852 100644
--- a/cmd/zstream/zstream_decompress.c
+++ b/cmd/zstream/zstream_decompress.c
@@ -146,7 +146,7 @@ zstream_do_decompress(int argc, char *argv[])
p = hsearch(e, ENTER);
if (p == NULL)
errx(1, "hsearch");
- p->data = (void*)type;
+ p->data = (void*)(intptr_t)type;
}
if (isatty(STDIN_FILENO)) {
diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c
index c63076f90..593249e12 100644
--- a/module/zfs/zfs_vnops.c
+++ b/module/zfs/zfs_vnops.c
@@ -64,7 +64,7 @@ zfs_fsync(znode_t *zp, int syncflag, cred_t *cr)
int error = 0;
zfsvfs_t *zfsvfs = ZTOZSB(zp);
- (void) tsd_set(zfs_fsyncer_key, (void *)zfs_fsync_sync_cnt);
+ (void) tsd_set(zfs_fsyncer_key, (void *)(uintptr_t)zfs_fsync_sync_cnt);
if (zfsvfs->z_os->os_sync != ZFS_SYNC_DISABLED) {
if ((error = zfs_enter_verify_zp(zfsvfs, zp, FTAG)) != 0)