From: "Russ Cox" <rsc@plan9.bell-labs.com>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] pptp.c install failed
Date: Sun, 11 Nov 2001 16:32:49 -0500 [thread overview]
Message-ID: <20011111213252.1487419A52@mail.cse.psu.edu> (raw)
> Why not ``rerrstr(char *buf, int size)''?
> Or even ``rerrstr(Str buf)''?
>
> C needs a counted array type, but until then we shouldn't
> cut corners.
As part of the 9P2000 changes, we fixed both errstr and
rerrstr as you suggest:
int errstr(char *err, uint nerr)
void rerrstr(char *err, uint nerr)
ERRMAX takes the place of ERRLEN, but it is a convention
rather than a specification: if you use one that is too big
or too small, the safety of your program isn't put in jeopardy.
Thus the code in question originally read:
void
ewrite(int fd, void *buf, int nbuf)
{
char e[ERRMAX], path[64];
if(write(fd, buf, nbuf) != nbuf){
rerrstr(e, sizeof e);
strcpy(path, "unknown");
fd2path(fd, path, sizeof path);
myfatal("write %d to %s: %s", nbuf, path, e);
}
}
which I think you wouldn't have any problems with.
I did think about posting an rerrstr(char*, uint), but
our rerrstr uses utfecpy to make sure it truncates at
a character boundary, and that function is post-distribution
too, so I stopped the cascade by assuming ERRLEN: since
the distribution errstr already does it, I don't see a problem
doing it in other places until we get a proper distribution out.
Russ
next reply other threads:[~2001-11-11 21:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-11-11 21:32 Russ Cox [this message]
-- strict thread matches above, loose matches on Subject: below --
2001-11-12 21:49 Russ Cox
[not found] <rsc@plan9.bell-labs.com>
2001-11-11 20:35 ` Russ Cox
2001-11-11 21:17 ` Scott Schwartz
2001-11-11 23:25 ` Dan Cross
2001-11-12 11:42 ` Boyd Roberts
2001-11-12 18:13 ` William S .
2001-11-11 18:54 William S .
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=20011111213252.1487419A52@mail.cse.psu.edu \
--to=rsc@plan9.bell-labs.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).