aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorPaul Eggert2021-07-12 00:00:20 -0700
committerPaul Eggert2021-07-12 00:12:20 -0700
commit2337869fbf8b967eb53ee57f978f3751987e43dc (patch)
tree4efade0869b4c3f1d23ba4e09bdfc19cc2f57778 /lib-src
parentda2f772fe575b20bff51b49aa5ded2bf15a2c89d (diff)
downloademacs-2337869fbf8b967eb53ee57f978f3751987e43dc.tar.gz
emacs-2337869fbf8b967eb53ee57f978f3751987e43dc.zip
Pacify gcc 11.1.1 -Wanalyzer-null-argument
* 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.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c49
-rw-r--r--lib-src/movemail.c14
2 files changed, 24 insertions, 39 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c
index c39c93db336..88b49f803e9 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -340,7 +340,6 @@ typedef struct regexp
340 struct re_pattern_buffer *pat; /* the compiled pattern */ 340 struct re_pattern_buffer *pat; /* the compiled pattern */
341 struct re_registers regs; /* re registers */ 341 struct re_registers regs; /* re registers */
342 bool error_signaled; /* already signaled for this regexp */ 342 bool error_signaled; /* already signaled for this regexp */
343 bool force_explicit_name; /* do not allow implicit tag name */
344 bool ignore_case; /* ignore case when matching */ 343 bool ignore_case; /* ignore case when matching */
345 bool multi_line; /* do a multi-line match on the whole file */ 344 bool multi_line; /* do a multi-line match on the whole file */
346} regexp; 345} regexp;
@@ -6910,7 +6909,6 @@ add_regex (char *regexp_pattern, language *lang)
6910 struct re_pattern_buffer *patbuf; 6909 struct re_pattern_buffer *patbuf;
6911 regexp *rp; 6910 regexp *rp;
6912 bool 6911 bool
6913 force_explicit_name = true, /* do not use implicit tag names */
6914 ignore_case = false, /* case is significant */ 6912 ignore_case = false, /* case is significant */
6915 multi_line = false, /* matches are done one line at a time */ 6913 multi_line = false, /* matches are done one line at a time */
6916 single_line = false; /* dot does not match newline */ 6914 single_line = false; /* dot does not match newline */
@@ -6949,7 +6947,8 @@ add_regex (char *regexp_pattern, language *lang)
6949 case 'N': 6947 case 'N':
6950 if (modifiers == name) 6948 if (modifiers == name)
6951 error ("forcing explicit tag name but no name, ignoring"); 6949 error ("forcing explicit tag name but no name, ignoring");
6952 force_explicit_name = true; 6950 /* This option has no effect and is present only for backward
6951 compatibility. */
6953 break; 6952 break;
6954 case 'i': 6953 case 'i':
6955 ignore_case = true; 6954 ignore_case = true;
@@ -7004,7 +7003,6 @@ add_regex (char *regexp_pattern, language *lang)
7004 p_head->pat = patbuf; 7003 p_head->pat = patbuf;
7005 p_head->name = savestr (name); 7004 p_head->name = savestr (name);
7006 p_head->error_signaled = false; 7005 p_head->error_signaled = false;
7007 p_head->force_explicit_name = force_explicit_name;
7008 p_head->ignore_case = ignore_case; 7006 p_head->ignore_case = ignore_case;
7009 p_head->multi_line = multi_line; 7007 p_head->multi_line = multi_line;
7010} 7008}
@@ -7144,20 +7142,15 @@ regex_tag_multiline (void)
7144 name = NULL; 7142 name = NULL;
7145 else /* make a named tag */ 7143 else /* make a named tag */
7146 name = substitute (buffer, rp->name, &rp->regs); 7144 name = substitute (buffer, rp->name, &rp->regs);
7147 if (rp->force_explicit_name) 7145
7148 { 7146 /* Force explicit tag name, if a name is there. */
7149 /* Force explicit tag name, if a name is there. */ 7147 pfnote (name, true, buffer + linecharno,
7150 pfnote (name, true, buffer + linecharno, 7148 charno - linecharno + 1, lineno, linecharno);
7151 charno - linecharno + 1, lineno, linecharno); 7149
7152 7150 if (debug)
7153 if (debug) 7151 fprintf (stderr, "%s on %s:%"PRIdMAX": %s\n",
7154 fprintf (stderr, "%s on %s:%"PRIdMAX": %s\n", 7152 name ? name : "(unnamed)", curfdp->taggedfname,
7155 name ? name : "(unnamed)", curfdp->taggedfname, 7153 lineno, buffer + linecharno);
7156 lineno, buffer + linecharno);
7157 }
7158 else
7159 make_tag (name, strlen (name), true, buffer + linecharno,
7160 charno - linecharno + 1, lineno, linecharno);
7161 break; 7154 break;
7162 } 7155 }
7163 } 7156 }
@@ -7471,18 +7464,14 @@ readline (linebuffer *lbp, FILE *stream)
7471 name = NULL; 7464 name = NULL;
7472 else /* make a named tag */ 7465 else /* make a named tag */
7473 name = substitute (lbp->buffer, rp->name, &rp->regs); 7466 name = substitute (lbp->buffer, rp->name, &rp->regs);
7474 if (rp->force_explicit_name) 7467
7475 { 7468 /* Force explicit tag name, if a name is there. */
7476 /* Force explicit tag name, if a name is there. */ 7469 pfnote (name, true, lbp->buffer, match, lineno, linecharno);
7477 pfnote (name, true, lbp->buffer, match, lineno, linecharno); 7470
7478 if (debug) 7471 if (debug)
7479 fprintf (stderr, "%s on %s:%"PRIdMAX": %s\n", 7472 fprintf (stderr, "%s on %s:%"PRIdMAX": %s\n",
7480 name ? name : "(unnamed)", curfdp->taggedfname, 7473 name ? name : "(unnamed)", curfdp->taggedfname,
7481 lineno, lbp->buffer); 7474 lineno, lbp->buffer);
7482 }
7483 else
7484 make_tag (name, strlen (name), true,
7485 lbp->buffer, match, lineno, linecharno);
7486 break; 7475 break;
7487 } 7476 }
7488 } 7477 }
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)
270 You might also wish to verify that your system is one which 270 You might also wish to verify that your system is one which
271 uses lock files for this purpose. Some systems use other methods. */ 271 uses lock files for this purpose. Some systems use other methods. */
272 272
273 bool lockname_unlinked = false;
273 inname_len = strlen (inname); 274 inname_len = strlen (inname);
274 lockname = xmalloc (inname_len + sizeof ".lock"); 275 lockname = xmalloc (inname_len + sizeof ".lock");
275 strcpy (lockname, inname); 276 strcpy (lockname, inname);
@@ -312,15 +313,10 @@ main (int argc, char **argv)
312 Five minutes should be good enough to cope with crashes 313 Five minutes should be good enough to cope with crashes
313 and wedgitude, and long enough to avoid being fooled 314 and wedgitude, and long enough to avoid being fooled
314 by time differences between machines. */ 315 by time differences between machines. */
315 if (stat (lockname, &st) >= 0) 316 if (!lockname_unlinked
316 { 317 && stat (lockname, &st) == 0
317 time_t now = time (0); 318 && st.st_ctime < time (0) - 300)
318 if (st.st_ctime < now - 300) 319 lockname_unlinked = unlink (lockname) == 0 || errno == ENOENT;
319 {
320 unlink (lockname);
321 lockname = 0;
322 }
323 }
324 } 320 }
325 321
326 delete_lockname = lockname; 322 delete_lockname = lockname;