Remove useless casts to (void *)
authorPeter Eisentraut <peter@eisentraut.org>
Fri, 21 Nov 2025 15:49:40 +0000 (16:49 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Fri, 21 Nov 2025 15:49:40 +0000 (16:49 +0100)
Their presence causes (small) risks of hiding actual type mismatches
or silently discarding qualifiers.  Some have been missed in
7f798aca1d5 and some are new ones along the same lines.

Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/aR8Yv%2BuATLKbJCgI%40ip-10-97-1-34.eu-west-3.compute.internal

src/backend/catalog/pg_publication.c
src/backend/commands/copyfromparse.c
src/backend/commands/extension.c
src/backend/storage/lmgr/lock.c
src/backend/tsearch/wparser.c
src/backend/utils/cache/inval.c
src/backend/utils/misc/injection_point.c
src/backend/utils/mmgr/bump.c
src/backend/utils/sort/tuplesortvariants.c

index ac2f4ee35616ce221b1af323be1a48c07060a0ec..0994220c53d5b5671ba3d8b47d60299d3a51a11a 100644 (file)
@@ -1369,7 +1369,7 @@ pg_get_publication_sequences(PG_FUNCTION_ARGS)
        if (publication->allsequences)
            sequences = GetAllPublicationRelations(RELKIND_SEQUENCE, false);
 
-       funcctx->user_fctx = (void *) sequences;
+       funcctx->user_fctx = sequences;
 
        MemoryContextSwitchTo(oldcontext);
    }
index b1ae97b833dffbd245ae2727975cb68bf5a30412..a09e7fbace3393dcee929fd27424fab92aae5382 100644 (file)
@@ -335,7 +335,7 @@ CopyGetData(CopyFromState cstate, void *databuf, int minread, int maxread)
                if (avail > maxread)
                    avail = maxread;
                pq_copymsgbytes(cstate->fe_msgbuf, databuf, avail);
-               databuf = (void *) ((char *) databuf + avail);
+               databuf = (char *) databuf + avail;
                maxread -= avail;
                bytesread += avail;
            }
index 93ef1ad106fdbd8ae5824f41a7d8dfb20e8791ff..ebc204c446213a5e7ef55037094accbc51d288f1 100644 (file)
@@ -931,7 +931,7 @@ execute_sql_string(const char *sql, const char *filename)
    callback_arg.stmt_len = -1;
 
    scripterrcontext.callback = script_error_callback;
-   scripterrcontext.arg = (void *) &callback_arg;
+   scripterrcontext.arg = &callback_arg;
    scripterrcontext.previous = error_context_stack;
    error_context_stack = &scripterrcontext;
 
index 4cc7f645c31719a612cea66dd1cd4096fefe207a..9cb78ead105a523a1efbab9c09b222bd67ae0bd3 100644 (file)
@@ -1943,7 +1943,7 @@ WaitOnLock(LOCALLOCK *locallock, ResourceOwner owner)
 
    /* Setup error traceback support for ereport() */
    waiterrcontext.callback = waitonlock_error_callback;
-   waiterrcontext.arg = (void *) locallock;
+   waiterrcontext.arg = locallock;
    waiterrcontext.previous = error_context_stack;
    error_context_stack = &waiterrcontext;
 
index a8ddb6109910ef0dd531ea9234f3e9bf5389e6b6..55171aa8da173df72d0154e8377694828df5f452 100644 (file)
@@ -204,7 +204,7 @@ prs_setup_firstcall(FuncCallContext *funcctx, FunctionCallInfo fcinfo,
    st->len = st->cur;
    st->cur = 0;
 
-   funcctx->user_fctx = (void *) st;
+   funcctx->user_fctx = st;
    if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
        elog(ERROR, "return type must be a row type");
    funcctx->tuple_desc = tupdesc;
index 02505c88b8e4cff64f8576616093736c8f537d47..06f736cab4580c35059865f12adc96327d0fdae5 100644 (file)
@@ -1480,7 +1480,7 @@ CacheInvalidateHeapTupleCommon(Relation relation,
    else
        PrepareToInvalidateCacheTuple(relation, tuple, newtuple,
                                      RegisterCatcacheInvalidation,
-                                     (void *) info);
+                                     info);
 
    /*
     * Now, is this tuple one of the primary definers of a relcache entry? See
index 64e6274652cd66484bfd50aa2cc9a7a8d0974adf..d02618c7ffeb51b75b97136e1781b9b3731b0782 100644 (file)
@@ -186,7 +186,7 @@ injection_point_cache_load(InjectionPointEntry *entry, int slot_idx, uint64 gene
        elog(ERROR, "could not find library \"%s\" for injection point \"%s\"",
             path, entry->name);
 
-   injection_callback_local = (void *)
+   injection_callback_local =
        load_external_function(path, entry->function, false, NULL);
 
    if (injection_callback_local == NULL)
index a263861fe43badd062e2ae14a7cea6cb2c2ab05b..e60ec94e1394ca84af465c7d5d94aa7e9d6439b2 100644 (file)
@@ -407,7 +407,7 @@ BumpAllocChunkFromBlock(MemoryContext context, BumpBlock *block, Size size,
 #ifdef MEMORY_CONTEXT_CHECKING
    chunk = (MemoryChunk *) block->freeptr;
 #else
-   ptr = (void *) block->freeptr;
+   ptr = block->freeptr;
 #endif
 
    /* point the freeptr beyond this chunk */
index 41ac4afbf495ec278267070f13f001ee3d20b90d..9751a7fc4957704e5a09e1de42ac2420c7a13803 100644 (file)
@@ -1954,7 +1954,7 @@ readtup_index_gin(Tuplesortstate *state, SortTuple *stup,
    LogicalTapeReadExact(tape, tuple, tuplen);
    if (base->sortopt & TUPLESORT_RANDOMACCESS) /* need trailing length word? */
        LogicalTapeReadExact(tape, &tuplen, sizeof(tuplen));
-   stup->tuple = (void *) tuple;
+   stup->tuple = tuple;
 
    /* no abbreviations (FIXME maybe use attrnum for this?) */
    stup->datum1 = (Datum) 0;