Collin Funk wrote: > > The cause is that xgetcwd() may return NULL, which I did not remember. > > Good catch. I assumed from the name it would always be successful or > exit. But it only exits when OOM, not for other errors.
And I made this assumption because when I looked at xgetcwd.h, it has no comment for the xgetcwd function. The comment is in the .c file. But modules should be usable without looking into the .c code. Looking at the module description and the .h file should be sufficient. This is the best practice since 1978, when Modula-2 came out with the distinction between "definition files" and "implementation files". We therefore need to move the comment from the .c file to the .h file. xgetcwd.h is not alone; all of the following files need their functions documented in the .h file: acl.h af_alg.h alignalloc.h areadlink.h argv-iter.h asyncsafe-spin.h backupfile.h base32.h base64.h canon-host.h chdir-long.h check-version.h closein.h closeout.h close-stream.h crc-x86_64.h cycle-check.h dev-ino.h dirent-safer.h dirname.h di-set.h exclude.h exitfail.h fcntl-safer.h filemode.h filenamecat.h file-set.h file-type.h fpending.h fsusage.h fts_.h getugroups.h hashcode-file.h human.h idcache.h ino-map.h inttostr.h i-ring.h isapipe.h localeinfo.h long-options.h memcasecmp.h memcoll.h mgetgroups.h mkancesdirs.h mkdir-p.h modechange.h mountlist.h mpsort.h openat.h openat-priv.h opendirat.h parse-datetime.h passfd.h posixtm.h posixver.h priv-set.h read-file.h readtokens0.h readtokens.h renameatu.h rijndael-alg-fst.h same.h save-cwd.h savedir.h snan.h stdio-safer.h stdlib-safer.h stdopen.h timespec.h trim.h unistd-safer.h unlinkdir.h userspec.h utimecmp.h utimens.h version-etc.h write-any-file.h xalloc.h xbinary-io.h xgetcwd.h xgethostname.h xmemcoll.h xmemdup0.h xnanosleep.h xreadlink.h yesno.h Bruno