9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] return of fd2path
@ 2003-05-06  9:09 William Ahern
  0 siblings, 0 replies; only message in thread
From: William Ahern @ 2003-05-06  9:09 UTC (permalink / raw)
  To: 9fans

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-05-06  9:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-06  9:09 [9fans] return of fd2path William Ahern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).