os.c: Add explicit casts

A Unix file descriptor number is stored in the
"generic callback argument" `void **priv`. However, on LP64
systems like x86_64 linux, `int` and `void **` have different size.
This leads to a compiler diagnostic:
```
os.c: In function ‘os_write’:
os.c:192:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  192 |   int fd = (int) *priv;
      |            ^
```
Adding an additional cast via `intptr_t` resolves the compiler
diagnostics.
This commit is contained in:
Jeff Epler 2025-08-18 08:34:57 -05:00
parent 94f6cd0004
commit df8a1fcc25

View file

@ -88,7 +88,7 @@ int os_open(void **priv, const char *path, int mode)
(errno == EACCES || errno == EAGAIN))
ERROR(EAGAIN, "unable to obtain lock for medium");
*priv = (void *) fd;
*priv = (void *)(intptr_t) fd;
return 0;
@ -105,7 +105,7 @@ fail:
*/
int os_close(void **priv)
{
int fd = (int) *priv;
int fd = (int)(intptr_t) *priv;
*priv = (void *) -1;
@ -124,7 +124,7 @@ fail:
*/
int os_same(void **priv, const char *path)
{
int fd = (int) *priv;
int fd = (int)(intptr_t) *priv;
struct stat fdev, dev;
if (fstat(fd, &fdev) == -1 ||
@ -144,7 +144,7 @@ fail:
*/
unsigned long os_seek(void **priv, unsigned long offset)
{
int fd = (int) *priv;
int fd = (int)(intptr_t) *priv;
off_t result;
/* offset == -1 special; seek to last block of device */
@ -169,7 +169,7 @@ fail:
*/
unsigned long os_read(void **priv, void *buf, unsigned long len)
{
int fd = (int) *priv;
int fd = (int)(intptr_t) *priv;
ssize_t result;
result = read(fd, buf, len << HFS_BLOCKSZ_BITS);
@ -189,7 +189,7 @@ fail:
*/
unsigned long os_write(void **priv, const void *buf, unsigned long len)
{
int fd = (int) *priv;
int fd = (int)(intptr_t) *priv;
ssize_t result;
result = write(fd, buf, len << HFS_BLOCKSZ_BITS);