From: Paul Eggert <eggert@cs.ucla.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Bug in filelock.c
Date: Sat, 23 Feb 2013 11:39:43 -0800 [thread overview]
Message-ID: <51291AFF.2000602@cs.ucla.edu> (raw)
In-Reply-To: <83zjyukfxe.fsf@gnu.org>
On 02/23/2013 11:07 AM, Eli Zaretskii wrote:
> Am I missing something?
No, it looks like a clear bug. Thanks for catching it!
Also, that "p != lockfile" business is bogus;
p can never equal lockfile.
Since the code has obviously never worked and evidently
never been needed and slows Emacs down with unnecessary
syscalls, I propose that we remove it, as follows:
=== modified file 'src/filelock.c'
--- src/filelock.c 2013-02-01 06:30:51 +0000
+++ src/filelock.c 2013-02-23 19:37:31 +0000
@@ -289,44 +289,31 @@ typedef struct
/* Write the name of the lock file for FN into LFNAME. Length will be
- that of FN plus two more for the leading `.#' plus 1 for the
- trailing period plus one for the digit after it plus one for the
+ that of FN plus two more for the leading `.#' plus one for the
null. */
#define MAKE_LOCK_NAME(lock, file) \
- (lock = alloca (SBYTES (file) + 2 + 1 + 1 + 1), \
+ (lock = alloca (SBYTES (file) + 2 + 1), \
fill_in_lock_file_name (lock, (file)))
static void
fill_in_lock_file_name (register char *lockfile, register Lisp_Object fn)
{
ptrdiff_t length = SBYTES (fn);
- register char *p;
- struct stat st;
- int count = 0;
+ char *p;
strcpy (lockfile, SSDATA (fn));
/* Shift the nondirectory part of the file name (including the null)
right two characters. Here is one of the places where we'd have to
do something to support 14-character-max file names. */
- for (p = lockfile + length; p != lockfile && *p != '/'; p--)
+ p = lockfile + length;
+ do
p[2] = *p;
+ while (*--p != '/');
/* Insert the `.#'. */
p[1] = '.';
p[2] = '#';
-
- p = p + length + 2;
-
- while (lstat (lockfile, &st) == 0 && !S_ISLNK (st.st_mode))
- {
- if (count > 9)
- {
- *p = '\0';
- return;
- }
- sprintf (p, ".%d", count++);
- }
}
/* Lock the lock file named LFNAME.
next prev parent reply other threads:[~2013-02-23 19:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-23 19:07 Bug in filelock.c Eli Zaretskii
2013-02-23 19:39 ` Paul Eggert [this message]
2013-02-23 20:23 ` Eli Zaretskii
2013-02-23 21:59 ` Andreas Schwab
2013-02-24 0:25 ` Paul Eggert
2013-02-24 3:46 ` Eli Zaretskii
2013-02-24 7:30 ` Paul Eggert
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=51291AFF.2000602@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.