9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: William Ahern <william@wilbur.25thandclement.com>
To: 9fans@cse.psu.edu
Subject: [9fans] return of fd2path
Date: Tue,  6 May 2003 09:09:57 +0000	[thread overview]
Message-ID: <rmcgo-ibi.ln1@wilbur.25thandClement.com> (raw)

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


                 reply	other threads:[~2003-05-06  9:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=rmcgo-ibi.ln1@wilbur.25thandClement.com \
    --to=william@wilbur.25thandclement.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).