Remove useless casts in format arguments
authorPeter Eisentraut <peter@eisentraut.org>
Tue, 9 Dec 2025 05:58:39 +0000 (06:58 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Tue, 9 Dec 2025 06:33:08 +0000 (07:33 +0100)
There were a number of useless casts in format arguments, either
where the input to the cast was already in the right type, or
seemingly uselessly casting between types instead of just using the
right format placeholder to begin with.

Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/07fa29f9-42d7-4aac-8834-197918cbbab6%40eisentraut.org

19 files changed:
contrib/amcheck/verify_heapam.c
src/backend/access/common/printtup.c
src/backend/access/rmgrdesc/gindesc.c
src/backend/access/transam/xact.c
src/backend/access/transam/xlogreader.c
src/backend/commands/copyfromparse.c
src/backend/commands/define.c
src/backend/libpq/auth.c
src/backend/libpq/pqcomm.c
src/backend/libpq/pqmq.c
src/backend/parser/parse_type.c
src/backend/replication/walreceiver.c
src/backend/storage/page/bufpage.c
src/backend/utils/adt/format_type.c
src/backend/utils/adt/tsvector.c
src/backend/utils/adt/xid.c
src/bin/pg_ctl/pg_ctl.c
src/bin/pgbench/pgbench.c
src/bin/psql/common.c

index a090e18c697b2fd7d233f11b07b7e44bedaa8c6a..130b35334639f2cdb3c11ca135927b32323c243d 100644 (file)
@@ -526,17 +526,17 @@ verify_heapam(PG_FUNCTION_ARGS)
                if (rdoffnum < FirstOffsetNumber)
                {
                    report_corruption(&ctx,
-                                     psprintf("line pointer redirection to item at offset %u precedes minimum offset %u",
-                                              (unsigned) rdoffnum,
-                                              (unsigned) FirstOffsetNumber));
+                                     psprintf("line pointer redirection to item at offset %d precedes minimum offset %d",
+                                              rdoffnum,
+                                              FirstOffsetNumber));
                    continue;
                }
                if (rdoffnum > maxoff)
                {
                    report_corruption(&ctx,
-                                     psprintf("line pointer redirection to item at offset %u exceeds maximum offset %u",
-                                              (unsigned) rdoffnum,
-                                              (unsigned) maxoff));
+                                     psprintf("line pointer redirection to item at offset %d exceeds maximum offset %d",
+                                              rdoffnum,
+                                              maxoff));
                    continue;
                }
 
@@ -550,22 +550,22 @@ verify_heapam(PG_FUNCTION_ARGS)
                if (!ItemIdIsUsed(rditem))
                {
                    report_corruption(&ctx,
-                                     psprintf("redirected line pointer points to an unused item at offset %u",
-                                              (unsigned) rdoffnum));
+                                     psprintf("redirected line pointer points to an unused item at offset %d",
+                                              rdoffnum));
                    continue;
                }
                else if (ItemIdIsDead(rditem))
                {
                    report_corruption(&ctx,
-                                     psprintf("redirected line pointer points to a dead item at offset %u",
-                                              (unsigned) rdoffnum));
+                                     psprintf("redirected line pointer points to a dead item at offset %d",
+                                              rdoffnum));
                    continue;
                }
                else if (ItemIdIsRedirected(rditem))
                {
                    report_corruption(&ctx,
-                                     psprintf("redirected line pointer points to another redirected line pointer at offset %u",
-                                              (unsigned) rdoffnum));
+                                     psprintf("redirected line pointer points to another redirected line pointer at offset %d",
+                                              rdoffnum));
                    continue;
                }
 
@@ -601,10 +601,10 @@ verify_heapam(PG_FUNCTION_ARGS)
            if (ctx.lp_off + ctx.lp_len > BLCKSZ)
            {
                report_corruption(&ctx,
-                                 psprintf("line pointer to page offset %u with length %u ends beyond maximum page offset %u",
+                                 psprintf("line pointer to page offset %u with length %u ends beyond maximum page offset %d",
                                           ctx.lp_off,
                                           ctx.lp_len,
-                                          (unsigned) BLCKSZ));
+                                          BLCKSZ));
                continue;
            }
 
