Re: Moving other hex functions to /common

From: Sehrope Sarkuni <sehrope(at)jackdb(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Moving other hex functions to /common
Date: 2021-01-13 15:00:49
Message-ID: CAH7T-ao1CmpEHCY8CW-E9eViy+7qktmUDt5R+ZvDSzrz=dXfgw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The length functions in src/common/hex.c should cast srclen to uint64 prior
to the shift. The current hex_enc_len(...) in encode.c performs such a
cast.

diff --git a/src/common/hex.c b/src/common/hex.c
index 0123c69697..e87aa1fd7f 100644
--- a/src/common/hex.c
+++ b/src/common/hex.c
@@ -178,7 +178,7 @@ pg_hex_decode(const char *src, size_t srclen, char
*dst, size_t dstlen)
uint64
pg_hex_enc_len(size_t srclen)
{
- return (srclen << 1);
+ return (uint64) srclen << 1;
}

/*
@@ -192,5 +192,5 @@ pg_hex_enc_len(size_t srclen)
uint64
pg_hex_dec_len(size_t srclen)
{
- return (srclen >> 1);
+ return (uint64) srclen >> 1;
}

Regards,
-- Sehrope Sarkuni
Founder & CEO | JackDB, Inc. | https://www.jackdb.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2021-01-13 15:01:37 Re: Alter timestamp without timezone to with timezone rewrites rows
Previous Message Tomas Vondra 2021-01-13 14:43:29 Re: POC: postgres_fdw insert batching