Re: Integer undeflow in fprintf in dsa.c

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: Ильясов Ян <ianilyasov(at)outlook(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Integer undeflow in fprintf in dsa.c
Date: 2024-02-20 12:22:48
Message-ID: CA+TgmobJwzfiT7Mx2cTnoB0a6V0EaT6E0+rPKTiGehmg489S6Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Feb 20, 2024 at 5:30 PM Daniel Gustafsson <daniel(at)yesql(dot)se> wrote:
> The message "at least 0 contiguous pages free" reads a bit nonsensical though,
> wouldn't it be preferrable to check for i being zero and print a custom message
> for that case? Something like the below untested sketch?
>
> + if (i == 0)
> + fprintf(stderr,
> + " segment bin %zu (no contiguous free pages):\n", i);
> + else
> + fprintf(stderr,
> + " segment bin %zu (at least %d contiguous pages free):\n",
> + i, 1 << (i - 1));

That does seem reasonable. However, this is just debugging code, so it
also probably isn't necessary to sweat anything too much.

--
Robert Haas
EDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2024-02-20 12:24:49 Re: Replace current implementations in crypt() and gen_salt() to OpenSSL
Previous Message Tomas Vondra 2024-02-20 12:09:25 Re: logical decoding and replication of sequences, take 2