@@ -678,16 +678,16 @@ verify_heapam(PG_FUNCTION_ARGS)
                if (!HeapTupleHeaderIsHeapOnly(next_htup))
                {
                    report_corruption(&ctx,
-                                     psprintf("redirected line pointer points to a non-heap-only tuple at offset %u",
-                                              (unsigned) nextoffnum));
+                                     psprintf("redirected line pointer points to a non-heap-only tuple at offset %d",
+                                              nextoffnum));
                }
 
                /* HOT chains should not intersect. */
                if (predecessor[nextoffnum] != InvalidOffsetNumber)
                {
                    report_corruption(&ctx,
-                                     psprintf("redirect line pointer points to offset %u, but offset %u also points there",
-                                              (unsigned) nextoffnum, (unsigned) predecessor[nextoffnum]));
+                                     psprintf("redirect line pointer points to offset %d, but offset %d also points there",
+                                              nextoffnum, predecessor[nextoffnum]));
                    continue;
                }
 
@@ -719,8 +719,8 @@ verify_heapam(PG_FUNCTION_ARGS)
            if (predecessor[nextoffnum] != InvalidOffsetNumber)
            {
                report_corruption(&ctx,
-                                 psprintf("tuple points to new version at offset %u, but offset %u also points there",
-                                          (unsigned) nextoffnum, (unsigned) predecessor[nextoffnum]));
+                                 psprintf("tuple points to new version at offset %d, but offset %d also points there",
+                                          nextoffnum, predecessor[nextoffnum]));
                continue;
            }
 
