9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Nathaniel W Filardo <nwf@cs.jhu.edu>
To: 9fans@9fans.net
Subject: [9fans] APE vsnprintf return value bug
Date: Mon,  9 Feb 2009 03:55:40 -0500	[thread overview]
Message-ID: <20090209085540.GC22259@masters6.cs.jhu.edu> (raw)

[-- Attachment #1: Type: text/plain, Size: 1097 bytes --]

There seems to be some disagreement about vsnprintf()'s return code, in a
way that's breaking my attempts to get git building on Plan 9.

The manual on my Linux box says:

> The  functions snprintf() and vsnprintf() do not write more than size
> bytes (including the trailing '\0').  If the output was truncated due to
> this limit then the return value is the number of characters (not
> including the trailing '\0') which would have been written to the final
> string if enough space had been available.  Thus, a return value of size
> or more means that the output was truncated.  (See also below under
> NOTES.)

While this strikes me as funny (though I suppose I see the merit), git
depends upon it being this way...  so when
/sys/src/ape/lib/ap/stdio/vfprintf.c says:

> int
> vfprintf(FILE *f, const char *s, va_list args)
> {
...
>   return ferror(f)? -1: nprint;;
> }

It appears that all hope is lost.  If I were to submit a patch which renamed
vfprintf to _vfprintf and pushed the ferror() check down to its callers,
would such a thing be accepted?

--nwf;

[-- Attachment #2: Type: application/pgp-signature, Size: 204 bytes --]

             reply	other threads:[~2009-02-09  8:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-09  8:55 Nathaniel W Filardo [this message]
2009-02-09  9:20 ` Steve Simon
2009-02-09 10:08   ` Charles Forsyth

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=20090209085540.GC22259@masters6.cs.jhu.edu \
    --to=nwf@cs.jhu.edu \
    --cc=9fans@9fans.net \
    /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).