Re: Cast to uint16 in pg_checksum_page() - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Cast to uint16 in pg_checksum_page()
Date
Msg-id 20200304044105.GD2593@paquier.xyz
Whole thread Raw
In response to Cast to uint16 in pg_checksum_page()  (David Steele <david@pgmasters.net>)
Responses Re: Cast to uint16 in pg_checksum_page()  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Some problems of recovery conflict wait events
Next
From: Fujii Masao
Date:
Subject: Re: Some problems of recovery conflict wait events