@@ -743,15 +743,15 @@ verify_heapam(PG_FUNCTION_ARGS)
                HeapTupleHeaderIsHeapOnly(next_htup))
            {
                report_corruption(&ctx,
-                                 psprintf("non-heap-only update produced a heap-only tuple at offset %u",
-                                          (unsigned) nextoffnum));
+                                 psprintf("non-heap-only update produced a heap-only tuple at offset %d",
+                                          nextoffnum));
            }
            if ((curr_htup->t_infomask2 & HEAP_HOT_UPDATED) &&
                !HeapTupleHeaderIsHeapOnly(next_htup))
            {
                report_corruption(&ctx,
-                                 psprintf("heap-only update produced a non-heap only tuple at offset %u",
-                                          (unsigned) nextoffnum));
+                                 psprintf("heap-only update produced a non-heap only tuple at offset %d",
+                                          nextoffnum));
            }
 
            /*
@@ -772,10 +772,10 @@ verify_heapam(PG_FUNCTION_ARGS)
                TransactionIdIsInProgress(curr_xmin))
            {
                report_corruption(&ctx,
-                                 psprintf("tuple with in-progress xmin %u was updated to produce a tuple at offset %u with committed xmin %u",
-                                          (unsigned) curr_xmin,
-                                          (unsigned) ctx.offnum,
-                                          (unsigned) next_xmin));
+                                 psprintf("tuple with in-progress xmin %u was updated to produce a tuple at offset %d with committed xmin %u",
+                                          curr_xmin,
+                                          ctx.offnum,
+                                          next_xmin));
            }
 
            /*
@@ -788,16 +788,16 @@ verify_heapam(PG_FUNCTION_ARGS)
            {
                if (xmin_commit_status[nextoffnum] == XID_IN_PROGRESS)
                    report_corruption(&ctx,
-                                     psprintf("tuple with aborted xmin %u was updated to produce a tuple at offset %u with in-progress xmin %u",
-                                              (unsigned) curr_xmin,
-                                              (unsigned) ctx.offnum,
-                                              (unsigned) next_xmin));
+                                     psprintf("tuple with aborted xmin %u was updated to produce a tuple at offset %d with in-progress xmin %u",
+                                              curr_xmin,
+                                              ctx.offnum,
+                                              next_xmin));
                else if (xmin_commit_status[nextoffnum] == XID_COMMITTED)
                    report_corruption(&ctx,
-                                     psprintf("tuple with aborted xmin %u was updated to produce a tuple at offset %u with committed xmin %u",
-                                              (unsigned) curr_xmin,
-                                              (unsigned) ctx.offnum,
-                                              (unsigned) next_xmin));
+                                     psprintf("tuple with aborted xmin %u was updated to produce a tuple at offset %d with committed xmin %u",
+                                              curr_xmin,
+                                              ctx.offnum,
+                                              next_xmin));
            }
        }
 
index 9f05e1d15bd12f2e03e45ac83b68813266c88f24..025fe75916f3086c4412c2fdd42d84b53702b868 100644 (file)
@@ -431,7 +431,7 @@ printatt(unsigned attributeId,
           value != NULL ? " = \"" : "",
           value != NULL ? value : "",
           value != NULL ? "\"" : "",
-          (unsigned int) (attributeP->atttypid),
+          attributeP->atttypid,
           attributeP->attlen,
           attributeP->atttypmod,
           attributeP->attbyval ? 't' : 'f');
index 075c4a0ae93a0439335e45191fd81623b316dfbf..62e21f8c935786a861415e038a525fafcb06c146 100644 (file)
@@ -23,7 +23,7 @@ desc_recompress_leaf(StringInfo buf, ginxlogRecompressDataLeaf *insertData)
    int         i;
    char       *walbuf = ((char *) insertData) + sizeof(ginxlogRecompressDataLeaf);
 
-   appendStringInfo(buf, " %d segments:", (int) insertData->nactions);
+   appendStringInfo(buf, " %d segments:", insertData->nactions);
 
    for (i = 0; i < insertData->nactions; i++)
    {
index 092e197eba33eba6853076322dcd832f923585ff..e48d4b7af6cd5ac28126d203d9c0aaf971b49e85 100644 (file)
@@ -5709,9 +5709,9 @@ ShowTransactionStateRec(const char *str, TransactionState s)
                             s->name ? s->name : "unnamed",
                             BlockStateAsString(s->blockState),
                             TransStateAsString(s->state),
-                            (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
-                            (unsigned int) s->subTransactionId,
-                            (unsigned int) currentCommandId,
+                            XidFromFullTransactionId(s->fullTransactionId),
+                            s->subTransactionId,
+                            currentCommandId,
                             currentCommandIdUsed ? " (used)" : "",
                             buf.data)));
    pfree(buf.data);
index 9cc7488e8929f34cc2d8c749db7f3216a1011ef6..5e5001b2101acc4ebaf92a64b44d9b694623e478 100644 (file)
@@ -1797,8 +1797,8 @@ DecodeXLogRecord(XLogReaderState *state,
            if (!blk->has_data && blk->data_len != 0)
            {
                report_invalid_record(state,
-                                     "BKPBLOCK_HAS_DATA not set, but data length is %u at %X/%08X",
-                                     (unsigned int) blk->data_len,
+                                     "BKPBLOCK_HAS_DATA not set, but data length is %d at %X/%08X",
+                                     blk->data_len,
                                      LSN_FORMAT_ARGS(state->ReadRecPtr));
                goto err;
            }
@@ -1833,10 +1833,10 @@ DecodeXLogRecord(XLogReaderState *state,
                     blk->bimg_len == BLCKSZ))
                {
                    report_invalid_record(state,
-                                         "BKPIMAGE_HAS_HOLE set, but hole offset %u length %u block image length %u at %X/%08X",
-                                         (unsigned int) blk->hole_offset,
-                                         (unsigned int) blk->hole_length,
-                                         (unsigned int) blk->bimg_len,
+                                         "BKPIMAGE_HAS_HOLE set, but hole offset %d length %d block image length %d at %X/%08X",
+                                         blk->hole_offset,
+                                         blk->hole_length,
+                                         blk->bimg_len,
                                          LSN_FORMAT_ARGS(state->ReadRecPtr));
                    goto err;
                }
@@ -1849,9 +1849,9 @@ DecodeXLogRecord(XLogReaderState *state,
                    (blk->hole_offset != 0 || blk->hole_length != 0))
                {
                    report_invalid_record(state,
-                                         "BKPIMAGE_HAS_HOLE not set, but hole offset %u length %u at %X/%08X",
-                                         (unsigned int) blk->hole_offset,
-                                         (unsigned int) blk->hole_length,
+                                         "BKPIMAGE_HAS_HOLE not set, but hole offset %d length %d at %X/%08X",
+                                         blk->hole_offset,
+                                         blk->hole_length,
                                          LSN_FORMAT_ARGS(state->ReadRecPtr));
                    goto err;
                }
@@ -1863,8 +1863,8 @@ DecodeXLogRecord(XLogReaderState *state,
                    blk->bimg_len == BLCKSZ)
                {
                    report_invalid_record(state,
-                                         "BKPIMAGE_COMPRESSED set, but block image length %u at %X/%08X",
-                                         (unsigned int) blk->bimg_len,
+                                         "BKPIMAGE_COMPRESSED set, but block image length %d at %X/%08X",
+                                         blk->bimg_len,
                                          LSN_FORMAT_ARGS(state->ReadRecPtr));
                    goto err;
                }
@@ -1878,8 +1878,8 @@ DecodeXLogRecord(XLogReaderState *state,
                    blk->bimg_len != BLCKSZ)
                {
                    report_invalid_record(state,
-                                         "neither BKPIMAGE_HAS_HOLE nor BKPIMAGE_COMPRESSED set, but block image length is %u at %X/%08X",
-                                         (unsigned int) blk->data_len,
+                                         "neither BKPIMAGE_HAS_HOLE nor BKPIMAGE_COMPRESSED set, but block image length is %d at %X/%08X",
+                                         blk->data_len,
                                          LSN_FORMAT_ARGS(state->ReadRecPtr));
                    goto err;
                }
index a09e7fbace3393dcee929fd27424fab92aae5382..62afcd8fad1144f9328abcde86ff811374b7cb3b 100644 (file)
@@ -1136,7 +1136,7 @@ CopyFromBinaryOneRow(CopyFromState cstate, ExprContext *econtext, Datum *values,
        ereport(ERROR,
                (errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
                 errmsg("row field count is %d, expected %d",
-                       (int) fld_count, attr_count)));
+                       fld_count, attr_count)));
 
    foreach(cur, cstate->attnumlist)
    {
index 5e1b867e6f7338cfed65177483235b9a1768db13..3e238c414f7efced2a44f0dc3c913d056af2934d 100644 (file)
@@ -42,7 +42,7 @@ defGetString(DefElem *def)
    switch (nodeTag(def->arg))
    {
        case T_Integer:
-           return psprintf("%ld", (long) intVal(def->arg));
+           return psprintf("%d", intVal(def->arg));
        case T_Float:
            return castNode(Float, def->arg)->fval;
        case T_Boolean:
index a9181cde87b438bfac00b7c7401bb85faf9d6920..8045dbffe049f0de58ae2c152250fc23ea786e4a 100644 (file)
@@ -2240,8 +2240,8 @@ InitializeLDAPConnection(Port *port, LDAP **ldap)
    if (!*ldap)
    {
        ereport(LOG,
-               (errmsg("could not initialize LDAP: error code %d",
-                       (int) LdapGetLastError())));
+               (errmsg("could not initialize LDAP: error code %lu",
+                       LdapGetLastError())));
 
        return STATUS_ERROR;
    }
index 77b62edafb7e871dc063bf5a1839af0f76862248..40b180644eb8a52e70e81f6d20d848c1a835daad 100644 (file)
@@ -618,10 +618,10 @@ ListenServerPort(int family, const char *hostName, unsigned short portNumber,
                     saved_errno == EADDRINUSE ?
                     (addr->ai_family == AF_UNIX ?
                      errhint("Is another postmaster already running on port %d?",
-                             (int) portNumber) :
+                             portNumber) :
                      errhint("Is another postmaster already running on port %d?"
                              " If not, wait a few seconds and retry.",
-                             (int) portNumber)) : 0));
+                             portNumber)) : 0));
            closesocket(fd);
            continue;
        }
@@ -662,7 +662,7 @@ ListenServerPort(int family, const char *hostName, unsigned short portNumber,
            ereport(LOG,
            /* translator: first %s is IPv4 or IPv6 */
                    (errmsg("listening on %s address \"%s\", port %d",
-                           familyDesc, addrDesc, (int) portNumber)));
+                           familyDesc, addrDesc, portNumber)));
 
        ListenSockets[*NumListenSockets] = fd;
        (*NumListenSockets)++;
