8000 Clean up most -Wunused-but-set-variable warnings from gcc 4.6 · postgrespro/postgres_cluster@5caa347 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5caa347

Browse files
committed
Clean up most -Wunused-but-set-variable warnings from gcc 4.6
This warning is new in gcc 4.6 and part of -Wall. This patch cleans up most of the noise, but there are some still warnings that are trickier to remove.
1 parent 3c381a5 commit 5caa347

File tree

34 files changed

+64
-188
lines changed
  • contrib
    • isn
    • pageinspect
    • < 8000 div class="PRIVATE_VisuallyHidden prc-TreeView-TreeViewVisuallyHidden-4-mPv" aria-hidden="true" id=":R3ddddabH1:">
      pgcrypto
  • seg
  • src
  • 34 files changed

    +64
    -188
    lines changed

    contrib/isn/isn.c

    Lines changed: 4 additions & 6 deletions
    Original file line numberDiff line numberDiff line change
    @@ -341,8 +341,7 @@ ean2isn(ean13 ean, bool errorOK, ean13 *result, enum isn_type accept)
    341341
    enum isn_type type = INVALID;
    342342

    343343
    char buf[MAXEAN13LEN + 1];
    344-
    char *firstdig,
    345-
    *aux;
    344+
    char *aux;
    346345
    unsigned digval;
    347346
    unsigned search;
    348347
    ean13 ret = ean;
    @@ -354,7 +353,7 @@ ean2isn(ean13 ean, bool errorOK, ean13 *result, enum isn_type accept)
    354353

    355354
    /* convert the number */
    356355
    search = 0;
    357-
    firstdig = aux = buf + 13;
    356+
    aux = buf + 13;
    358357
    *aux = '\0'; /* terminate string; aux points to last digit */
    359358
    do
    360359
    {
    @@ -528,8 +527,7 @@ ean2string(ean13 ean, bool errorOK, char *result, bool shortType)
    528527
    const unsigned (*TABLE_index)[2];
    529528
    enum isn_type type = INVALID;
    530529

    531-
    char *firstdig,
    532-
    *aux;
    530+
    char *aux;
    533531
    unsigned digval;
    534532
    unsigned search;
    535533
    char valid = '\0'; /* was the number initially written with a
    @@ -546,7 +544,7 @@ ean2string(ean13 ean, bool errorOK, char *result, bool shortType)
    546544

    547545
    /* convert the number */
    548546
    search = 0;
    549-
    firstdig = aux = result + MAXEAN13LEN;
    547+
    aux = result + MAXEAN13LEN;
    550548
    *aux = '\0'; /* terminate string; aux points to last digit */
    551549
    *--aux = valid; /* append '!' for numbers with invalid but
    552550
    * corrected check digit */

    contrib/pageinspect/fsmfuncs.c

    Lines changed: 0 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -35,7 +35,6 @@ Datum
    3535
    fsm_page_contents(PG_FUNCTION_ARGS)
    3636
    {
    3737
    bytea *raw_page = PG_GETARG_BYTEA_P(0);
    38-
    int raw_page_size;
    3938
    StringInfoData sinfo;
    4039
    FSMPage fsmpage;
    4140
    int i;
    @@ -45,7 +44,6 @@ fsm_page_contents(PG_FUNCTION_ARGS)
    4544
    (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
    4645
    (errmsg("must be superuser to use raw page functions"))));
    4746

    48-
    raw_page_size = VARSIZE(raw_page) - VARHDRSZ;
    4947
    fsmpage = (FSMPage) PageGetContents(VARDATA(raw_page));
    5048

    5149
    initStringInfo(&sinfo);

    contrib/pgcrypto/pgp-s2k.c

    Lines changed: 3 additions & 9 deletions
    Original file line numberDiff line numberDiff line change
    @@ -39,14 +39,12 @@ static int
    3939
    calc_s2k_simple(PGP_S2K *s2k, PX_MD *md, const uint8 *key,
    4040
    unsigned key_len)
    4141
    {
    42-
    unsigned md_bs,
    43-
    md_rlen;
    42+
    unsigned md_rlen;
    4443
    uint8 buf[PGP_MAX_DIGEST];
    4544
    unsigned preload;
    4645
    unsigned remain;
    4746
    uint8 *dst = s2k->key;
    4847

    49-
    md_bs = px_md_block_size(md);
    5048
    md_rlen = px_md_result_size(md);
    5149

    5250
    remain = s2k->key_len;
    @@ -83,14 +81,12 @@ calc_s2k_simple(PGP_S2K *s2k, PX_MD *md, const uint8 *key,
    8381
    static int
    8482
    calc_s2k_salted(PGP_S2K *s2k, PX_MD *md, const uint8 *key, unsigned key_len)
    8583
    {
    86-
    unsigned md_bs,
    87-
    md_rlen;
    84+
    unsigned md_rlen;
    8885
    uint8 buf[PGP_MAX_DIGEST];
    8986
    unsigned preload = 0;
    9087
    uint8 *dst;
    9188
    unsigned remain;
    9289

    93-
    md_bs = px_md_block_size(md);
    9490
    md_rlen = px_md_result_size(md);
    9591

    9692
    dst = s2k->key;
    @@ -129,8 +125,7 @@ static int
    129125
    calc_s2k_iter_salted(PGP_S2K *s2k, PX_MD *md, const uint8 *key,
    130126
    unsigned key_len)
    131127
    {
    132-
    unsigned md_bs,
    133-
    md_rlen;
    128+
    unsigned md_rlen;
    134129
    uint8 buf[PGP_MAX_DIGEST];
    135130
    uint8 *dst;
    136131
    unsigned preload = 0;
    @@ -143,7 +138,6 @@ calc_s2k_iter_salted(PGP_S2K *s2k, PX_MD *md, const uint8 *key,
    143138
    cval = s2k->iter;
    144139
    count = ((unsigned) 16 + (cval & 15)) << ((cval >> 4) + 6);
    145140

    146-
    md_bs = px_md_block_size(md);
    147141
    md_rlen = px_md_result_size(md);
    148142

    149143
    remain = s2k->key_len;

    contrib/pgcrypto/px-hmac.c

    Lines changed: 0 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -52,13 +52,11 @@ static void
    5252
    hmac_init(PX_HMAC *h, const uint8 *key, unsigned klen)
    5353
    {
    5454
    unsigned bs,
    55-
    hlen,
    5655
    i;
    5756
    uint8 *keybuf;
    5857
    PX_MD *md = h->md;
    5958

    6059
    bs = px_md_block_size(md);
    61-
    hlen = px_md_result_size(md);
    6260
    keybuf = px_alloc(bs);
    6361
    memset(keybuf, 0, bs);
    6462

    contrib/pgcrypto/px.c

    Lines changed: 1 addition & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -162,14 +162,12 @@ combo_init(PX_Combo *cx, const uint8 *key, unsigned klen,
    162162
    const uint8 *iv, unsigned ivlen)
    163163
    {
    164164
    int err;
    165-
    unsigned bs,
    166-
    ks,
    165+
    unsigned ks,
    167166
    ivs;
    168167
    PX_Cipher *c = cx->cipher;
    169168
    uint8 *ivbuf = NULL;
    170169
    uint8 *keybuf;
    171170

    172-
    bs = px_cipher_block_size(c);
    173171
    ks = px_cipher_key_size(c);
    174172

    175173
    ivs = px_cipher_iv_size(c);
    @@ -205,15 +203,13 @@ combo_encrypt(PX_Combo *cx, const uint8 *data, unsigned dlen,
    205203
    int err = 0;
    206204
    uint8 *bbuf;
    207205
    unsigned bs,
    208-
    maxlen,
    209206
    bpos,
    210207
    i,
    211208
    pad;
    212209

    213210
    PX_Cipher *c = cx->cipher;
    214211

    215212
    bbuf = NULL;
    216-
    maxlen = *rlen;
    217213
    bs = px_cipher_block_size(c);
    218214

    219215
    /* encrypt */

    contrib/seg/seg.c

    Lines changed: 1 addition & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -867,7 +867,6 @@ restore(char *result, float val, int n)
    867867
    '0', '0', '0', '0', '\0'
    868868
    };
    869869
    char *p;
    870-
    char *mant;
    871870
    int exp;
    872871
    int i,
    873872
    dp,
    @@ -893,7 +892,7 @@ restore(char *result, float val, int n)
    893892
    *p = '\0';
    894893

    895894
    /* get the exponent */
    896-
    mant = (char *) strtok(strdup(result), "e");
    895+
    strtok(strdup(result), "e");
    897896
    exp = atoi(strtok(NULL, "e"));
    898897

    899898
    if (exp == 0)

    src/backend/access/gist/gistvacuum.c

    Lines changed: 0 additions & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -38,8 +38,6 @@ gistvacuumcleanup(PG_FUNCTION_ARGS)
    3838
    BlockNumber npages,
    3939
    blkno;
    4040
    BlockNumber totFreePages;
    41-
    BlockNumber lastBlock = GIST_ROOT_BLKNO,
    42-
    lastFilledBlock = GIST_ROOT_BLKNO;
    4341
    bool needLock;
    4442

    4543
    /* No-op in ANALYZE ONLY mode */
    @@ -90,11 +88,8 @@ gistvacuumcleanup(PG_FUNCTION_ARGS)
    9088
    totFreePages++;
    9189
    RecordFreeIndexPage(rel, blkno);
    9290
    }
    93-
    else
    94-
    lastFilledBlock = blkno;
    9591
    UnlockReleaseBuffer(buffer);
    9692
    }
    97-
    lastBlock = npages - 1;
    9893

    9994
    /* Finally, vacuum the FSM */
    10095
    IndexFreeSpaceMapVacuum(info->index);

    src/backend/access/nbtree/nbtpage.c

    Lines changed: 1 addition & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -466,7 +466,6 @@ _bt_log_reuse_page(Relation rel, BlockNumber blkno, TransactionId latestRemovedX
    466466

    467467
    /* XLOG stuff */
    468468
    {
    469-
    XLogRecPtr recptr;
    470469
    XLogRecData rdata[1];
    471470
    xl_btree_reuse_page xlrec_reuse;
    472471

    @@ -478,7 +477,7 @@ _bt_log_reuse_page(Relation rel, BlockNumber blkno, TransactionId latestRemovedX
    478477
    rdata[0].buffer = InvalidBuffer;
    479478
    rdata[0].next = NULL;
    480479

    481-
    recptr = XLogInsert(RM_BTREE_ID, XLOG_BTREE_REUSE_PAGE, rdata);
    480+
    XLogInsert(RM_BTREE_ID, XLOG_BTREE_REUSE_PAGE, rdata);
    482481

    483482
    /*
    484483
    * We don't do PageSetLSN or PageSetTLI here because we're about

    src/backend/catalog/pg_proc.c

    Lines changed: 0 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -671,7 +671,6 @@ fmgr_internal_validator(PG_FUNCTION_ARGS)
    671671
    {
    672672
    Oid funcoid = PG_GETARG_OID(0);
    673673
    HeapTuple tuple;
    674-
    Form_pg_proc proc;
    675674
    bool isnull;
    676675
    Datum tmp;
    677676
    char *prosrc;
    @@ -684,7 +683,6 @@ fmgr_internal_validator(PG_FUNCTION_ARGS)
    684683
    tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid));
    685684
    if (!HeapTupleIsValid(tuple))
    686685
    elog(ERROR, "cache lookup failed for function %u", funcoid);
    687-
    proc = (Form_pg_proc) GETSTRUCT(tuple);
    688686

    689687
    tmp = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_prosrc, &isnull);
    690688
    if (isnull)
    @@ -717,7 +715,6 @@ fmgr_c_validator(PG_FUNCTION_ARGS)
    717715
    Oid funcoid = PG_GETARG_OID(0);
    718716
    void *libraryhandle;
    719717
    HeapTuple tuple;
    720-
    Form_pg_proc proc;
    721718
    bool isnull;
    722719
    Datum tmp;
    723720
    char *prosrc;
    @@ -732,7 +729,6 @@ fmgr_c_validator(PG_FUNCTION_ARGS)
    732729
    tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid));
    733730
    if (!HeapTupleIsValid(tuple))
    734731
    elog(ERROR, "cache lookup failed for function %u", funcoid);
    735-
    proc = (Form_pg_proc) GETSTRUCT(tuple);
    736732

    737733
    tmp = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_prosrc, &isnull);
    738734
    if (isnull)

    src/backend/catalog/toasting.c

    Lines changed: 1 addition & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -118,7 +118,6 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid, Datum reloptio
    118118
    Relation toast_rel;
    119119
    Relation class_rel;
    120120
    Oid toast_relid;
    121-
    Oid toast_idxid;
    122121
    Oid toast_typid = InvalidOid;
    123122
    Oid namespaceid;
    124123
    char toast_relname[NAMEDATALEN];
    @@ -274,7 +273,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid, Datum reloptio
    274273
    coloptions[0] = 0;
    275274
    coloptions[1] = 0;
    276275

    277-
    toast_idxid = index_create(toast_rel, toast_idxname, toastIndexOid,
    276+
    index_create(toast_rel, toast_idxname, toastIndexOid,
    278277
    indexInfo,
    279278
    list_make2("chunk_id", "chunk_seq"),
    280279
    BTREE_AM_OID,

    src/backend/commands/explain.c

    Lines changed: 0 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1269,7 +1269,6 @@ show_plan_tlist(PlanState *planstate, List *ancestors, ExplainState *es)
    12691269
    List *result = NIL;
    12701270
    bool useprefix;
    12711271
    ListCell *lc;
    1272-
    int i;
    12731272

    12741273
    /* No work if empty tlist (this occurs eg in bitmap indexscans) */
    12751274
    if (plan->targetlist == NIL)
    @@ -1290,7 +1289,6 @@ show_plan_tlist(PlanState *planstate, List *ancestors, ExplainState *es)
    12901289
    useprefix = list_length(es->rtable) > 1;
    12911290

    12921291
    /* Deparse each result column (we now include resjunk ones) */
    1293-
    i = 0;
    12941292
    foreach(lc, plan->targetlist)
    12951293
    {
    12961294
    TargetEntry *tle = (TargetEntry *) lfirst(lc);

    src/backend/commands/tablecmds.c

    Lines changed: 0 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -8164,14 +8164,12 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
    81648164
    AttrNumber parent_attno;
    81658165
    int parent_natts;
    81668166
    TupleDesc tupleDesc;
    8167-
    TupleConstr *constr;
    81688167
    HeapTuple tuple;
    81698168

    81708169
    attrrel = heap_open(AttributeRelationId, RowExclusiveLock);
    81718170

    81728171
    tupleDesc = RelationGetDescr(parent_rel);
    81738172
    parent_natts = tupleDesc->natts;
    8174-
    constr = tupleDesc->constr;
    81758173

    81768174
    for (parent_attno = 1; parent_attno <= parent_natts; parent_attno++)
    81778175
    {

    src/backend/commands/tsearchcmds.c

    Lines changed: 1 addition & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -2156,14 +2156,12 @@ DropConfigurationMapping(AlterTSConfigurationStmt *stmt,
    21562156
    HeapTuple maptup;
    21572157
    int i;
    21582158
    Oid prsId;
    2159-
    int *tokens,
    2160-
    ntoken;
    2159+
    int *tokens;
    21612160
    ListCell *c;
    21622161

    21632162
    prsId = ((Form_pg_ts_config) GETSTRUCT(tup))->cfgparser;
    21642163

    21652164
    tokens = getTokenTypes(prsId, stmt->tokentype);
    2166-
    ntoken = list_length(stmt->tokentype);
    21672165

    21682166
    i = 0;
    21692167
    foreach(c, stmt->tokentype)

    src/backend/commands/vacuum.c

    Lines changed: 1 addition & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -92,8 +92,7 @@ vacuum(VacuumStmt *vacstmt, Oid relid, bool do_toast,
    9292
    BufferAccessStrategy bstrategy, bool for_wraparound, bool isTopLevel)
    9393
    {
    9494
    const char *stmttype;
    95-
    volatile bool all_rels,
    96-
    in_outer_xact,
    95+
    volatile bool in_outer_xact,
    9796
    use_own_xacts;
    9897
    List *relations;
    9998

    @@ -153,9 +152,6 @@ vacuum(VacuumStmt *vacstmt, Oid relid, bool do_toast,
    153152
    }
    154153
    vac_strategy = bstrategy;
    155154

    156-
    /* Remember whether we are processing everything in the DB */
    157-
    all_rels = (!OidIsValid(relid) && vacstmt->relation == NULL);
    158-
    159155
    /*
    160156
    * Build list of relations to process, unless caller gave us one. (If we
    161157
    * build one, we put it in vac_context for safekeeping.)

    src/backend/executor/nodeHashjoin.c

    Lines changed: 0 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -59,7 +59,6 @@ static bool ExecHashJoinNewBatch(HashJoinState *hjstate);
    5959
    TupleTableSlot * /* return: a tuple or NULL */
    6060
    ExecHashJoin(HashJoinState *node)
    6161
    {
    62-
    EState *estate;
    6362
    PlanState *outerNode;
    6463
    HashState *hashNode;
    6564
    List *joinqual;
    @@ -74,7 +73,6 @@ ExecHashJoin(HashJoinState *node)
    7473
    /*
    7574
    * get information from HashJoin node
    7675
    */
    77-
    estate = node->js.ps.state;
    7876
    joinqual = node->js.joinqual;
    7977
    otherqual = node->js.ps.qual;
    8078
    hashNode = (HashState *) innerPlanState(node);

    src/backend/executor/nodeMergejoin.c

    Lines changed: 0 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -639,7 +639,6 @@ ExecMergeTupleDump(MergeJoinState *mergestate)
    639639
    TupleTableSlot *
    640640
    ExecMergeJoin(MergeJoinState *node)
    641641
    {
    642-
    EState *estate;
    643642
    List *joinqual;
    644643
    List *otherqual;
    645644
    bool qualResult;
    @@ -655,7 +654,6 @@ ExecMergeJoin(MergeJoinState *node)
    655654
    /*
    656655
    * get information from node
    657656
    */
    658-
    estate = node->js.ps.state;
    659657
    innerPlan = innerPlanState(node);
    660658
    outerPlan = outerPlanState(node);
    661659
    econtext = node->js.ps.ps_ExprContext;

    src/backend/executor/nodeRecursiveunion.c

    Lines changed: 2 additions & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -79,7 +79,6 @@ ExecRecursiveUnion(RecursiveUnionState *node)
    7979
    PlanState *innerPlan = innerPlanState(node);
    8080
    RecursiveUnion *plan = (RecursiveUnion *) node->ps.plan;
    8181
    TupleTableSlot *slot;
    82-
    RUHashEntry entry;
    8382
    bool isnew;
    8483

    8584
    /* 1. Evaluate non-recursive term */
    @@ -93,8 +92,7 @@ ExecRecursiveUnion(RecursiveUnionState *node)
    9392
    if (plan->numCols > 0)
    9493
    {
    9594
    /* Find or build hashtable entry for this tuple's group */
    96-
    entry = (RUHashEntry)
    97-
    LookupTupleHashEntry(node->hashtable, slot, &isnew);
    95+
    LookupTupleHashEntry(node->hashtable, slot, &isnew);
    9896
    /* Must reset temp context after each hashtable lookup */
    9997
    MemoryContextReset(node->tempContext);
    10098
    /* Ignore tuple if already seen */
    @@ -141,8 +139,7 @@ ExecRecursiveUnion(RecursiveUnionState *node)
    141139
    if (plan->numCols > 0)
    142140
    {
    143141
    /* Find or build hashtable entry for this tuple's group */
    144-
    entry = (RUHashEntry)
    145-
    LookupTupleHashEntry(node->hashtable, slot, &isnew);
    142+
    LookupTupleHashEntry(node->hashtable, slot, &isnew);
    146143
    /* Must reset temp context after each hashtable lookup */
    147144
    MemoryContextReset(node->tempContext);
    148145
    /* Ignore tuple if already seen */

    src/backend/foreign/foreign.c

    Lines changed: 0 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -175,7 +175,6 @@ GetForeignServerByName(const char *srvname, bool missing_ok)
    175175
    UserMapping *
    176176
    GetUserMapping(Oid userid, Oid serverid)
    177177
    {
    178-
    Form_pg_user_mapping umform;
    179178
    Datum datum;
    180179
    HeapTuple tp;
    181180
    bool isnull;
    @@ -199,8 +198,6 @@ GetUserMapping(Oid userid, Oid serverid)
    199198
    errmsg("user mapping not found for \"%s\"",
    200199
    MappingUserName(userid))));
    201200

    202-
    umform = (Form_pg_user_mapping) GETSTRUCT(tp);
    203-
    204201
    um = (UserMapping *) palloc(sizeof(UserMapping));
    205202
    um->userid = userid;
    206203
    um->serverid = serverid;

    0 commit comments

    Comments
     (0)
    0