GNU bug report logs - #8401
removing duplication and improving the readlink code

Previous Next

Package: emacs;

Reported by: Paul Eggert <eggert <at> cs.ucla.edu>

Date: Fri, 1 Apr 2011 06:48:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 8401 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 8401 <at> debbugs.gnu.org
Subject: Re: removing duplication and improving the readlink code
Date: Fri, 01 Apr 2011 12:00:28 -0700
On 04/01/2011 01:33 AM, Eli Zaretskii wrote:
> Isn't much easier and much more elegant to use ssize_t instead of an
> int for the buffer sizes in both cases?

That doesn't suffice; the code should not only use ssize_t for
readlink's returned value, but it should also use size_t for the
buffer size, and it should check that neither type overflows.

We could modify both copies of Emacs's readlink-using
code to fix these problems, but when there's duplication like
this, it's typically better to have just one copy of the code,
and make any necessary fixes in that copy.

On 04/01/2011 01:33 AM, Eli Zaretskii wrote:
> If this patch is accepted, the new emacs_readlink function will be a
> trivial "fail" stub on Windows.

That would introduce an unnecessary "#ifdef DOS_NT" into the mainline
code.  We should strive to keep the mainline code free of
porting #ifdefs when it is easy, as it is in this case.
The proposed code should run just fine on Windows, using
the already-existing stubs.  We shouldn't need to clutter up
up the mainline code with unnecessary Windows-specific
microoptimizations.




This bug report was last modified 14 years and 54 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.