aboutsummaryrefslogtreecommitdiffstats
path: root/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 /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 'src')
-rw-r--r--src/alloc.c5
-rw-r--r--src/dbusbind.c41
-rw-r--r--src/intervals.c1
-rw-r--r--src/intervals.h2
-rw-r--r--src/regex-emacs.c21
-rw-r--r--src/term.c2
-rw-r--r--src/xdisp.c19
-rw-r--r--src/xterm.c17
8 files changed, 59 insertions, 49 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 43fbbb79bed..3cfc3d61ddd 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -1032,9 +1032,12 @@ lisp_free (void *block)
1032 return; 1032 return;
1033 1033
1034 MALLOC_BLOCK_INPUT; 1034 MALLOC_BLOCK_INPUT;
1035#ifndef GC_MALLOC_CHECK
1036 struct mem_node *m = mem_find (block);
1037#endif
1035 free (block); 1038 free (block);
1036#ifndef GC_MALLOC_CHECK 1039#ifndef GC_MALLOC_CHECK
1037 mem_delete (mem_find (block)); 1040 mem_delete (m);
1038#endif 1041#endif
1039 MALLOC_UNBLOCK_INPUT; 1042 MALLOC_UNBLOCK_INPUT;
1040} 1043}
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 7cfdbbe23cf..943a4aff8e7 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -1690,29 +1690,30 @@ xd_read_message_1 (DBusConnection *connection, Lisp_Object bus)
1690 value = Fgethash (key, Vdbus_registered_objects_table, Qnil); 1690 value = Fgethash (key, Vdbus_registered_objects_table, Qnil);
1691 1691
1692 /* Loop over the registered functions. Construct an event. */ 1692 /* Loop over the registered functions. Construct an event. */
1693 while (!NILP (value)) 1693 for (; !NILP (value); value = CDR_SAFE (value))
1694 { 1694 {
1695 key = CAR_SAFE (value); 1695 key = CAR_SAFE (value);
1696 Lisp_Object key_uname = CAR_SAFE (key);
1696 /* key has the structure (UNAME SERVICE PATH HANDLER). */ 1697 /* key has the structure (UNAME SERVICE PATH HANDLER). */
1697 if (((uname == NULL) 1698 if (uname && !NILP (key_uname)
1698 || (NILP (CAR_SAFE (key))) 1699 && strcmp (uname, SSDATA (key_uname)) != 0)
1699 || (strcmp (uname, SSDATA (CAR_SAFE (key))) == 0)) 1700 continue;
1700 && ((path == NULL) 1701 Lisp_Object key_service_etc = CDR_SAFE (key);
1701 || (NILP (CAR_SAFE (CDR_SAFE (CDR_SAFE (key))))) 1702 Lisp_Object key_path_etc = CDR_SAFE (key_service_etc);
1702 || (strcmp (path, 1703 Lisp_Object key_path = CAR_SAFE (key_path_etc);
1703 SSDATA (CAR_SAFE (CDR_SAFE (CDR_SAFE (key))))) 1704 if (path && !NILP (key_path)
1704 == 0)) 1705 && strcmp (path, SSDATA (key_path)) != 0)
1705 && (!NILP (CAR_SAFE (CDR_SAFE (CDR_SAFE (CDR_SAFE (key))))))) 1706 continue;
1706 { 1707 Lisp_Object handler = CAR_SAFE (CDR_SAFE (key_path_etc));
1707 EVENT_INIT (event); 1708 if (NILP (handler))
1708 event.kind = DBUS_EVENT; 1709 continue;
1709 event.frame_or_window = Qnil; 1710
1710 /* Handler. */ 1711 /* Construct an event and exit the loop. */
1711 event.arg 1712 EVENT_INIT (event);
1712 = Fcons (CAR_SAFE (CDR_SAFE (CDR_SAFE (CDR_SAFE (key)))), args); 1713 event.kind = DBUS_EVENT;
1713 break; 1714 event.frame_or_window = Qnil;
1714 } 1715 event.arg = Fcons (handler, args);
1715 value = CDR_SAFE (value); 1716 break;
1716 } 1717 }
1717 1718
1718 if (NILP (value)) 1719 if (NILP (value))
diff --git a/src/intervals.c b/src/intervals.c
index 687b237b9ea..9e28637d6bc 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -121,7 +121,6 @@ copy_properties (INTERVAL source, INTERVAL target)
121{ 121{
122 if (DEFAULT_INTERVAL_P (source) && DEFAULT_INTERVAL_P (target)) 122 if (DEFAULT_INTERVAL_P (source) && DEFAULT_INTERVAL_P (target))
123 return; 123 return;
124 eassume (source && target);
125 124
126 COPY_INTERVAL_CACHE (source, target); 125 COPY_INTERVAL_CACHE (source, target);
127 set_interval_plist (target, Fcopy_sequence (source->plist)); 126 set_interval_plist (target, Fcopy_sequence (source->plist));
diff --git a/src/intervals.h b/src/intervals.h
index 484fca2e756..0ce581208e3 100644
--- a/src/intervals.h
+++ b/src/intervals.h
@@ -251,7 +251,7 @@ extern void traverse_intervals_noorder (INTERVAL,
251 void (*) (INTERVAL, void *), void *); 251 void (*) (INTERVAL, void *), void *);
252extern INTERVAL split_interval_right (INTERVAL, ptrdiff_t) 252extern INTERVAL split_interval_right (INTERVAL, ptrdiff_t)
253 ATTRIBUTE_RETURNS_NONNULL; 253 ATTRIBUTE_RETURNS_NONNULL;
254extern INTERVAL split_interval_left (INTERVAL, ptrdiff_t); 254extern INTERVAL split_interval_left (INTERVAL, ptrdiff_t) ATTRIBUTE_RETURNS_NONNULL;
255extern INTERVAL find_interval (INTERVAL, ptrdiff_t); 255extern INTERVAL find_interval (INTERVAL, ptrdiff_t);
256extern INTERVAL next_interval (INTERVAL); 256extern INTERVAL next_interval (INTERVAL);
257extern INTERVAL previous_interval (INTERVAL); 257extern INTERVAL previous_interval (INTERVAL);
diff --git a/src/regex-emacs.c b/src/regex-emacs.c
index 700a6c357de..8662fe8d6d0 100644
--- a/src/regex-emacs.c
+++ b/src/regex-emacs.c
@@ -1244,21 +1244,22 @@ static int analyze_first (re_char *p, re_char *pend,
1244 return REG_ESIZE; \ 1244 return REG_ESIZE; \
1245 ptrdiff_t b_off = b - old_buffer; \ 1245 ptrdiff_t b_off = b - old_buffer; \
1246 ptrdiff_t begalt_off = begalt - old_buffer; \ 1246 ptrdiff_t begalt_off = begalt - old_buffer; \
1247 bool fixup_alt_jump_set = !!fixup_alt_jump; \ 1247 ptrdiff_t fixup_alt_jump_off = \
1248 bool laststart_set = !!laststart; \ 1248 fixup_alt_jump ? fixup_alt_jump - old_buffer : -1; \
1249 bool pending_exact_set = !!pending_exact; \ 1249 ptrdiff_t laststart_off = laststart ? laststart - old_buffer : -1; \
1250 ptrdiff_t fixup_alt_jump_off, laststart_off, pending_exact_off; \ 1250 ptrdiff_t pending_exact_off = \
1251 if (fixup_alt_jump_set) fixup_alt_jump_off = fixup_alt_jump - old_buffer; \ 1251 pending_exact ? pending_exact - old_buffer : -1; \
1252 if (laststart_set) laststart_off = laststart - old_buffer; \
1253 if (pending_exact_set) pending_exact_off = pending_exact - old_buffer; \
1254 bufp->buffer = xpalloc (bufp->buffer, &bufp->allocated, \ 1252 bufp->buffer = xpalloc (bufp->buffer, &bufp->allocated, \
1255 requested_extension, MAX_BUF_SIZE, 1); \ 1253 requested_extension, MAX_BUF_SIZE, 1); \
1256 unsigned char *new_buffer = bufp->buffer; \ 1254 unsigned char *new_buffer = bufp->buffer; \
1257 b = new_buffer + b_off; \ 1255 b = new_buffer + b_off; \
1258 begalt = new_buffer + begalt_off; \ 1256 begalt = new_buffer + begalt_off; \
1259 if (fixup_alt_jump_set) fixup_alt_jump = new_buffer + fixup_alt_jump_off; \ 1257 if (0 <= fixup_alt_jump_off) \
1260 if (laststart_set) laststart = new_buffer + laststart_off; \ 1258 fixup_alt_jump = new_buffer + fixup_alt_jump_off; \
1261 if (pending_exact_set) pending_exact = new_buffer + pending_exact_off; \ 1259 if (0 <= laststart_off) \
1260 laststart = new_buffer + laststart_off; \
1261 if (0 <= pending_exact_off) \
1262 pending_exact = new_buffer + pending_exact_off; \
1262 } while (false) 1263 } while (false)
1263 1264
1264 1265
diff --git a/src/term.c b/src/term.c
index bad1127c93b..3bea621dbda 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2287,9 +2287,9 @@ A suspended tty may be resumed by calling `resume-tty' on it. */)
2287 delete_keyboard_wait_descriptor (fileno (f)); 2287 delete_keyboard_wait_descriptor (fileno (f));
2288 2288
2289#ifndef MSDOS 2289#ifndef MSDOS
2290 fclose (f);
2291 if (f != t->display_info.tty->output) 2290 if (f != t->display_info.tty->output)
2292 fclose (t->display_info.tty->output); 2291 fclose (t->display_info.tty->output);
2292 fclose (f);
2293#endif 2293#endif
2294 2294
2295 t->display_info.tty->input = 0; 2295 t->display_info.tty->input = 0;
diff --git a/src/xdisp.c b/src/xdisp.c
index 82a018485d3..5ff54b2884f 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -22471,6 +22471,13 @@ compute_line_metrics (struct it *it)
22471} 22471}
22472 22472
22473 22473
22474static void
22475clear_position (struct it *it)
22476{
22477 it->position.charpos = 0;
22478 it->position.bytepos = 0;
22479}
22480
22474/* Append one space to the glyph row of iterator IT if doing a 22481/* Append one space to the glyph row of iterator IT if doing a
22475 window-based redisplay. The space has the same face as 22482 window-based redisplay. The space has the same face as
22476 IT->face_id. Value is true if a space was added. 22483 IT->face_id. Value is true if a space was added.
@@ -22506,7 +22513,7 @@ append_space_for_newline (struct it *it, bool default_face_p)
22506 struct face *face; 22513 struct face *face;
22507 22514
22508 it->what = IT_CHARACTER; 22515 it->what = IT_CHARACTER;
22509 memset (&it->position, 0, sizeof it->position); 22516 clear_position (it);
22510 it->object = Qnil; 22517 it->object = Qnil;
22511 it->len = 1; 22518 it->len = 1;
22512 22519
@@ -22835,7 +22842,7 @@ extend_face_to_end_of_line (struct it *it)
22835 const int stretch_width = 22842 const int stretch_width =
22836 indicator_column - it->current_x - char_width; 22843 indicator_column - it->current_x - char_width;
22837 22844
22838 memset (&it->position, 0, sizeof it->position); 22845 clear_position (it);
22839 22846
22840 /* Only generate a stretch glyph if there is distance 22847 /* Only generate a stretch glyph if there is distance
22841 between current_x and the indicator position. */ 22848 between current_x and the indicator position. */
@@ -22869,7 +22876,7 @@ extend_face_to_end_of_line (struct it *it)
22869 22876
22870 if (stretch_width > 0) 22877 if (stretch_width > 0)
22871 { 22878 {
22872 memset (&it->position, 0, sizeof it->position); 22879 clear_position (it);
22873 append_stretch_glyph (it, Qnil, stretch_width, 22880 append_stretch_glyph (it, Qnil, stretch_width,
22874 it->ascent + it->descent, 22881 it->ascent + it->descent,
22875 stretch_ascent); 22882 stretch_ascent);
@@ -22919,7 +22926,7 @@ extend_face_to_end_of_line (struct it *it)
22919 (((it->ascent + it->descent) 22926 (((it->ascent + it->descent)
22920 * FONT_BASE (font)) / FONT_HEIGHT (font)); 22927 * FONT_BASE (font)) / FONT_HEIGHT (font));
22921 saved_pos = it->position; 22928 saved_pos = it->position;
22922 memset (&it->position, 0, sizeof it->position); 22929 clear_position (it);
22923 saved_avoid_cursor = it->avoid_cursor_p; 22930 saved_avoid_cursor = it->avoid_cursor_p;
22924 it->avoid_cursor_p = true; 22931 it->avoid_cursor_p = true;
22925 saved_face_id = it->face_id; 22932 saved_face_id = it->face_id;
@@ -22957,7 +22964,7 @@ extend_face_to_end_of_line (struct it *it)
22957 enum display_element_type saved_what = it->what; 22964 enum display_element_type saved_what = it->what;
22958 22965
22959 it->what = IT_CHARACTER; 22966 it->what = IT_CHARACTER;
22960 memset (&it->position, 0, sizeof it->position); 22967 clear_position (it);
22961 it->object = Qnil; 22968 it->object = Qnil;
22962 it->c = it->char_to_display = ' '; 22969 it->c = it->char_to_display = ' ';
22963 it->len = 1; 22970 it->len = 1;
@@ -32651,7 +32658,7 @@ display_and_set_cursor (struct window *w, bool on,
32651{ 32658{
32652 struct frame *f = XFRAME (w->frame); 32659 struct frame *f = XFRAME (w->frame);
32653 int new_cursor_type; 32660 int new_cursor_type;
32654 int new_cursor_width; 32661 int new_cursor_width UNINIT;
32655 bool active_cursor; 32662 bool active_cursor;
32656 struct glyph_row *glyph_row; 32663 struct glyph_row *glyph_row;
32657 struct glyph *glyph; 32664 struct glyph *glyph;
diff --git a/src/xterm.c b/src/xterm.c
index 5c5de191dcc..165b0a6b01e 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -6621,6 +6621,10 @@ x_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
6621 glyph->ascent + glyph->descent - 1); 6621 glyph->ascent + glyph->descent - 1);
6622 x += glyph->pixel_width; 6622 x += glyph->pixel_width;
6623 } 6623 }
6624
6625 /* Defend against hypothetical bad code elsewhere that uses
6626 s->char2b after this function returns. */
6627 s->char2b = NULL;
6624} 6628}
6625 6629
6626#ifdef USE_X_TOOLKIT 6630#ifdef USE_X_TOOLKIT
@@ -23521,7 +23525,8 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
23521#ifdef USE_XCB 23525#ifdef USE_XCB
23522 xcb_connection_t *xcb_conn; 23526 xcb_connection_t *xcb_conn;
23523#endif 23527#endif
23524 char *cm_atom_sprintf; 23528 static char const cm_atom_fmt[] = "_NET_WM_CM_S%d";
23529 char cm_atom_sprintf[sizeof cm_atom_fmt - 2 + INT_STRLEN_BOUND (int)];
23525 23530
23526 block_input (); 23531 block_input ();
23527 23532
@@ -24212,14 +24217,8 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
24212 dpyinfo->resx = (mm < 1) ? 100 : pixels * 25.4 / mm; 24217 dpyinfo->resx = (mm < 1) ? 100 : pixels * 25.4 / mm;
24213 } 24218 }
24214 24219
24215 { 24220 sprintf (cm_atom_sprintf, cm_atom_fmt,
24216 int n = snprintf (NULL, 0, "_NET_WM_CM_S%d", 24221 XScreenNumberOfScreen (dpyinfo->screen));
24217 XScreenNumberOfScreen (dpyinfo->screen));
24218 cm_atom_sprintf = alloca (n + 1);
24219
24220 snprintf (cm_atom_sprintf, n + 1, "_NET_WM_CM_S%d",
24221 XScreenNumberOfScreen (dpyinfo->screen));
24222 }
24223 24222
24224 { 24223 {
24225 static const struct 24224 static const struct