Unportable code in autoprewarm.c

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Unportable code in autoprewarm.c
Date: 2018-05-02 19:21:49
Message-ID: 7773.1525288909@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I've been going through compiler warnings from the buildfarm, and
I notice jacana is unhappy about this:

/* First line of the file is a record count. */
if (fscanf(file, "<<" INT64_FORMAT ">>\n", &num_elements) != 1)

It's entirely correct to complain, because we only guarantee that
INT64_FORMAT works with snprintf, not with the scanf family of
functions.

Is there a reason why this record count needs to be int64 rather than
plain int, and if so what? This code is not exactly well documented,
but it looks to me like the number of records should be bounded by
NBuffers, which is an int and is unlikely ever to not be an int.
So I'm inclined to just flush autoprewarm.c's use of int64 counters
altogether.

regards, tom lane

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-05-02 20:01:53 Re: A few warnings on Windows
Previous Message Andrew Dunstan 2018-05-02 19:19:08 Re: stats_ext test fails with -DCATCACHE_FORCE_RELEASE