summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2017-09-03 15:12:29 +0000
committerTom Lane2017-09-03 15:12:29 +0000
commit4faa1dc2eb02ba67303110e025d44abb40b12725 (patch)
treed84d18aea235b4db3b1639959842225b51e10b5c
parente451901804bd96a6b0fe3875b5c90aa0555c6a05 (diff)
Suppress compiler warnings in dshash.c.
Some compilers complain, not unreasonably, about left-shifting an int32 "1" and then assigning the result to an int64. In practice I sure hope that this data structure never gets large enough that an overflow would actually occur; but let's cast the constant to the 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
-rw-r--r--src/backend/lib/dshash.c8
-rw-r--r--src/include/lib/dshash.h2
2 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/lib/dshash.c b/src/backend/lib/dshash.c
index 5dbd0c4227..448e058725 100644
--- a/src/backend/lib/dshash.c
+++ b/src/backend/lib/dshash.c
@@ -315,7 +315,7 @@ dshash_destroy(dshash_table *hash_table)
ensure_valid_bucket_pointers(hash_table);
/* Free all the entries. */
- size = 1 << hash_table->size_log2;
+ size = ((size_t) 1) << hash_table->size_log2;
for (i = 0; i < size; ++i)
{
dsa_pointer item_pointer = hash_table->buckets[i];
@@ -676,7 +676,7 @@ resize(dshash_table *hash_table, size_t new_size_log2)
dsa_pointer new_buckets_shared;
dsa_pointer *new_buckets;
size_t size;
- size_t new_size = 1 << new_size_log2;
+ size_t new_size = ((size_t) 1) << new_size_log2;
size_t i;
/*
@@ -707,10 +707,10 @@ resize(dshash_table *hash_table, size_t new_size_log2)
new_buckets = dsa_get_address(hash_table->area, new_buckets_shared);
/*
- * We've allocate the new bucket array; all that remains to do now is to
+ * We've allocated the new bucket array; all that remains to do now is to
* reinsert all items, which amounts to adjusting all the pointers.
*/
- size = 1 << hash_table->control->size_log2;
+ size = ((size_t) 1) << hash_table->control->size_log2;
for (i = 0; i < size; ++i)
{
dsa_pointer item_pointer = hash_table->buckets[i];
diff --git a/src/include/lib/dshash.h b/src/include/lib/dshash.h
index 3fd91f8697..362871bfe0 100644
--- a/src/include/lib/dshash.h
+++ b/src/include/lib/dshash.h
@@ -39,7 +39,7 @@ typedef dshash_hash (*dshash_hash_function) (const void *v, size_t size,
* members tranche_id and tranche_name do not need to be initialized when
* attaching to an existing hash table.
*
- * Compare and hash functions mus be supplied even when attaching, because we
+ * Compare and hash functions must be supplied even when attaching, because we
* can't safely share function pointers between backends in general. Either
* the arg variants or the non-arg variants should be supplied; the other
* function pointers should be NULL. If the arg varants are supplied then the