Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Enable sub-second timeout in zsystem flock



dana (Monday 2020-01-06):
> Like i said, it doesn't seem to do much error-checking anywhere else, so i
> guess it's consistent... but if it were me i'd probably make any out-of-range
> value return an error, yeah.

Easy enough, except that producing a useful error message, with the
actual maximum value, is trickier than I'd expected.

zerrmsg() (and thus zwarnnam()) only supports displaying a long (%L)
if DEBUG is enabled (see "#ifdef DEBUG" lines 290 and 328 of
Src/utils.c), and no floating-point types.  Is this deliberate?
I can see why floats would be harder to support, but long seems
harmless.

If %L can be enabled in zerrmsg() then, getting back to zsystem/flock,
if there's an overflow on the value of the retry interval, it's easy to
display an error message saying that the value is limited to
LONG_MAX / 1000000L seconds (slightly underestimated for display
purposes).  As for an overflow on the (64-bit) timeout value, it's
harder to display the maximum value, but then users are less likely to
stumble into an overflow so I'd leave it silent and perhaps document it.

If not, there's always the possibility of displaying a generic "value
too large" message.


dana (Monday 2020-01-06):
> On 6 Jan 2020, at 11:30, Cedric Ware <cedric.ware__bml@xxxxxxxxxxxxxx> wrote:
> > Thanks for the pointer.  Yes, that could be done, though I don't have
> > the time right now.  What I actually had in mind was a test suite I
> > could run to check that I didn't break anything elsewhere.  Which is
> > "make test", I should have thought of it.  The current tests are still
> > successful with the patch.
> 
> I'm slightly busy again too but i could try to write a script for it later.

As I've never done this before, I'd feel more confident adding tests to
an existing script than trying to learn and write one from scratch.

					Thanks, best regards,
					Cedric Ware.



Messages sorted by: Reverse Date, Date, Thread, Author