From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu Subject: Re: [9fans] pptp.c install failed From: "Russ Cox" MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Message-Id: <20011111213252.1487419A52@mail.cse.psu.edu> Date: Sun, 11 Nov 2001 16:32:49 -0500 Topicbox-Message-UUID: 1e8fd914-eaca-11e9-9e20-41e7f4b1d025 > 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