Cast to uint16 in pg_checksum_page()

From: David Steele <david(at)pgmasters(dot)net>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Cast to uint16 in pg_checksum_page()
Date: 2020-03-03 23:37:36
Message-ID: 91d86c8a-11fc-7b88-43eb-5ca3f6fb8bd3@pgmasters.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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?

Regards,
--
-David
david(at)pgmasters(dot)net

Attachment Content-Type Size
page-checksum-cast-v1.patch text/plain 507 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2020-03-03 23:39:26 Re: Is it time to retire type "opaque"?
Previous Message Alexander Korotkov 2020-03-03 23:31:43 Re: Psql patch to show access methods info