Fix a race condition diagnosed by gcc -Wsequence-point (Bug#8254).
[bpt/emacs.git] / src / ChangeLog
index 0b7f7e7..7e873e3 100644 (file)
@@ -1,6 +1,277 @@
-2011-03-10  Paul Eggert  <eggert@cs.ucla.edu>
+2011-03-15  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Fix a race condition diagnosed by gcc -Wsequence-point (Bug#8254).
+       An expression of the form (DOWNCASE (x) == DOWNCASE (y)), found in
+       dired.c's scmp function, had undefined behavior.
+       * lisp.h (DOWNCASE_TABLE, UPCASE_TABLE, DOWNCASE, UPPERCASEP):
+       (NOCASEP, LOWERCASEP, UPCASE, UPCASE1): Move from here ...
+       * buffer.h: ... to here, because these macros use current_buffer,
+       and the new implementation with inline functions needs to have
+       current_buffer in scope now, rather than later when the macros
+       are used.
+       (downcase, upcase1): New static inline functions.
+       (DOWNCASE, UPCASE1): Reimplement using these functions.
+       This avoids undefined behavior in expressions like
+       DOWNCASE (x) == DOWNCASE (y), which previously suffered
+       from race conditions in accessing the global variables
+       case_temp1 and case_temp2.
+       * casetab.c (case_temp1, case_temp2): Remove; no longer needed.
+       * lisp.h (case_temp1, case_temp2): Remove their decls.
+       * character.h (ASCII_CHAR_P): Move from here ...
+       * lisp.h: ... to here, so that the inline functions mentioned
+       above can use them.
+
+       * dired.c (directory_files_internal_unwind): Now static.
+
+       * fileio.c (file_name_as_directory, directory_file_name):
+       (barf_or_query_if_file_exists, auto_save_error, auto_save_1):
+       Now static.
+       (file_name_as_directory): Use const pointers when appropriate.
+       (Fexpand_file_name): Likewise.  In particular, newdir might
+       point at constant storage, so make it a const pointer.
+       (Fmake_directory_internal, Fread_file_name): Remove unused vars.
+       (Ffile_selinux_context, Fset_file_selinux_context): Fix pointer
+       signedness issues.
+       (Fset_file_times, Finsert_file_contents, auto_save_error):
+       Rename locals to avoid shadowing.
+
+       * minibuf.c (choose_minibuf_frame_1): Now static.
+       (Ftry_completion, Fall_completions): Rename or remove locals
+       to avoid shadowing.
+
+       * marker.c (bytepos_to_charpos): Remove; unused.
+
+       * lisp.h (verify_bytepos, count_markers): New decls,
+       so that gcc does not warn that these functions aren't declared.
+
+       * insdel.c (check_markers, make_gap_larger, make_gap_smaller):
+       (reset_var_on_error, Fcombine_after_change_execute_1): Now static.
+       (CHECK_MARKERS): Redo to avoid gcc -Wempty-body diagnostic.
+       (copy_text): Remove unused local var.
+
+       * filelock.c (within_one_second): Now static.
+       (lock_file_1): Rename local to avoid shadowing.
+
+       * buffer.c (fix_overlays_before): Mark locals as initialized.
+       (fix_start_end_in_overlays): Likewise.  This function should be
+       simplified by using pointers-to-pointers, but that's a different
+       matter.
+
+2011-03-14  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * buffer.c (switch_to_buffer_1): Now static.
+       (Fkill_buffer, record_buffer, Fbury_buffer, Fset_buffer_multibyte):
+       (report_overlay_modification): Rename locals to avoid shadowing.
+
+       * sysdep.c (system_process_attributes): Rename vars to avoid shadowing.
+       Fix pointer signedness issue.
+       (sys_subshell): Mark local as volatile if checking for lint,
+       to suppress a gcc -Wclobbered warning that does not seem to be right.
+       (MAXPATHLEN): Define only if needed.
+
+       * process.c (serial_open, serial_configure): Move decls from here ...
+       * systty.h: ... to here, so that they can be checked.
+
+       * fns.c (get_random, seed_random): Move extern decls from here ...
+       * lisp.h: ... to here, so that they can be checked.
+
+       * sysdep.c (reset_io): Now static.
+       (wait_for_termination_signal): Remove; unused.
+
+       * keymap.c (keymap_parent, keymap_memberp, map_keymap_internal):
+       (copy_keymap_item, append_key, push_text_char_description):
+       Now static.
+       (Fwhere_is_internal): Don't test CONSP (sequences) unnecessarily.
+       (DENSE_TABLE_SIZE): Remove; unused.
+       (get_keymap, access_keymap, Fdefine_key, Fwhere_is_internal):
+       (describe_map_tree):
+       Rename locals to avoid shadowing.
+
+       * keyboard.c: Declare functions static if they are not used elsewhere.
+       (echo_char, echo_dash, cmd_error, top_level_2):
+       (poll_for_input, handle_async_input): Now static.
+       (read_char, kbd_buffer_get_event, make_lispy_position):
+       (make_lispy_event, make_lispy_movement, apply_modifiers):
+       (decode_keyboard_code, tty_read_avail_input, menu_bar_items):
+       (parse_tool_bar_item, read_key_sequence, Fread_key_sequence):
+       (Fread_key_sequence_vector): Rename locals to avoid shadowing.
+       (read_key_sequence, read_char): Mark locals as initialized.
+       (Fexit_recursive_edit, Fabort_recursive_edit): Mark with NO_RETURN.
+
+       * keyboard.h (make_ctrl_char): New decl.
+       (mark_kboards): Move decl here ...
+       * alloc.c (mark_kboards): ... from here.
+
+       * lisp.h (force_auto_save_soon): New decl.
+
+       * emacs.c (init_cmdargs): Rename local to avoid shadowing.
+       (DEFINE_DUMMY_FUNCTION): New macro.
+       (__do_global_ctors, __do_global_ctors_aux, __do_global_dtors, __main):
+       Use it.
+       (main): Add casts to avoid warnings
+       if GCC considers string literals to be constants.
+
+       * lisp.h (fatal_error_signal): Add decl, since it's exported.
+
+       * dbusbind.c: Pointer signedness fixes.
+       (xd_signature, xd_append_arg, xd_initialize):
+       (Fdbus_call_method, Fdbus_call_method_asynchronously):
+       (Fdbus_method_return_internal, Fdbus_method_error_internal):
+       (Fdbus_send_signal, xd_read_message_1, Fdbus_register_service):
+       (Fdbus_register_signal): Use SSDATA when the context wants char *.
+
+       * dbusbind.c (Fdbus_init_bus): Add cast to avoid warning
+       if GCC considers string literals to be constants.
+       (Fdbus_register_service, Fdbus_register_method): Remove unused vars.
+
+2011-03-13  Chong Yidong  <cyd@stupidchicken.com>
+
+       * buffer.h (BUF_BEGV, BUF_BEGV_BYTE, BUF_ZV, BUF_ZV_BYTE, BUF_PT)
+       (BUF_PT_BYTE): Rewrite to handle indirect buffers (Bug#8219).
+       These macros can no longer be used for assignment.
+
+       * buffer.c (Fget_buffer_create, Fmake_indirect_buffer): Assign
+       struct members directly, instead of using BUF_BEGV etc.
+       (record_buffer_markers, fetch_buffer_markers): New functions for
+       recording and fetching special buffer markers.
+       (set_buffer_internal_1, set_buffer_temp): Use them.
+
+       * lread.c (unreadchar): Use SET_BUF_PT_BOTH.
+
+       * insdel.c (adjust_point): Use SET_BUF_PT_BOTH.
+
+       * intervals.c (temp_set_point_both): Use SET_BUF_PT_BOTH.
+       (get_local_map): Use SET_BUF_BEGV_BOTH and SET_BUF_ZV_BOTH.
+
+       * xdisp.c (hscroll_window_tree):
+       (reconsider_clip_changes): Use PT instead of BUF_PT.
+
+2011-03-13  Eli Zaretskii  <eliz@gnu.org>
+
+       * makefile.w32-in ($(BLD)/editfns.$(O)): Depend on
+       $(EMACS_ROOT)/lib/intprops.h.
+
+2011-03-13  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Fix more problems found by GCC 4.5.2's static checks.
+
+       * gtkutil.c (xg_get_pixbuf_from_pixmap): Add cast from char *
+       to unsigned char * to avoid compiler diagnostic.
+       (xg_free_frame_widgets): Make it clear that a local variable is
+       needed only if USE_GTK_TOOLTIP.
+       (gdk_window_get_screen): Make it clear that this macro is needed
+       only if USE_GTK_TOOLTIP.
+       (int_gtk_range_get_value): New function, which avoids a diagnostic
+       from gcc -Wbad-function-cast.
+       (xg_set_toolkit_scroll_bar_thumb): Use it.
+       (xg_tool_bar_callback, xg_tool_item_stale_p): Rewrite to avoid
+       diagnostic from gcc -Wbad-function-cast.
+       (get_utf8_string, xg_get_file_with_chooser):
+       Rename locals to avoid shadowing.
+       (create_dialog): Move locals to avoid shadowing.
+
+       * xgselect.c (xg_select): Remove unused var.
+
+       * image.c (four_corners_best): Mark locals as initialized.
+       (gif_load): Initialize transparent_p to zero (Bug#8238).
+       Mark another local as initialized.
+       (my_png_error, my_error_exit): Mark with NO_RETURN.
+
+       * image.c (clear_image_cache): Now static.
+       (DIM, HAVE_STDLIB_H_1): Remove unused macros.
+       (xpm_load): Redo to avoid "discards qualifiers" gcc warning.
+       (x_edge_detection): Remove unnecessary cast that
+       gcc -Wbad-function-cast diagnoses.
+       (gif_load): Fix pointer signedness.
+       (clear_image_cache, xbm_read_bitmap_data, x_detect_edges):
+       (jpeg_load, gif_load): Rename locals to avoid shadowing.
+
+2011-03-11  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Improve quality of tests for time stamp overflow.
+       For example, without this patch (encode-time 0 0 0 1 1
+       1152921504606846976) returns the obviously-bogus value (-948597
+       62170) on my RHEL 5.5 x86-64 host.  With the patch, it correctly
+       reports time overflow.  See
+       <http://lists.gnu.org/archive/html/emacs-devel/2011-03/msg00470.html>.
+       * deps.mk (editfns.o): Depend on ../lib/intprops.h.
+       * editfns.c: Include limits.h and intprops.h.
+       (TIME_T_MIN, TIME_T_MAX): New macros.
+       (time_overflow): Move earlier, to before first use.
+       (hi_time, lo_time): New functions, for an accurate test for
+       out-of-range times.
+       (Fcurrent_time, Fget_internal_run_time, make_time): Use them.
+       (Fget_internal_run_time): Don't assume time_t fits in int.
+       (make_time): Use list2 instead of Fcons twice.
+       (Fdecode_time): More accurate test for out-of-range times.
+       (check_tm_member): New function.
+       (Fencode_time): Use it, to test for out-of-range times.
+       (lisp_time_argument): Don't rely on undefined left-shift and
+       right-shift behavior when checking for time stamp overflow.
+
+       * editfns.c (time_overflow): New function, refactoring common code.
+       (Fformat_time_string, Fdecode_time, Fencode_time):
+       (Fcurrent_time_string): Use it.
+
+       Move 'make_time' to be next to its inverse 'lisp_time_argument'.
+       * dired.c (make_time): Move to ...
+       * editfns.c (make_time): ... here.
+       * systime.h: Note the move.
+
+2011-03-12  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+       * fringe.c (update_window_fringes): Remove unused variables.
+
+       * unexmacosx.c (copy_data_segment): Also copy __got section.
+       (Bug#8223)
+
+2011-03-12  Eli Zaretskii  <eliz@gnu.org>
+
+       * termcap.c [MSDOS]: Include "msdos.h.
+       (find_capability, tgetnum, tgetflag, tgetstr, tputs, tgetent):
+       Constify `char *' arguments and their references according to
+       prototypes in tparam.h.
+
+       * deps.mk (termcap.o): Depend on tparam.h and msdos.h.
+
+       * msdos.c (XMenuAddPane): 3rd argument is `const char *' now.
+       Adapt all references accordingly.
+
+       * msdos.h (XMenuAddPane): 3rd argument is `const char *' now.
+
+2011-03-11  Tom Tromey  <tromey@redhat.com>
+
+       * buffer.c (syms_of_buffer): Remove obsolete comment.
+
+2011-03-11  Eli Zaretskii  <eliz@gnu.org>
+
+       * termhooks.h (encode_terminal_code): Declare prototype.
+
+       * msdos.c (encode_terminal_code): Don't declare prototype.
+
+       * term.c (encode_terminal_code): Now external again, used by
+       w32console.c and msdos.c.
+
+       * makefile.w32-in ($(BLD)/term.$(O), ($(BLD)/tparam.$(O)): Depend
+       on $(SRC)/tparam.h, see 2011-03-11T07:24:21Z!eggert@cs.ucla.edu.
+
+2011-03-11  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Fix some minor problems found by GCC 4.5.2's static checks.
+
+       * fringe.c (update_window_fringes): Mark locals as initialized
+       (Bug#8227).
+       (destroy_fringe_bitmap, init_fringe_bitmap): Now static.
+
+       * alloc.c (mark_fringe_data): Move decl from here ...
+       * lisp.h (mark_fringe_data) [HAVE_WINDOW_SYSTEM]: ... to here,
+       to check its interface.
+       (init_fringe_once): Do not declare unless HAVE_WINDOW_SYSTEM.
 
        * fontset.c (free_realized_fontset): Now static.
+       (Fset_fontset_font): Rename local to avoid shadowing.
+       (fontset_font): Mark local as initialized.
+       (FONTSET_SPEC, FONTSET_REPERTORY, RFONT_DEF_REPERTORY): Remove; unused.
 
        * xrdb.c: Include "xterm.h", to check x_load_resources's interface.
 
        * lisp.h (GCPRO1_VAR, UNGCPRO_VAR): New macros,
        so that the caller can use some name other than gcpro1.
        (GCPRO1, UNGCPRO): Reimplement in terms of the new macros.
-       * xfns.c (x_decode_color, x_set_name, x_window): Now static.
+       * xfns.c (Fx_create_frame, x_create_tip_frame, Fx_show_tip):
+       (Fx_backspace_delete_keys_p):
+       Use them to avoid shadowing, and rename vars to avoid shadowing.
+       (x_decode_color, x_set_name, x_window): Now static.
        (Fx_create_frame): Add braces to silence GCC warning.
        (Fx_file_dialog, Fx_select_font): Fix pointer signedness.
        (x_real_positions, xg_set_icon_from_xpm_data, x_create_tip_frame):
        Some of these renamings use the new GCPRO1_VAR and UNGCPRO_VAR
        macros.
 
-2011-03-09  Paul Eggert  <eggert@cs.ucla.edu>
-
        * xterm.h (x_mouse_leave): New decl.
 
        * xterm.c (x_copy_dpy_color, x_focus_on_frame, x_unfocus_frame):
        since it's unused otherwise.
 
        * xdisp.c (produce_glyphless_glyph): Initialize lower_xoff.
-       Add a FIXME comment, since the code still doesn't look right.
+       Add a FIXME, since the code still doesn't look right.  (Bug#8215)
        (Fcurrent_bidi_paragraph_direction): Simplify slightly; this
        avoids a gcc -Wuninitialized diagnostic.
        (display_line, BUILD_COMPOSITE_GLYPH_STRING, draw_glyphs):
        and to avoid gcc -Wuninitialized warning.
        (load_charset_map): Mark variables that gcc -Wuninitialized
        does not deduce are never used uninitialized.
-       (load_charset): Abort instead of using uninitialized var.
+       (load_charset): Abort instead of using uninitialized var (Bug#8229).
 
        * coding.c (coding_set_source, coding_set_destination):
        Use "else { /* comment */ }" rather than "else /* comment */;"
        -Wuninitialized does not deduce are never used uninitialized.
        (detect_coding_iso_2022): Initialize a local variable that might
        be used uninitialized.  Leave a FIXME because it's not clear that
-       this initialization is needed.
+       this initialization is needed.  (Bug#8211)
        (ISO_CODE_LF, ISO_CODE_CR, CODING_ISO_FLAG_EUC_TW_SHIFT):
        (ONE_MORE_BYTE_NO_CHECK, UTF_BOM, UTF_16_INVALID_P):
        (SHIFT_OUT_OK, ENCODE_CONTROL_SEQUENCE_INTRODUCER):
        * alloc.c (mark_ttys): Move decl from here ...
        * lisp.h (mark_ttys): ... to here, so that it's checked against defn.
 
+2011-03-11  Andreas Schwab  <schwab@linux-m68k.org>
+
+       * .gdbinit (pwinx, xbuffer): Fix access to buffer name.
+
+2011-03-09  Juanma Barranquero  <lekktu@gmail.com>
+
+       * search.c (compile_pattern_1): Remove argument regp, unused since
+       revid:rms@gnu.org-19941211082627-3x1g1wyqkjmwloig.
+       (compile_pattern): Don't pass it.
+
+2011-03-08  Jan Djärv  <jan.h.d@swipnet.se>
+
+       * xterm.h (DEFAULT_GDK_DISPLAY): New define.
+       (GDK_WINDOW_XID, gtk_widget_get_preferred_size): New defines
+       for ! HAVE_GTK3.
+       (GTK_WIDGET_TO_X_WIN): Use GDK_WINDOW_XID.
+
+       * xmenu.c (menu_position_func): Call gtk_widget_get_preferred_size.
+
+       * gtkutil.c: Include gtkx.h if HAVE_GTK3.  If ! HAVE_GTK3, define
+       gdk_window_get_screen, gdk_window_get_geometry,
+       gdk_x11_window_lookup_for_display and GDK_KEY_g.
+       (xg_set_screen): Use DEFAULT_GDK_DISPLAY.
+       (xg_get_pixbuf_from_pixmap): New function.
+       (xg_get_pixbuf_from_pix_and_mask): Change parameters from GdkPixmap
+       to Pixmap, take frame as parameter, remove GdkColormap parameter.
+       Call xg_get_pixbuf_from_pixmap instead of
+       gdk_pixbuf_get_from_drawable.
+       (xg_get_image_for_pixmap): Do not make GdkPixmaps, call
+       xg_get_pixbuf_from_pix_and_mask with Pixmap parameters instead.
+       (xg_check_special_colors): Use GtkStyleContext and its functions
+       for HAVE_GTK3.
+       (xg_prepare_tooltip, xg_hide_tooltip): Call gdk_window_get_screen.
+       (xg_prepare_tooltip, create_dialog, menubar_map_cb)
+       (xg_update_frame_menubar, xg_tool_bar_detach_callback)
+       (xg_tool_bar_attach_callback, xg_update_tool_bar_sizes): Call
+       gtk_widget_get_preferred_size.
+       (xg_frame_resized): gdk_window_get_geometry only takes 5
+       parameters.
+       (xg_win_to_widget, xg_event_is_for_menubar): Call
+       gdk_x11_window_lookup_for_display.
+       (xg_set_widget_bg): New function.
+       (delete_cb): New function.
+       (xg_create_frame_widgets): connect delete-event to delete_cb.
+       Call xg_set_widget_bg.  Only set backgrund pixmap for ! HAVE_GTK3
+       (xg_set_background_color): Call xg_set_widget_bg.
+       (xg_set_frame_icon): Call xg_get_pixbuf_from_pix_and_mask.
+       (xg_create_scroll_bar): vadj is a GtkAdjustment for HAVE_GTK3.
+       Only call gtk_range_set_update_policy if ! HAVE_GTK3.
+       (xg_make_tool_item): Only connect xg_tool_bar_item_expose_callback
+       if ! HAVE_GTK3.
+       (update_frame_tool_bar): Call gtk_widget_hide.
+       (xg_initialize): Use GDK_KEY_g.
+
+       * xsmfns.c (gdk_set_sm_client_id): Define to gdk_set_sm_client_id
+       if ! HAVE_GTK3
+       (x_session_initialize): Call gdk_x11_set_sm_client_id.
+
+       * xterm.c (XFillRectangle): Use cairo routines for HAVE_GTK3.
+       (x_term_init): Disable Xinput(2) with GDK_CORE_DEVICE_EVENTS.
+       Load ~/emacs.d/gtkrc only for ! HAVE_GTK3.
+
+2011-03-08  Juanma Barranquero  <lekktu@gmail.com>
+
+       * w32xfns.c (select_palette): Check success of RealizePalette against
+       GDI_ERROR, not zero.
+
+2011-03-07  Ben Key  <bkey76@gmail.com>
+
+       * w32fns.c (FILE_NAME_COMBO_BOX, FILE_NAME_LIST): Define.
+       (file_dialog_callback): Fix locating the window handle of the File Name
+       text field.  After disabling it, set focus on the list control.
+       (Fx_file_dialog): If only_dir_p is non-nil, set the text of the File
+       Name text field to "Current Directory" if it does not already have
+       another value.  (Bug#8181)
+
+2011-03-07  Adrian Robert  <Adrian.B.Robert@gmail.com>
+
+       * nsterm.m (ns_draw_window_cursor): Fix handling of "cursor_width"
+       parameter for hbar cursors.  Based on a patch by Ben Key
+       <bkey76@gmail.com>.
+
 2011-03-06  Chong Yidong  <cyd@stupidchicken.com>
 
        * xdisp.c (redisplay_window): Revert incorrect logic in 2011-03-06
        * xdisp.c (BUILD_GLYPHLESS_GLYPH_STRING): Omit unused local var.
        (produce_glyphless_glyph): Make a pointer "const"
        since it might point to immutable storage.
-       (update_window_cursor):  Now static, since it's not used elsewhere.
+       (update_window_cursor): Now static, since it's not used elsewhere.
        (SKIP_GLYPHS): Removed unused macro.
 
 2011-03-06  Michael Shields  <shields@msrl.com>  (tiny change)
        as per recent filemodestring API change.  Reported by Jonas Öster in
        <http://lists.gnu.org/archive/html/emacs-devel/2011-02/msg01069.html>.
 
-2011-02-23  Ben Key  <bkey76@gmail.com>  (tiny change)
+2011-02-23  Ben Key  <bkey76@gmail.com>
 
        * nsterm.m (ns_draw_window_cursor): Obey the cursor_width argument
        directly, for bar cursors.