aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorPaul Eggert2022-05-12 17:01:10 -0700
committerPaul Eggert2022-05-12 17:03:55 -0700
commit0f731c49e6a8ccf3aa4c30c3f8ca82ed0a2cefb7 (patch)
treef675d5245b560aaaeae1c95f52df8ec882631d75 /lib-src
parent454caf858d92a87dc781bc35b421d5014a312bb9 (diff)
downloademacs-0f731c49e6a8ccf3aa4c30c3f8ca82ed0a2cefb7.tar.gz
emacs-0f731c49e6a8ccf3aa4c30c3f8ca82ed0a2cefb7.zip
Pacify GCC 12 in default developer build
This lets ‘./configure; make’ work on Fedora 36 x86-64 from a Git checkout without generating false-alarm warnings. * lib-src/etags.c (main): There appeared to be false alarm with GCC 12. However, the code was wrong anyway, as it mishandled file names containing "'" so fix that bug. This pacifies GCC. (mercury_decl): Omit tests ‘s + pos != NULL’ that were apparently intended to be ‘s[pos] != '\0'’ but which were miscoded to always be true and which were mostly not needed anyway. In one place, though, a test was needed, so fix that by using strchr instead. * src/alloc.c (lisp_free) [!GC_MALLOC_CHECK]: * src/term.c (Fsuspend_tty): Don’t look at a pointer after freeing it, even just to test it for equality with some other pointer, as this has undefined behavior in C and GCC 12 diagnoses this. * src/dbusbind.c (xd_read_message_1): Rework the code a bit so that it has fewer tests. This pacifies GCC 12 which was complaining incorrectly about dereferencing a null pointer. * src/intervals.c (copy_properties): Remove an eassume that should no longer be needed even to pacify older GCCs, due to ... * src/intervals.h (split_interval_left): ... this addition of ATTRIBUTE_RETURNS_NONNULL to pacify a GCC 12 warning about dereferencing a null pointer. * src/regex-emacs.c (EXTEND_BUFFER): Use negative values rather than auxiliary booleans to indicate null pointers. This pacifies GCC 12 false alarms about using uninitialized variables. * src/xdisp.c (clear_position): New function. (append_space_for_newline, extend_face_to_end_of_line): Use it to work around false alarms from GCC 12. (display_and_set_cursor): Add an UNINIT to pacify GCC 12. * src/xterm.c (x_draw_glyphless_glyph_string_foreground): Defend against hypothetical bad code elsewhere; this also pacifies GCC 12. (x_term_init): Use fixed-size auto array rather than alloca, as the array is small; this also pacifies GCC 12.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c
index 65b9fae8d5a..ea99ed9f396 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -1427,14 +1427,19 @@ main (int argc, char **argv)
1427 if (CTAGS) 1427 if (CTAGS)
1428 if (append_to_tagfile || update) 1428 if (append_to_tagfile || update)
1429 { 1429 {
1430 char *cmd = xmalloc (2 * strlen (tagfile) + sizeof "sort -u -o..");
1431 /* Maybe these should be used: 1430 /* Maybe these should be used:
1432 setenv ("LC_COLLATE", "C", 1); 1431 setenv ("LC_COLLATE", "C", 1);
1433 setenv ("LC_ALL", "C", 1); */ 1432 setenv ("LC_ALL", "C", 1); */
1434 char *z = stpcpy (cmd, "sort -u -o "); 1433 char *cmd = xmalloc (8 * strlen (tagfile) + sizeof "sort -u -o '' ''");
1435 z = stpcpy (z, tagfile); 1434 char *z = stpcpy (cmd, "sort -u -o '");
1436 *z++ = ' '; 1435 char *escaped_tagfile = z;
1437 strcpy (z, tagfile); 1436 for (; *tagfile; *z++ = *tagfile++)
1437 if (*tagfile == '\'')
1438 z = stpcpy (z, "'\\'");
1439 ptrdiff_t escaped_tagfile_len = z - escaped_tagfile;
1440 z = stpcpy (z, "' '");
1441 z = mempcpy (z, escaped_tagfile, escaped_tagfile_len);
1442 strcpy (z, "'");
1438 return system (cmd); 1443 return system (cmd);
1439 } 1444 }
1440 return EXIT_SUCCESS; 1445 return EXIT_SUCCESS;
@@ -6396,7 +6401,8 @@ mercury_decl (char *s, size_t pos)
6396 size_t origpos; 6401 size_t origpos;
6397 origpos = pos; 6402 origpos = pos;
6398 6403
6399 while (s + pos != NULL && (c_isalnum (s[pos]) || s[pos] == '_')) ++pos; 6404 while (c_isalnum (s[pos]) || s[pos] == '_')
6405 pos++;
6400 6406
6401 unsigned char decl_type_length = pos - origpos; 6407 unsigned char decl_type_length = pos - origpos;
6402 char buf[decl_type_length + 1]; 6408 char buf[decl_type_length + 1];
@@ -6440,9 +6446,9 @@ mercury_decl (char *s, size_t pos)
6440 so this is the hard case. */ 6446 so this is the hard case. */
6441 if (strcmp (buf, "solver") == 0) 6447 if (strcmp (buf, "solver") == 0)
6442 { 6448 {
6443 ++pos; 6449 do
6444 while (s + pos != NULL && (c_isalnum (s[pos]) || s[pos] == '_')) 6450 pos++;
6445 ++pos; 6451 while (c_isalnum (s[pos]) || s[pos] == '_');
6446 6452
6447 decl_type_length = pos - origpos; 6453 decl_type_length = pos - origpos;
6448 char buf2[decl_type_length + 1]; 6454 char buf2[decl_type_length + 1];
@@ -6492,7 +6498,6 @@ mercury_decl (char *s, size_t pos)
6492 while (c_isalnum (s[pos]) 6498 while (c_isalnum (s[pos])
6493 || s[pos] == '_' 6499 || s[pos] == '_'
6494 || (s[pos] == '.' /* A module dot. */ 6500 || (s[pos] == '.' /* A module dot. */
6495 && s + pos + 1 != NULL
6496 && (c_isalnum (s[pos + 1]) || s[pos + 1] == '_') 6501 && (c_isalnum (s[pos + 1]) || s[pos + 1] == '_')
6497 && (module_dot_pos = pos))) /* Record module dot position. 6502 && (module_dot_pos = pos))) /* Record module dot position.
6498 Erase module from name. */ 6503 Erase module from name. */
@@ -6536,10 +6541,10 @@ mercury_decl (char *s, size_t pos)
6536 } 6541 }
6537 else if (is_mercury_quantifier && s[pos] == '[') /* :- some [T] pred/func. */ 6542 else if (is_mercury_quantifier && s[pos] == '[') /* :- some [T] pred/func. */
6538 { 6543 {
6539 for (++pos; s + pos != NULL && s[pos] != ']'; ++pos) {} 6544 char *close_bracket = strchr (s + pos + 1, ']');
6540 if (s + pos == NULL) return null_pos; 6545 if (!close_bracket)
6541 ++pos; 6546 return null_pos;
6542 pos = skip_spaces (s + pos) - s; 6547 pos = skip_spaces (close_bracket + 1) - s;
6543 mercury_pos_t position = mercury_decl (s, pos); 6548 mercury_pos_t position = mercury_decl (s, pos);
6544 position.totlength += pos - origpos; 6549 position.totlength += pos - origpos;
6545 return position; 6550 return position;