index 5f39949a3677390a3b80199a1e2659fb4a4d2c36..2b75de0ddef9482f21a3b03dffa06a3e2c8d36f3 100644 (file)
@@ -329,7 +329,7 @@ pq_parse_errornotice(StringInfo msg, ErrorData *edata)
                edata->funcname = pstrdup(value);
                break;
            default:
-               elog(ERROR, "unrecognized error field code: %d", (int) code);
+               elog(ERROR, "unrecognized error field code: %d", code);
                break;
        }
    }
index 7713bdc6af0a977407167c6f10fa6ac424112c99..e07d65fc25b1ace322c605ffab45f139035c31a6 100644 (file)
@@ -382,7 +382,7 @@ typenameTypeMod(ParseState *pstate, const TypeName *typeName, Type typ)
 
            if (IsA(&ac->val, Integer))
            {
-               cstr = psprintf("%ld", (long) intVal(&ac->val));
+               cstr = psprintf("%d", intVal(&ac->val));
            }
            else if (IsA(&ac->val, Float))
            {
index 4217fc54e2e9d12a9784d7affcaadedbba6bc523..3a94c9683a760a7884d9896902e0ca3c3284a971 100644 (file)
@@ -949,8 +949,8 @@ XLogWalRcvWrite(char *buf, Size nbytes, XLogRecPtr recptr, TimeLineID tli)
            ereport(PANIC,
                    (errcode_for_file_access(),
                     errmsg("could not write to WAL segment %s "
-                           "at offset %d, length %lu: %m",
-                           xlogfname, startoff, (unsigned long) segbytes)));
+                           "at offset %d, length %d: %m",
+                           xlogfname, startoff, segbytes)));
        }
 
        /* Update state for write */
