Re: Range checks of pg_test_fsync --secs-per-test and pg_test_timing --duration - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: Range checks of pg_test_fsync --secs-per-test and pg_test_timing --duration
Date
Msg-id 4d4867ca-41fe-d95e-3b82-24818b508847@2ndquadrant.com
Whole thread Raw
In response to Range checks of pg_test_fsync --secs-per-test and pg_test_timing --duration  (Michael Paquier <michael@paquier.xyz>)
Responses Re: Range checks of pg_test_fsync --secs-per-test and pg_test_timing --duration  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
On 2020-08-06 08:27, Michael Paquier wrote:
> As $subject says, pg_test_fsync and pg_test_timing don't really check
> the range of option values specified.  It is possible for example to
> make pg_test_fsync run an infinite amount of time, and pg_test_timing
> does not handle overflows with --duration at all.
> 
> These are far from being critical issues, but let's fix them at least
> on HEAD.  So, please see the attached, where I have also added some
> basic TAP tests for both tools.

According to the POSIX standard, atoi() is not required to do any error 
checking, and if you want error checking, you should use strtol().

And if you do that, you might as well change the variables to unsigned 
and use strtoul(), and then drop the checks for <=0.  I would allow 0. 
It's not very useful, but it's not harmful and could be applicable in 
testing.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



pgsql-hackers by date:

Previous
From: Ranier Vilela
Date:
Subject: Re: [PATCH] Redudant initilization
Next
From: Alvaro Herrera
Date:
Subject: Re: PATCH: Batch/pipelining support for libpq