Skip to content

Commit e36d164

Browse files
committed
Fix svace warnings + cosmetic
1 parent bc917c9 commit e36d164

File tree

6 files changed

+19
-16
lines changed

6 files changed

+19
-16
lines changed

src/btree_rum.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ rum_btree_extract_query(FunctionCallInfo fcinfo,
112112
case BTGreaterEqualStrategyNumber:
113113
case BTGreaterStrategyNumber:
114114
*ptr_partialmatch = true;
115+
/*FALLTHROUGH*/
115116
case BTEqualStrategyNumber:
116117
case RUM_DISTANCE:
117118
case RUM_LEFT_DISTANCE:

src/rum_ts_utils.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ PG_FUNCTION_INFO_V1(rum_ts_join_pos);
5353

5454
PG_FUNCTION_INFO_V1(tsquery_to_distance_query);
5555

56-
static int count_pos(char *ptr, int len);
56+
static unsigned int count_pos(char *ptr, int len);
5757
static char *decompress_pos(char *ptr, WordEntryPos *pos);
5858
static Datum build_tsvector_entry(TSVector vector, WordEntry *we);
5959
static Datum build_tsvector_hash_entry(TSVector vector, WordEntry *we);
@@ -354,7 +354,7 @@ rum_tsquery_timestamp_consistent(PG_FUNCTION_ARGS)
354354
#define SIXTHBIT 0x20
355355
#define LOWERMASK 0x1F
356356

357-
static int
357+
static unsigned int
358358
compress_pos(char *target, WordEntryPos *pos, int npos)
359359
{
360360
int i;
@@ -414,7 +414,7 @@ decompress_pos(char *ptr, WordEntryPos *pos)
414414
}
415415
}
416416

417-
static int
417+
static unsigned int
418418
count_pos(char *ptr, int len)
419419
{
420420
int count = 0,

src/rumdatapage.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ static BlockNumber dataGetRightMostPage(RumBtree btree, Page page);
2020

2121
/* Does datatype allow packing into the 1-byte-header varlena format? */
2222
#define TYPE_IS_PACKABLE(typlen, typstorage) \
23-
((typlen) == -1 && (typstorage) != 'p')
23+
((typlen) == -1 && (typstorage) != TYPSTORAGE_PLAIN)
2424

2525
/*
2626
* Increment data_length by the space needed by the datum, including any
@@ -99,7 +99,7 @@ rumDatumWrite(Pointer ptr, Datum datum, bool typbyval, char typalign,
9999
elog(ERROR, "unsupported byval length: %d", (int) (typlen));
100100
}
101101

102-
data_length = typlen;
102+
data_length = (Size)typlen;
103103
}
104104
else if (typlen == -1)
105105
{
@@ -149,7 +149,7 @@ rumDatumWrite(Pointer ptr, Datum datum, bool typbyval, char typalign,
149149
/* fixed-length pass-by-reference */
150150
ptr = (char *) att_align_nominal(ptr, typalign);
151151
Assert(typlen > 0);
152-
data_length = typlen;
152+
data_length = (Size)typlen;
153153
memmove(ptr, DatumGetPointer(datum), data_length);
154154
}
155155

@@ -736,7 +736,7 @@ RumDataPageAddItem(Page page, void *data, OffsetNumber offset)
736736
if (offset <= maxoff)
737737
memmove(ptr + sizeof(PostingItem),
738738
ptr,
739-
(maxoff - offset + 1) * sizeof(PostingItem));
739+
((uint16_t)(maxoff - offset + 1)) * sizeof(PostingItem));
740740
}
741741
memcpy(ptr, data, sizeof(PostingItem));
742742
RumPageGetOpaque(page)->maxoff++;
@@ -763,7 +763,7 @@ RumPageDeletePostingItem(Page page, OffsetNumber offset)
763763
char *dstptr = RumDataPageGetItem(page, offset),
764764
*sourceptr = RumDataPageGetItem(page, offset + 1);
765765

766-
memmove(dstptr, sourceptr, sizeof(PostingItem) * (maxoff - offset));
766+
memmove(dstptr, sourceptr, sizeof(PostingItem) * (uint16_t)(maxoff - offset));
767767
}
768768