index 91c8e758b19b522a80cebc9665c7feece21f9db5..05376431ef29041ef8e36d21014c04d65ebde3e6 100644 (file)
@@ -1438,8 +1438,8 @@ PageIndexTupleOverwrite(Page page, OffsetNumber offnum,
        offset != MAXALIGN(offset))
        ereport(ERROR,
                (errcode(ERRCODE_DATA_CORRUPTED),
-                errmsg("corrupted line pointer: offset = %u, size = %u",
-                       offset, (unsigned int) oldsize)));
+                errmsg("corrupted line pointer: offset = %u, size = %d",
+                       offset, oldsize)));
 
    /*
     * Determine actual change in space requirement, check for page overflow.
index 9948c26e76cd57d4041712ae62ae452150a944b6..0afd1cb3563fe40afd560254e540d1338c9b595b 100644 (file)
@@ -378,7 +378,7 @@ printTypmod(const char *typname, int32 typmod, Oid typmodout)
    if (typmodout == InvalidOid)
    {
        /* Default behavior: just print the integer typmod with parens */
-       res = psprintf("%s(%d)", typname, (int) typmod);
+       res = psprintf("%s(%d)", typname, typmod);
    }
    else
    {
index 1fa2e3729bfab6391f61fe8a1279dd32f5a69656..f568f1fce99f24264877869d5d33ed201de5d943 100644 (file)
@@ -210,9 +210,9 @@ tsvectorin(PG_FUNCTION_ARGS)
        if (toklen >= MAXSTRLEN)
            ereturn(escontext, (Datum) 0,
                    (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
-                    errmsg("word is too long (%ld bytes, max %ld bytes)",
-                           (long) toklen,
-                           (long) (MAXSTRLEN - 1))));
+                    errmsg("word is too long (%d bytes, max %d bytes)",
+                           toklen,
+                           MAXSTRLEN - 1)));
 
        if (cur - tmpbuf > MAXSTRPOS)
            ereturn(escontext, (Datum) 0,
index 3d0c48769cce832962b1bed3bb559db4563dc316..8a6e0390709b85c5717bedfec633132a198f1549 100644 (file)
@@ -45,7 +45,7 @@ xidout(PG_FUNCTION_ARGS)
    TransactionId transactionId = PG_GETARG_TRANSACTIONID(0);
    char       *result = (char *) palloc(16);
 
-   snprintf(result, 16, "%lu", (unsigned long) transactionId);
+   snprintf(result, 16, "%u", transactionId);
    PG_RETURN_CSTRING(result);
 }
 
