Johannes Schindelin [off-list ref] writes:
Okay, I made up my mind. Allowing "dir == NULL" is not
only a matter of convenience. It is the most natural
way to say that "dir" is an invalid or non-existing
directory.
That is also fine; it only needs to be clarified somehow to
people who might wonder what get_relative_cwd() function is used
for and how to use it in their programs. The comment that says
"As a convenience" may need to become a bit more elaborate to
say why it is convenient for the callers to do so (e.g. "The
caller may have called another function that returns a directory
to obtain the 'dir', which may have returned NULL as a way to
say 'there is nothing applicable in your case', and in such a
case, your $(cwd) relative to that 'dir' is also something that
cannot be used, hence a NULL is returned").