From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu From: William Ahern Message-ID: Subject: [9fans] return of fd2path Date: Tue, 6 May 2003 09:09:57 +0000 Topicbox-Message-UUID: 9f281a0e-eacb-11e9-9e20-41e7f4b1d025 i writing a little program which needs to keep track of paths to open file descriptors [on *bsd/linux]. i wrote a lexical path normalizer, which is almost exactly the same as cleanname(), but i only figured that out afterwards (and after i found SUSv3's realpath() ;). anyhow, i also found fd2path(). so i'm in the process of shuffling my code to mimic the semantics of cleanname() and fd2path(), just 'cause i like their simplicity and might as well work toward an existing interface. _anyhow_, one thing that bugs me is the return value of fd2path(). why not make the return value similar to SUSv3's snprintf()? that is, return the length of the logical string? i saw a few posts on this. one was to make the return value the remainder of the logical length and the buffer length. another pointed out that inferno just returned a malloc'd string on its own. but, why force the developer to continually use strlen()? in my application i am keeping track of the length of the file paths from the instance the strings enter the program. i try to use only string functions that force superfluous use strlen(). the semantics of snprintf() seem quite reasonable. in fact, i can't really figure out a down side... anybody? i'm not trying to micro-optomize here, but in this case it doesn't make any sense to continually re-calculate the length of a string. curious.... - Bill