@@ -362,7 +362,7 @@ cidout(PG_FUNCTION_ARGS)
    CommandId   c = PG_GETARG_COMMANDID(0);
    char       *result = (char *) palloc(16);
 
-   snprintf(result, 16, "%lu", (unsigned long) c);
+   snprintf(result, 16, "%u", c);
    PG_RETURN_CSTRING(result);
 }
 
index 4f666d91036b6e9fa2b0980a1c8853b92773cf32..dfe7b4d2f9e0a832ca7e5ad8a9cff95efe117f6c 100644 (file)
@@ -564,7 +564,7 @@ start_postmaster(void)
    if (!CreateRestrictedProcess(cmd, &pi, false))
    {
        write_stderr(_("%s: could not start server: error code %lu\n"),
-                    progname, (unsigned long) GetLastError());
+                    progname, GetLastError());
        exit(1);
    }
    /* Don't close command process handle here; caller must do so */
@@ -1537,7 +1537,7 @@ pgwin32_doRegister(void)
        CloseServiceHandle(hSCM);
        write_stderr(_("%s: could not register service \"%s\": error code %lu\n"),
                     progname, register_servicename,
-                    (unsigned long) GetLastError());
+                    GetLastError());
        exit(1);
    }
    CloseServiceHandle(hService);
@@ -1567,7 +1567,7 @@ pgwin32_doUnregister(void)
        CloseServiceHandle(hSCM);
        write_stderr(_("%s: could not open service \"%s\": error code %lu\n"),
                     progname, register_servicename,
-                    (unsigned long) GetLastError());
+                    GetLastError());
        exit(1);
    }
    if (!DeleteService(hService))
@@ -1576,7 +1576,7 @@ pgwin32_doUnregister(void)
        CloseServiceHandle(hSCM);
        write_stderr(_("%s: could not unregister service \"%s\": error code %lu\n"),
                     progname, register_servicename,
-                    (unsigned long) GetLastError());
+                    GetLastError());
        exit(1);
    }
    CloseServiceHandle(hService);
@@ -1725,7 +1725,7 @@ pgwin32_doRunAsService(void)
    {
        write_stderr(_("%s: could not start service \"%s\": error code %lu\n"),
                     progname, register_servicename,
-                    (unsigned long) GetLastError());
+                    GetLastError());
        exit(1);
    }
 }
