Re: Remove useless casts to (void *) - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Remove useless casts to (void *)
Date
Msg-id 1654508.1733162761@sss.pgh.pa.us
Whole thread Raw
In response to Re: Remove useless casts to (void *)  (Peter Eisentraut <peter@eisentraut.org>)
Responses Re: Remove useless casts to (void *)
List pgsql-hackers
Peter Eisentraut <peter@eisentraut.org> writes:
> Committed, thanks.

Now that we have a more-or-less full set of buildfarm results
on this, I checked for new warnings, and found two:

pg_shmem.c: In function 'PGSharedMemoryIsInUse':
pg_shmem.c:323:33: warning: passing argument 1 of 'shmdt' from incompatible pointer type [-Wincompatible-pointer-types]
  323 |         if (memAddress && shmdt(memAddress) < 0)
      |                                 ^~~~~~~~~~
      |                                 |
      |                                 PGShmemHeader *
In file included from pg_shmem.c:27:
/usr/include/sys/shm.h:131:11: note: expected 'char *' but argument is of type 'PGShmemHeader *'
  131 | int shmdt(char *);
      |           ^~~~~~
pg_shmem.c: In function 'PGSharedMemoryCreate':
pg_shmem.c:838:37: warning: passing argument 1 of 'shmdt' from incompatible pointer type [-Wincompatible-pointer-types]
  838 |                 if (oldhdr && shmdt(oldhdr) < 0)
      |                                     ^~~~~~
      |                                     |
      |                                     PGShmemHeader *
/usr/include/sys/shm.h:131:11: note: expected 'char *' but argument is of type 'PGShmemHeader *'
  131 | int shmdt(char *);
      |           ^~~~~~

This is from hake[1], which is running OpenIndiana/illumos.
That platform shows a couple of other strange warnings, so maybe
re-eliminating these two is not worth worrying about, but
nonetheless the casts to void * were doing something here.

            regards, tom lane

[1] https://buildfarm.postgresql.org/cgi-bin/show_stage_log.pl?nm=hake&dt=2024-12-02%2017%3A19%3A40&stg=make



pgsql-hackers by date:

Previous
From: Alexander Lakhin
Date:
Subject: Re: RISC-V animals sporadically produce weird memory-related failures
Next
From: Peter Geoghegan
Date:
Subject: Re: Incorrect result of bitmap heap scan.