Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys/kern



> I wouldn't call that simplifying the code.  The added code doesn't change
> the result and the code is even more unreadable then before IMHO.

The previous version requires reader more consideration than mine.
Reader need to wonder what (sp->f_mntonname[0] == '\0') means, why is
called after the strlcpy().  Those things aren't necessary to think.

The guts of the code is to detect two cases (the mount point is
exactly equals to the chroot base, or under it) and do different
things for each case.  Mine is closer to this.

> I don't like the change before that, either.  The meaning of "len != 1) is
> obscure.  And one has to discover of unstated assumptions to understand
> what it possible means.  If any of these assumptions are violated in the
> future the code will, again, fail in obscure ways.  Why don't we use a
> check that will be true only if it finds exactly what the author expects.
> E.g. (len == 0 && *bp == '/') for matching the the root dir "/".

I don't think it is unstated assumptions that ``when getcwd is
success, the result is always starts with /''.

To really understand what the expression (len == 1 && *bp == '/')
means, reader is anyway required to understand what the len is and
what the bp is.  Once understands, the meaning of len == 1 is obvious.

enami.


Home | Main Index | Thread Index | Old Index