Re: Cast to uint16 in pg_checksum_page()

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: David Steele <david(at)pgmasters(dot)net>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Cast to uint16 in pg_checksum_page()
Date: 2020-03-04 04:41:05
Message-ID: 20200304044105.GD2593@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Mar 03, 2020 at 06:37:36PM -0500, David Steele wrote:
> Hackers,
>
> The current code in checksum_impl.h does not play nice with -Wconversion on
> gcc:
>
> warning: conversion to 'uint16 {aka short unsigned int}' from 'uint32 {aka
> unsigned int}' may alter its value [-Wconversion]
> return (checksum % 65535) + 1;
> ~~~~~~~~~~~~~~~~~~~^~~
>
> It seems like an explicit cast to uint16 would be better?

Attempting to compile the backend code with -Wconversion leads to many
warnings, still there has been at least one fix in the past to ease
the use of the headers in this case, with b5b3229 (this made the code
more readable). Should we really care about this case?
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2020-03-04 04:48:12 Re: Some problems of recovery conflict wait events
Previous Message Michael Paquier 2020-03-04 04:27:59 Re: Some problems of recovery conflict wait events