769769
RumPageGetOpaque(page)->maxoff--;
@@ -1229,7 +1229,7 @@ dataSplitPageInternal(RumBtree btree, Buffer lbuf, Buffer rbuf,
12291229
RumItem *bound;
12301230
Page newlPage = PageGetTempPageCopy(BufferGetPage(lbuf));
12311231
RumItem oldbound = *RumDataPageGetRightBound(newlPage);
1232-
int sizeofitem = sizeof(PostingItem);
1232+
unsigned int sizeofitem = sizeof(PostingItem);
12331233
OffsetNumber maxoff = RumPageGetOpaque(newlPage)->maxoff;
12341234
Size pageSize = PageGetPageSize(newlPage);
12351235
Size freeSpace;
@@ -1246,7 +1246,7 @@ dataSplitPageInternal(RumBtree btree, Buffer lbuf, Buffer rbuf,
12461246
Assert(!RumPageIsLeaf(newlPage));
12471247
ptr = vector + (off - 1) * sizeofitem;
12481248
if (maxoff + 1 - off != 0)
1249-
memmove(ptr + sizeofitem, ptr, (maxoff - off + 1) * sizeofitem);
1249+
memmove(ptr + sizeofitem, ptr, (uint16_t)(maxoff - off + 1) * sizeofitem);
12501250
memcpy(ptr, &(btree->pitem), sizeofitem);
12511251

12521252
maxoff++;
@@ -1273,7 +1273,7 @@ dataSplitPageInternal(RumBtree btree, Buffer lbuf, Buffer rbuf,
12731273

12741274
ptr = RumDataPageGetItem(rPage, FirstOffsetNumber);
12751275
memcpy(ptr, vector + separator * sizeofitem,
1276-
(maxoff - separator) * sizeofitem);
1276+
(uint16_t)(maxoff - separator) * sizeofitem);
12771277
RumPageGetOpaque(rPage)->maxoff = maxoff - separator;
12781278
/* Adjust pd_lower */
12791279
((PageHeader) rPage)->pd_lower = (ptr +
@@ -1501,6 +1501,7 @@ rumInsertItemPointers(RumState * rumstate,
15011501
RumItem * items, uint32 nitem,
15021502
GinStatsData *buildStats)
15031503
{
1504+
Assert(gdi->stack);
15041505
BlockNumber rootBlkno = gdi->stack->blkno;
15051506

15061507
gdi->btree.items = items;

src/rumentrypage.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ static IndexTuple
112112
getRightMostTuple(Page page)
113113
{
114114
OffsetNumber maxoff = PageGetMaxOffsetNumber(page);
115+
Assert(maxoff!=InvalidOffsetNumber);
115116

116117
return (IndexTuple) PageGetItem(page, PageGetItemId(page, maxoff));
117118
}

src/rumget.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ startScanEntry(RumState * rumstate, RumScanEntry entry, Snapshot snapshot)
687687
else if (RumGetNPosting(itup) > 0)
688688
{
689689
entry->nlist = RumGetNPosting(itup);
690-
entry->predictNumberResult = entry->nlist;
690+
entry->predictNumberResult = (uint32_t)entry->nlist;
691691
entry->list = (RumItem *) palloc(sizeof(RumItem) * entry->nlist);
692692

693693
rumReadTuple(rumstate, entry->attnum, itup, entry->list, true);
@@ -1104,7 +1104,7 @@ entryGetNextItemList(RumState * rumstate, RumScanEntry entry, Snapshot snapshot)
11041104
else if (RumGetNPosting(itup) > 0)
11051105
{
11061106
entry->nlist = RumGetNPosting(itup);
1107-
entry->predictNumberResult = entry->nlist;
1107+
entry->predictNumberResult = (uint32_t)entry->nlist;
11081108
entry->list = (RumItem *) palloc(sizeof(RumItem) * entry->nlist);
11091109

11101110
rumReadTuple(rumstate, entry->attnum, itup, entry->list, true);

src/rumscan.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,12 +469,12 @@ lookupScanDirection(RumState *state, AttrNumber attno, StrategyNumber strategy)
469469
int i;
470470
RumConfig *rumConfig = state->rumConfig + attno - 1;
471471

472-
for(i = 0; rumConfig->strategyInfo[i].strategy != InvalidStrategy &&
473-
i < MAX_STRATEGIES; i++)
472+
for(i = 0; i < MAX_STRATEGIES; i++)
474473
{
474+
if (rumConfig->strategyInfo[i].strategy != InvalidStrategy)
475+
break;
475476
if (rumConfig->strategyInfo[i].strategy == strategy)
476477
return rumConfig->strategyInfo[i].direction;
477-
478478
}
479479

480480
return NoMovementScanDirection;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy