On Mon, Dec 23, 2013 at 10:21:59AM -0500, Ted Unangst wrote:
> On Mon, Dec 23, 2013 at 10:25, Jérémie Courrèges-Anglas wrote:
> > Ted Unangst <[email protected]> writes:
> >
> >> Part one of this diff eliminates a series of u_long casts in favor of
> >> just using native size_t types. A few other type adjustments.
> >
> > Wouldn't that make ssh harder to port to systems where those types
> > aren't available? See for example millert's last commit to
> > yacc/skeleton.c.
There's two types of porting pain: one-off and constant.
Not having a type like ptrdiff_t is the former. It's a problem that
can be dealt with once, eg testing for it in configure and typdef'ing
as appropriate. Not having %z is in the same boat (although a bit more
work to write a test for) since we already have a vsnprintf implementation
in the compat library and all the log messages use vsnprintf.
Constant pain is when we have to make changes to the portable code and
patches no longer apply. These are long-term pain because they keep
slowing things down (and, if we get it wrong, cause other problems)
so should be weighed up to make sure the benefit is worth the effort.
I haven't been through the diff yet to see how much of each type is in
there :-) I do note that %z is in SuSv3 (but not v2) so anything not
having it is likely to be old but not necessarily obsolete.
> What are these systems?
>
> The counter argument is that using long makes the code harder to port
> to systems where long and ptrdiff_t are different sizes. And by harder
> to port, I mean compiles fine but executes incorrectly. I consider
> that a worse problem.
>
> If ptrdiff_t is really out, I think I'd prefer to take my chances
> with ssize_t being the right size. (there are 3 occurrences of
> ptrdiff_t in umac.c too).
Given that it's already in use and we haven't had any complaints that
I'm aware of I have no objection to adding more ptrdiff_t. I'll look
through the rest of the diff shortly.
--
Darren Tucker (dtucker at zip.com.au)
GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4 37C9 C982 80C7 8FF4 FA69
Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.