Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4faa1dc

Browse files
committed
Suppress compiler warnings in dshash.c.
Some compilers complain, not unreasonably, about left-shifting anint32 "1" and then assigning the result to an int64. In practiceI sure hope that this data structure never gets large enough thatan overflow would actually occur; but let's cast the constant tothe right type to avoid the hazard.In passing, fix a typo in dshash.h.Amit Kapila, adjusted as per comment from Thomas Munro.Discussion:https://postgr.es/m/CAA4eK1+5vfVMYtjK_NX8O3-42yM3o80qdqWnQzGquPrbq6mb+A@mail.gmail.com
1 parente451901 commit4faa1dc

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

‎src/backend/lib/dshash.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ dshash_destroy(dshash_table *hash_table)
315315
ensure_valid_bucket_pointers(hash_table);
316316

317317
/* Free all the entries. */
318-
size=1 <<hash_table->size_log2;
318+
size=((size_t)1) <<hash_table->size_log2;
319319
for (i=0;i<size;++i)
320320
{
321321
dsa_pointeritem_pointer=hash_table->buckets[i];
@@ -676,7 +676,7 @@ resize(dshash_table *hash_table, size_t new_size_log2)
676676
dsa_pointernew_buckets_shared;
677677
dsa_pointer*new_buckets;
678678
size_tsize;
679-
size_tnew_size=1 <<new_size_log2;
679+
size_tnew_size=((size_t)1) <<new_size_log2;
680680
size_ti;
681681

682682
/*
@@ -707,10 +707,10 @@ resize(dshash_table *hash_table, size_t new_size_log2)
707707
new_buckets=dsa_get_address(hash_table->area,new_buckets_shared);
708708

709709
/*
710-
* We'veallocate the new bucket array; all that remains to do now is to
710+
* We'veallocated the new bucket array; all that remains to do now is to
711711
* reinsert all items, which amounts to adjusting all the pointers.
712712
*/
713-
size=1 <<hash_table->control->size_log2;
713+
size=((size_t)1) <<hash_table->control->size_log2;
714714
for (i=0;i<size;++i)
715715
{
716716
dsa_pointeritem_pointer=hash_table->buckets[i];

‎src/include/lib/dshash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ typedef dshash_hash (*dshash_hash_function) (const void *v, size_t size,
3939
* members tranche_id and tranche_name do not need to be initialized when
4040
* attaching to an existing hash table.
4141
*
42-
* Compare and hash functionsmus be supplied even when attaching, because we
42+
* Compare and hash functionsmust be supplied even when attaching, because we
4343
* can't safely share function pointers between backends in general. Either
4444
* the arg variants or the non-arg variants should be supplied; the other
4545
* function pointers should be NULL. If the arg varants are supplied then the

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp