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 <mahrens@delphix.com>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Signed-off-by: Brooks Davis <brooks.davis@sri.com>
Closes #14131
This commit is contained in:
Brooks Davis
2022-10-27 23:28:03 +01:00
committed by Brian Behlendorf
parent 877790001e
commit b9041e1f27
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -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)) {