@@ -1797,7 +1797,7 @@ CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo, bool as_ser
         * it doesn't cast DWORD before printing.
         */
        write_stderr(_("%s: could not open process token: error code %lu\n"),
-                    progname, (unsigned long) GetLastError());
+                    progname, GetLastError());
        return 0;
    }
 
@@ -1811,7 +1811,7 @@ CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo, bool as_ser
                                  0, &dropSids[1].Sid))
    {
        write_stderr(_("%s: could not allocate SIDs: error code %lu\n"),
-                    progname, (unsigned long) GetLastError());
+                    progname, GetLastError());
        return 0;
    }
 
@@ -1837,7 +1837,7 @@ CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo, bool as_ser
    if (!b)
    {
        write_stderr(_("%s: could not create restricted token: error code %lu\n"),
-                    progname, (unsigned long) GetLastError());
+                    progname, GetLastError());
        return 0;
    }
 
@@ -1856,8 +1856,7 @@ CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo, bool as_ser
            HANDLE      job;
            char        jobname[128];
 
-           sprintf(jobname, "PostgreSQL_%lu",
-                   (unsigned long) processInfo->dwProcessId);
+           sprintf(jobname, "PostgreSQL_%lu", processInfo->dwProcessId);
 
            job = CreateJobObject(NULL, jobname);
            if (job)
@@ -1919,7 +1918,7 @@ GetPrivilegesToDelete(HANDLE hToken)
        !LookupPrivilegeValue(NULL, SE_CHANGE_NOTIFY_NAME, &luidChangeNotify))
    {
        write_stderr(_("%s: could not get LUIDs for privileges: error code %lu\n"),
-                    progname, (unsigned long) GetLastError());
+                    progname, GetLastError());
        return NULL;
    }
 
@@ -1927,7 +1926,7 @@ GetPrivilegesToDelete(HANDLE hToken)
        GetLastError() != ERROR_INSUFFICIENT_BUFFER)
    {
        write_stderr(_("%s: could not get token information: error code %lu\n"),
-                    progname, (unsigned long) GetLastError());
+                    progname, GetLastError());
        return NULL;
    }
 
@@ -1942,7 +1941,7 @@ GetPrivilegesToDelete(HANDLE hToken)
    if (!GetTokenInformation(hToken, TokenPrivileges, tokenPrivs, length, &length))
    {
        write_stderr(_("%s: could not get token information: error code %lu\n"),
-                    progname, (unsigned long) GetLastError());
+                    progname, GetLastError());
        free(tokenPrivs);
        return NULL;
    }
index 00593fab5e1d2c18ed0c193050ae965ebb31c761..45b340d3da5791ca70b116fb5efafcf59564f60a 100644 (file)
@@ -6274,8 +6274,8 @@ parseScriptWeight(const char *option, char **script)
        if (errno != 0 || badp == sep + 1 || *badp != '\0')
            pg_fatal("invalid weight specification: %s", sep);
        if (wtmp > INT_MAX || wtmp < 0)
-           pg_fatal("weight specification out of range (0 .. %d): %lld",
-                    INT_MAX, (long long) wtmp);
+           pg_fatal("weight specification out of range (0 .. %d): %ld",
+                    INT_MAX, wtmp);
        weight = wtmp;
    }
    else
index cd329ade12b5d7467dd1f23c68414593bca12628..1a28ba6c02b8f0fb78307643e40f63463efb4a03 100644 (file)
@@ -1021,7 +1021,7 @@ PrintQueryStatus(PGresult *result, FILE *printQueryFout)
    if (pset.logfile)
        fprintf(pset.logfile, "%s\n", cmdstatus);
 
-   snprintf(buf, sizeof(buf), "%u", (unsigned int) PQoidValue(result));
+   snprintf(buf, sizeof(buf), "%u", PQoidValue(result));
    SetVariable(pset.vars, "LASTOID", buf);
 }