From 2337869fbf8b967eb53ee57f978f3751987e43dc Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 12 Jul 2021 00:00:20 -0700 Subject: Pacify gcc 11.1.1 -Wanalyzer-null-argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lib-src/etags.c (regexp): Omit member force_explicit_name, since it’s always true. All uses removed. This lets us remove calls to strlen (name) where GCC isn’t smart enough to deduce that name must be nonnull. * lib-src/movemail.c (main): Fix bug that could cause link (tempname, NULL) to be called. * src/emacs.c (argmatch): Break check into two ‘if’s, since GCC doesn’t seem to be smart enough to check the single ‘if’. * src/gtkutil.c (xg_update_menu_item): Fix bug where strcmp could be given a NULL arg. * src/xfont.c (xfont_list_family): Use nonnull value for dummy initial value. --- lib-src/movemail.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'lib-src/movemail.c') diff --git a/lib-src/movemail.c b/lib-src/movemail.c index cfdebccb8d0..e683da179df 100644 --- a/lib-src/movemail.c +++ b/lib-src/movemail.c @@ -270,6 +270,7 @@ main (int argc, char **argv) You might also wish to verify that your system is one which uses lock files for this purpose. Some systems use other methods. */ + bool lockname_unlinked = false; inname_len = strlen (inname); lockname = xmalloc (inname_len + sizeof ".lock"); strcpy (lockname, inname); @@ -312,15 +313,10 @@ main (int argc, char **argv) Five minutes should be good enough to cope with crashes and wedgitude, and long enough to avoid being fooled by time differences between machines. */ - if (stat (lockname, &st) >= 0) - { - time_t now = time (0); - if (st.st_ctime < now - 300) - { - unlink (lockname); - lockname = 0; - } - } + if (!lockname_unlinked + && stat (lockname, &st) == 0 + && st.st_ctime < time (0) - 300) + lockname_unlinked = unlink (lockname) == 0 || errno == ENOENT; } delete_lockname = lockname; -- cgit v1.2.3