Hi, With all the latest talk about declarations and prototypes, I got curious and tried building GDB on x86_64-linux with `-Wmissing-declarations -Wmissing-prototypes' added to WARN_CFLAGS, like so: make WARN_CFLAGS="-Wall -Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral -Wno-pointer-sign -Wno-unused -Wno-switch -Wno-char-subscripts -Wmissing-declarations -Wmissing-prototypes" This revealed: 1) several functions that should be static 2) several cases of modules that don't include their own header 3) several cases of _initialize_foo not being declared. 4) a few functions that are public, declared, not never used. I spent a few minutes fixing most of the cases that fit in classes #1, #2 and #3 above. For the record, here's the warning diff: --- warnings_prev.txt 2009-02-17 23:57:18.000000000 +0000 +++ warnings_after.txt 2009-02-18 00:13:10.000000000 +0000 @@ -1,23 +1,5 @@ -../../src/gdb/solib.c:75: warning: no previous prototype for 'set_solib_ops' -../../src/gdb/solib.c:482: warning: no previous prototype for 'solib_read_symbols' -../../src/gdb/solib.c:720: warning: no previous prototype for 'solib_add' -../../src/gdb/solib.c:859: warning: no previous prototype for 'solib_address' -../../src/gdb/solib.c:936: warning: no previous prototype for 'solib_create_inferior_hook' -../../src/gdb/solib.c:959: warning: no previous prototype for 'in_solib_dynsym_resolve_code' -../../src/gdb/solib.c:999: warning: no previous prototype for 'no_shared_libraries' -../../src/gdb/symfile-mem.c:213: warning: no previous prototype for '_initialize_symfile_mem' -../../src/gdb/linux-tdep.c:28: warning: no previous prototype for 'linux_get_siginfo_type' -../../src/gdb/inf-ptrace.c:630: warning: no previous prototype for 'inf_ptrace_target' -../../src/gdb/inf-ptrace.c:766: warning: no previous prototype for 'inf_ptrace_store_registers' -../../src/gdb/inf-ptrace.c:783: warning: no previous prototype for 'inf_ptrace_trad_target' -../../src/gdb/fork-child.c:548: warning: no previous prototype for '_initialize_fork_child' ../../src/gdb/i386-nat.c:239: warning: no previous prototype for 'child_post_startup_inferior' -../../src/gdb/amd64-nat.c:81: warning: no previous prototype for 'amd64_native_gregset_supplies_p' -../../src/gdb/amd64-nat.c:92: warning: no previous prototype for 'amd64_supply_native_gregset' -../../src/gdb/amd64-nat.c:123: warning: no previous prototype for 'amd64_collect_native_gregset' ../../src/gdb/amd64-linux-nat.c:340: warning: no previous prototype for 'ps_get_thread_area' -../../src/gdb/linux-nat.c:4563: warning: no previous prototype for 'linux_nat_terminal_ours' -../../src/gdb/linux-nat.c:4804: warning: no previous prototype for '_initialize_linux_nat' ../../src/gdb/proc-service.c:117: warning: no previous prototype for 'ps_pstop' ../../src/gdb/proc-service.c:126: warning: no previous prototype for 'ps_pcontinue' ../../src/gdb/proc-service.c:136: warning: no previous prototype for 'ps_lstop' @@ -36,66 +18,8 @@ ../../src/gdb/proc-service.c:295: warning: no previous prototype for 'ps_lgetfpregs' ../../src/gdb/proc-service.c:315: warning: no previous prototype for 'ps_lsetfpregs' ../../src/gdb/proc-service.c:334: warning: no previous prototype for 'ps_getpid' -../../src/gdb/proc-service.c:340: warning: no previous prototype for '_initialize_proc_service' -../../src/gdb/linux-thread-db.c:1180: warning: no previous prototype for '_initialize_thread_db' -../../src/gdb/gcore.c:516: warning: no previous prototype for '_initialize_gcore' -../../src/gdb/remote.c:5714: warning: no previous prototype for 'remote_send_printf' -../../src/gdb/cli/cli-logging.c:175: warning: no previous prototype for 'show_logging_command' -../../src/gdb/cli/cli-logging.c:196: warning: no previous prototype for '_initialize_cli_logging' -../../src/gdb/tui/tui-command.c:48: warning: no previous prototype for 'tui_dispatch_ctrl_char' ../../src/gdb/tui/tui-data.c:318: warning: no previous prototype for 'set_gen_win_origin' -../../src/gdb/tui/tui-data.c:489: warning: no previous prototype for 'init_content_element' -../../src/gdb/tui/tui-data.c:537: warning: no previous prototype for 'init_win_info' -../../src/gdb/tui/tui-disasm.c:169: warning: no previous prototype for 'tui_set_disassem_content' -../../src/gdb/tui/tui-disasm.c:272: warning: no previous prototype for 'tui_show_disassem' -../../src/gdb/tui/tui-disasm.c:295: warning: no previous prototype for 'tui_show_disassem_and_update_source' -../../src/gdb/tui/tui-disasm.c:324: warning: no previous prototype for 'tui_get_begin_asm_address' -../../src/gdb/tui/tui-disasm.c:377: warning: no previous prototype for 'tui_vertical_disassem_scroll' -../../src/gdb/tui/tui-interp.c:195: warning: no previous prototype for '_initialize_tui_interp' -../../src/gdb/tui/tui-layout.c:136: warning: no previous prototype for 'tui_set_layout' -../../src/gdb/tui/tui-layout.c:271: warning: no previous prototype for 'tui_add_win_to_layout' -../../src/gdb/tui/tui-layout.c:322: warning: no previous prototype for 'tui_default_win_height' -../../src/gdb/tui/tui-layout.c:362: warning: no previous prototype for 'tui_default_win_viewport_height' -../../src/gdb/tui/tui-layout.c:380: warning: no previous prototype for '_initialize_tui_layout' -../../src/gdb/tui/tui-regs.c:80: warning: no previous prototype for 'tui_last_regs_line_no' -../../src/gdb/tui/tui-regs.c:100: warning: no previous prototype for 'tui_line_from_reg_element_no' -../../src/gdb/tui/tui-regs.c:126: warning: no previous prototype for 'tui_first_reg_element_no_inline' -../../src/gdb/tui/tui-regs.c:141: warning: no previous prototype for 'tui_last_reg_element_no_in_line' -../../src/gdb/tui/tui-regs.c:154: warning: no previous prototype for 'tui_show_registers' -../../src/gdb/tui/tui-regs.c:320: warning: no previous prototype for 'tui_display_registers_from' -../../src/gdb/tui/tui-regs.c:422: warning: no previous prototype for 'tui_display_reg_element_at_line' -../../src/gdb/tui/tui-regs.c:457: warning: no previous prototype for 'tui_display_registers_from_line' -../../src/gdb/tui/tui-regs.c:498: warning: no previous prototype for 'tui_check_register_values' -../../src/gdb/tui/tui-regs.c:609: warning: no previous prototype for '_initialize_tui_regs' -../../src/gdb/tui/tui-stack.c:416: warning: no previous prototype for '_initialize_tui_stack' -../../src/gdb/tui/tui-win.c:275: warning: no previous prototype for 'tui_update_variables' -../../src/gdb/tui/tui-win.c:341: warning: no previous prototype for 'tui_get_cmd_list' -../../src/gdb/tui/tui-win.c:353: warning: no previous prototype for '_initialize_tui_win' -../../src/gdb/tui/tui-win.c:462: warning: no previous prototype for 'tui_update_gdb_sizes' -../../src/gdb/tui/tui-win.c:478: warning: no previous prototype for 'tui_set_win_focus_to' -../../src/gdb/tui/tui-win.c:496: warning: no previous prototype for 'tui_scroll_forward' -../../src/gdb/tui/tui-win.c:521: warning: no previous prototype for 'tui_scroll_backward' -../../src/gdb/tui/tui-win.c:547: warning: no previous prototype for 'tui_scroll_left' -../../src/gdb/tui/tui-win.c:569: warning: no previous prototype for 'tui_scroll_right' -../../src/gdb/tui/tui-win.c:593: warning: no previous prototype for 'tui_scroll' -../../src/gdb/tui/tui-win.c:616: warning: no previous prototype for 'tui_refresh_all_win' -../../src/gdb/tui/tui-win.c:651: warning: no previous prototype for 'tui_resize_all' -../../src/gdb/tui/tui-win.c:812: warning: no previous prototype for 'tui_sigwinch_handler' -../../src/gdb/tui/tui-win.c:821: warning: no previous prototype for 'tui_initialize_win' -../../src/gdb/tui/tui-windata.c:48: warning: no previous prototype for 'tui_first_data_item_displayed' -../../src/gdb/tui/tui-windata.c:73: warning: no previous prototype for 'tui_first_data_element_no_in_line' -../../src/gdb/tui/tui-windata.c:90: warning: no previous prototype for 'tui_delete_data_content_windows' -../../src/gdb/tui/tui-windata.c:107: warning: no previous prototype for 'tui_erase_data_content' -../../src/gdb/tui/tui-windata.c:132: warning: no previous prototype for 'tui_display_all_data' -../../src/gdb/tui/tui-windata.c:156: warning: no previous prototype for 'tui_display_data_from_line' -../../src/gdb/tui/tui-windata.c:196: warning: no previous prototype for 'tui_display_data_from' -../../src/gdb/tui/tui-windata.c:218: warning: no previous prototype for 'tui_refresh_data_win' -../../src/gdb/tui/tui-windata.c:234: warning: no previous prototype for 'tui_check_data_values' -../../src/gdb/tui/tui-windata.c:271: warning: no previous prototype for 'tui_vertical_data_scroll' -../../src/gdb/tui/tui-wingeneral.c:83: warning: no previous prototype for 'box_win' -../../src/gdb/python/python.c:360: warning: no previous prototype for '_initialize_python' -cp-name-parser.y:1979: warning: no previous prototype for 'cp_comp_to_string' -cp-name-parser.y:2016: warning: no previous prototype for 'cp_demangled_name_to_comp' +../../src/gdb/tui/tui-regs.c:142: warning: no previous prototype for 'tui_last_reg_element_no_in_line' In file included from ada-exp.y:767: ada-lex.c:2273: warning: no previous prototype for 'yyget_lineno' ada-lex.c:2282: warning: no previous prototype for 'yyget_in' @@ -109,55 +33,10 @@ ada-lex.c:2338: warning: no previous pro ada-lex.c:2343: warning: no previous prototype for 'yyset_debug' ada-lex.c:2377: warning: no previous prototype for 'yylex_destroy' ../../src/gdb/ada-lex.l:288: warning: no previous prototype for 'lexer_init' -ada-exp.y:1525: warning: no previous prototype for '_initialize_ada_exp' -../../src/gdb/addrmap.c:538: warning: no previous prototype for '_initialize_addrmap' -../../src/gdb/auxv.c:85: warning: no previous prototype for 'default_auxv_parse' -../../src/gdb/bfd-target.c:75: warning: no previous prototype for 'target_bfd_xfer_partial' -../../src/gdb/bfd-target.c:112: warning: no previous prototype for 'target_bfd_xclose' -../../src/gdb/breakpoint.c:5179: warning: no previous prototype for 'expand_line_sal_maybe' -../../src/gdb/regcache.c:452: warning: no previous prototype for 'regcache_observer_target_changed' -../../src/gdb/eval.c:419: warning: no previous prototype for 'value_f90_subarray' -../../src/gdb/symtab.c:777: warning: no previous prototype for 'find_pc_sect_psymtab_closer' -../../src/gdb/symfile.c:485: warning: no previous prototype for 'place_section' -../../src/gdb/infrun.c:1665: warning: no previous prototype for 'infrun_thread_stop_requested' ../../src/gdb/infrun.c:1979: warning: no previous prototype for 'nullify_last_target_wait_ptid' -../../src/gdb/infrun.c:4853: warning: no previous prototype for 'siginfo_make_value' -../../src/gdb/exceptions.c:362: warning: no previous prototype for 'print_any_exception' -../../src/gdb/inf-child.c:163: warning: no previous prototype for 'inf_child_target' -../../src/gdb/target.c:375: warning: no previous prototype for 'default_get_ada_task_ptid' -../../src/gdb/target.c:2212: warning: no previous prototype for 'find_default_can_async_p' -../../src/gdb/target.c:2227: warning: no previous prototype for 'find_default_is_async_p' -../../src/gdb/target.c:2242: warning: no previous prototype for 'find_default_supports_non_stop' -../../src/gdb/target.c:2528: warning: no previous prototype for 'dummy_pid_to_str' -../../src/gdb/findcmd.c:316: warning: no previous prototype for '_initialize_mem_search' -../../src/gdb/reverse.c:108: warning: no previous prototype for '_initialize_reverse' ../../src/gdb/observer.c:185: warning: no previous prototype for 'observer_test_first_notification_function' ../../src/gdb/observer.c:191: warning: no previous prototype for 'observer_test_second_notification_function' ../../src/gdb/observer.c:197: warning: no previous prototype for 'observer_test_third_notification_function' -../../src/gdb/stabsread.c:4269: warning: no previous prototype for 'cleanup_undefined_types_noname' -../../src/gdb/stabsread.c:4304: warning: no previous prototype for 'cleanup_undefined_types_1' -../../src/gdb/ada-lang.c:1206: warning: no previous prototype for 'ada_la_decode' -../../src/gdb/ada-lang.c:1219: warning: no previous prototype for 'ada_match_name' -../../src/gdb/ada-lang.c:1240: warning: no previous prototype for 'ada_suppress_symbol_printing' -../../src/gdb/ada-lang.c:1575: warning: no previous prototype for 'ada_is_array_type' -../../src/gdb/ada-lang.c:2321: warning: no previous prototype for 'ada_value_ptr_subscript' -../../src/gdb/ada-lang.c:2579: warning: no previous prototype for 'ada_array_length' -../../src/gdb/ada-lang.c:7537: warning: no previous prototype for 'ada_to_static_fixed_value' -../../src/gdb/ada-lang.c:11072: warning: no previous prototype for '_initialize_ada_language' -../../src/gdb/ada-tasks.c:159: warning: no previous prototype for 'ada_get_task_number' -../../src/gdb/ada-tasks.c:204: warning: no previous prototype for 'ada_get_environment_task' -../../src/gdb/ada-tasks.c:947: warning: no previous prototype for 'ada_task_list_changed' -../../src/gdb/ada-tasks.c:965: warning: no previous prototype for 'ada_new_objfile_observer' -../../src/gdb/ada-tasks.c:978: warning: no previous prototype for '_initialize_tasks' -../../src/gdb/jv-lang.c:1060: warning: no previous prototype for 'java_language_arch_info' ../../src/gdb/ada-typeprint.c:125: warning: no previous prototype for 'ada_typedef_print' -../../src/gdb/m2-typeprint.c:376: warning: no previous prototype for 'm2_get_discrete_bounds' -../../src/gdb/cp-valprint.c:508: warning: no previous prototype for 'cp_find_class_member' -../../src/gdb/utils.c:3546: warning: no previous prototype for '_initialize_utils' -../../src/gdb/frame.c:1150: warning: no previous prototype for 'frame_observer_target_changed' -../../src/gdb/gnu-v3-abi.c:488: warning: no previous prototype for 'gnuv3_find_method_in' -../../src/gdb/target-descriptions.c:1130: warning: no previous prototype for '_initialize_target_descriptions' -../../src/gdb/inferior.c:235: warning: no previous prototype for 'valid_gdb_inferior_id' -../../src/gdb/osdata.c:283: warning: no previous prototype for 'info_osdata_command' The remaining warnings after the patch is installed are: ../../src/gdb/i386-nat.c:239: warning: no previous prototype for 'child_post_startup_inferior' ../../src/gdb/amd64-linux-nat.c:340: warning: no previous prototype for 'ps_get_thread_area' ../../src/gdb/proc-service.c:117: warning: no previous prototype for 'ps_pstop' ../../src/gdb/proc-service.c:126: warning: no previous prototype for 'ps_pcontinue' ../../src/gdb/proc-service.c:136: warning: no previous prototype for 'ps_lstop' ../../src/gdb/proc-service.c:146: warning: no previous prototype for 'ps_lcontinue' ../../src/gdb/proc-service.c:158: warning: no previous prototype for 'ps_lgetxregsize' ../../src/gdb/proc-service.c:168: warning: no previous prototype for 'ps_lgetxregs' ../../src/gdb/proc-service.c:178: warning: no previous prototype for 'ps_lsetxregs' ../../src/gdb/proc-service.c:187: warning: no previous prototype for 'ps_plog' ../../src/gdb/proc-service.c:201: warning: no previous prototype for 'ps_pglobal_lookup' ../../src/gdb/proc-service.c:219: warning: no previous prototype for 'ps_pdread' ../../src/gdb/proc-service.c:228: warning: no previous prototype for 'ps_pdwrite' ../../src/gdb/proc-service.c:238: warning: no previous prototype for 'ps_ptread' ../../src/gdb/proc-service.c:247: warning: no previous prototype for 'ps_ptwrite' ../../src/gdb/proc-service.c:256: warning: no previous prototype for 'ps_lgetregs' ../../src/gdb/proc-service.c:275: warning: no previous prototype for 'ps_lsetregs' ../../src/gdb/proc-service.c:295: warning: no previous prototype for 'ps_lgetfpregs' ../../src/gdb/proc-service.c:315: warning: no previous prototype for 'ps_lsetfpregs' ../../src/gdb/proc-service.c:334: warning: no previous prototype for 'ps_getpid' ../../src/gdb/tui/tui-data.c:318: warning: no previous prototype for 'set_gen_win_origin' ../../src/gdb/tui/tui-regs.c:142: warning: no previous prototype for 'tui_last_reg_element_no_in_line' In file included from ada-exp.y:767: ada-lex.c:2273: warning: no previous prototype for 'yyget_lineno' ada-lex.c:2282: warning: no previous prototype for 'yyget_in' ada-lex.c:2290: warning: no previous prototype for 'yyget_out' ada-lex.c:2298: warning: no previous prototype for 'yyget_leng' ada-lex.c:2307: warning: no previous prototype for 'yyget_text' ada-lex.c:2316: warning: no previous prototype for 'yyset_lineno' ada-lex.c:2328: warning: no previous prototype for 'yyset_in' ada-lex.c:2333: warning: no previous prototype for 'yyset_out' ada-lex.c:2338: warning: no previous prototype for 'yyget_debug' ada-lex.c:2343: warning: no previous prototype for 'yyset_debug' ada-lex.c:2377: warning: no previous prototype for 'yylex_destroy' ../../src/gdb/ada-lex.l:288: warning: no previous prototype for 'lexer_init' ../../src/gdb/infrun.c:1979: warning: no previous prototype for 'nullify_last_target_wait_ptid' ../../src/gdb/observer.c:185: warning: no previous prototype for 'observer_test_first_notification_function' ../../src/gdb/observer.c:191: warning: no previous prototype for 'observer_test_second_notification_function' ../../src/gdb/observer.c:197: warning: no previous prototype for 'observer_test_third_notification_function' ../../src/gdb/ada-typeprint.c:125: warning: no previous prototype for 'ada_typedef_print' E.g., notice that a few functions here are really unnused and should probably either be deleted, or there's a bug hiding in there: e.g., i386-nat.c:child_post_startup_inferior or ada-typeprint.c:ada_typedef_print. Apart from other native code that I didn't cover with my small testing, we're not far off from being able to switch these warnings on. I've also tried adding "-Wmissing-prototypes", but it shows up a few more issues than I have energy at the moment to look at. I'm assuming this the patch only contains obvious content. -- Pedro Alves