bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Fix ddb warnings introduced with -Wstrict-prototypes


From: Samuel Thibault
Subject: Re: [PATCH] Fix ddb warnings introduced with -Wstrict-prototypes
Date: Thu, 5 Jan 2023 01:01:56 +0100
User-agent: NeoMutt/20170609 (1.8.3)

Applied, thanks!

Flavio Cruz, le mer. 04 janv. 2023 00:30:28 -0500, a ecrit:
> Changed some ddb command functions to have the expected signature but
> not all of them due to the being difficult to inter-dependency between
> header files (for those just used cast).
> ---
>  ddb/db_break.c     | 14 ++++++++++---
>  ddb/db_break.h     | 12 +++++++++--
>  ddb/db_command.c   | 52 +++++++++++++++++++++++++---------------------
>  ddb/db_command.h   |  4 +++-
>  ddb/db_cond.c      |  6 +++++-
>  ddb/db_cond.h      |  6 +++++-
>  ddb/db_examine.c   |  6 +++++-
>  ddb/db_examine.h   |  6 +++++-
>  ddb/db_input.c     |  8 ++-----
>  ddb/db_macro.c     | 18 +++++++++++++---
>  ddb/db_macro.h     | 22 +++++++++++++++-----
>  ddb/db_print.c     |  2 +-
>  ddb/db_sym.c       |  2 +-
>  ddb/db_sym.h       |  2 +-
>  ddb/db_variables.c |  2 +-
>  ddb/db_watch.c     |  6 +++++-
>  ddb/db_watch.h     |  6 +++++-
>  i386/i386/trap.c   |  3 +--
>  kern/lock.h        |  4 +++-
>  19 files changed, 124 insertions(+), 57 deletions(-)
> 
> diff --git a/ddb/db_break.c b/ddb/db_break.c
> index 0456f5f9..780c1ccc 100644
> --- a/ddb/db_break.c
> +++ b/ddb/db_break.c
> @@ -62,7 +62,7 @@ static boolean_t                    db_thread_break_init = 
> FALSE;
>  static int                           db_breakpoint_number = 0;
>  
>  static db_breakpoint_t
> -db_breakpoint_alloc()
> +db_breakpoint_alloc(void)
>  {
>       db_breakpoint_t bkpt;
>  
> @@ -597,7 +597,11 @@ db_list_breakpoints(void)
>  /* Delete breakpoint */
>  /*ARGSUSED*/
>  void
> -db_delete_cmd(void)
> +db_delete_cmd(
> +     db_expr_t,
> +     boolean_t,
> +     db_expr_t,
> +     const char *)
>  {
>       int n;
>       thread_t thread;
> @@ -730,7 +734,11 @@ db_breakpoint_cmd(
>  
>  /* list breakpoints */
>  void
> -db_listbreak_cmd(void)
> +db_listbreak_cmd(
> +     db_expr_t,
> +     boolean_t,
> +     db_expr_t,
> +     const char *)
>  {
>       db_list_breakpoints();
>  }
> diff --git a/ddb/db_break.h b/ddb/db_break.h
> index 610af2f8..9f0ee95b 100644
> --- a/ddb/db_break.h
> +++ b/ddb/db_break.h
> @@ -88,9 +88,17 @@ extern db_breakpoint_t  db_set_breakpoint(const task_t 
> task, db_addr_t addr,
>                                         int count, const thread_t thread, 
>                                         boolean_t task_bpt);
>  
> -void db_listbreak_cmd(void);
> +void db_listbreak_cmd(
> +     db_expr_t       addr,
> +     boolean_t       have_addr,
> +     db_expr_t       count,
> +     const char      *modif);
>  
> -void db_delete_cmd(void);
> +void db_delete_cmd(
> +     db_expr_t       addr,
> +     boolean_t       have_addr,
> +     db_expr_t       count,
> +     const char *    modif);
>  
>  void db_breakpoint_cmd(
>       db_expr_t       addr,
> diff --git a/ddb/db_command.c b/ddb/db_command.c
> index c9e4f6ae..d21386e6 100644
> --- a/ddb/db_command.c
> +++ b/ddb/db_command.c
> @@ -156,10 +156,10 @@ db_cmd_list(const struct db_command *table)
>  
>  static void
>  db_command(
> -     struct db_command       **last_cmdp,    /* IN_OUT */
> +     const struct db_command **last_cmdp,    /* IN_OUT */
>       struct db_command       *cmd_table)
>  {
> -     struct db_command       *cmd;
> +     const struct db_command *cmd = NULL;
>       int             t;
>       char            modif[TOK_STRING_SIZE];
>       db_expr_t       addr, count;
> @@ -266,7 +266,7 @@ db_command(
>           }
>       }
>       *last_cmdp = cmd;
> -     if (cmd != 0) {
> +     if (cmd != NULL) {
>           /*
>            * Execute the command.
>            */
> @@ -296,7 +296,7 @@ db_command(
>  
>  static void
>  db_command_list(
> -     struct db_command       **last_cmdp,    /* IN_OUT */
> +     const struct db_command **last_cmdp,    /* IN_OUT */
>       struct db_command       *cmd_table)
>  {
>       do {
> @@ -308,29 +308,29 @@ db_command_list(
>  struct db_command db_show_all_cmds[] = {
>       { "tasks",      db_show_all_tasks,      0,      0 },
>       { "threads",    db_show_all_threads,    0,      0 },
> -     { "slocks",     db_show_all_slocks,     0,      0 },
> +     { "slocks",     (db_command_fun_t)db_show_all_slocks,   0,      0 },
>       { (char *)0 }
>  };
>  
>  struct db_command db_show_cmds[] = {
>       { "all",        0,                      0,      db_show_all_cmds },
> -     { "registers",  db_show_regs,           0,      0 },
> +     { "registers",  (db_command_fun_t)db_show_regs,         0,      0 },
>       { "breaks",     db_listbreak_cmd,       0,      0 },
>       { "watches",    db_listwatch_cmd,       0,      0 },
>       { "thread",     db_show_one_thread,     0,      0 },
>       { "task",       db_show_one_task,       0,      0 },
>       { "macro",      db_show_macro,          CS_OWN, 0 },
>       { "map",        vm_map_print,           0,      0 },
> -     { "object",     vm_object_print,        0,      0 },
> -     { "page",       vm_page_print,          0,      0 },
> -     { "copy",       vm_map_copy_print,      0,      0 },
> -     { "port",       ipc_port_print,         0,      0 },
> -     { "pset",       ipc_pset_print,         0,      0 },
> -     { "kmsg",       ipc_kmsg_print,         0,      0 },
> -     { "msg",        ipc_msg_print,          0,      0 },
> +     { "object",     (db_command_fun_t)vm_object_print,      0,      0 },
> +     { "page",       (db_command_fun_t)vm_page_print,                0,      
> 0 },
> +     { "copy",       (db_command_fun_t)vm_map_copy_print,    0,      0 },
> +     { "port",       (db_command_fun_t)ipc_port_print,               0,      
> 0 },
> +     { "pset",       (db_command_fun_t)ipc_pset_print,               0,      
> 0 },
> +     { "kmsg",       (db_command_fun_t)ipc_kmsg_print,               0,      
> 0 },
> +     { "msg",        (db_command_fun_t)ipc_msg_print,                0,      
> 0 },
>       { "ipc_port",   db_show_port_id,        0,      0 },
> -     { "slabinfo",   db_show_slab_info,      0,      0 },
> -     { "vmstat",     db_show_vmstat,         0,      0 },
> +     { "slabinfo",   (db_command_fun_t)db_show_slab_info,    0,      0 },
> +     { "vmstat",     (db_command_fun_t)db_show_vmstat,               0,      
> 0 },
>       { (char *)0, }
>  };
>  
> @@ -356,13 +356,13 @@ struct db_command db_command_table[] = {
>    /* this must be the first entry, if it exists */
>       { "machine",    0,                      0,              0},
>  #endif
> -     { "print",      db_print_cmd,           CS_OWN,         0 },
> +     { "print",      (db_command_fun_t)db_print_cmd,         CS_OWN,         
> 0 },
>       { "examine",    db_examine_cmd,         CS_MORE|CS_SET_DOT, 0 },
>       { "x",          db_examine_cmd,         CS_MORE|CS_SET_DOT, 0 },
>       { "xf",         db_examine_forward,     CS_SET_DOT,     0 },
>       { "xb",         db_examine_backward,    CS_SET_DOT,     0 },
>       { "search",     db_search_cmd,          CS_OWN|CS_SET_DOT, 0 },
> -     { "set",        db_set_cmd,             CS_OWN,         0 },
> +     { "set",        (db_command_fun_t)db_set_cmd,           CS_OWN,         
> 0 },
>       { "write",      db_write_cmd,           CS_MORE|CS_SET_DOT, 0 },
>       { "w",          db_write_cmd,           CS_MORE|CS_SET_DOT, 0 },
>       { "delete",     db_delete_cmd,          CS_OWN,         0 },
> @@ -379,14 +379,14 @@ struct db_command db_command_table[] = {
>       { "match",      db_trace_until_matching_cmd,0,          0 },
>       { "trace",      db_stack_trace_cmd,     0,              0 },
>       { "cond",       db_cond_cmd,            CS_OWN,         0 },
> -     { "call",       db_fncall,              CS_OWN,         0 },
> +     { "call",       (db_command_fun_t)db_fncall,            CS_OWN,         
> 0 },
>       { "macro",      db_def_macro_cmd,       CS_OWN,         0 },
>       { "dmacro",     db_del_macro_cmd,       CS_OWN,         0 },
>       { "show",       0,                      0,      db_show_cmds },
>       { "debug",      0,                      0,      db_debug_cmds },
> -     { "reset",      db_reset_cpu,           0,              0 },
> -     { "reboot",     db_reset_cpu,           0,              0 },
> -     { "halt",       db_halt_cpu,            0,              0 },
> +     { "reset",      (db_command_fun_t)db_reset_cpu,         0,              
> 0 },
> +     { "reboot",     (db_command_fun_t)db_reset_cpu,         0,              
> 0 },
> +     { "halt",       (db_command_fun_t)db_halt_cpu,          0,              
> 0 },
>       { (char *)0, }
>  };
>  
> @@ -403,7 +403,7 @@ void db_machine_commands_install(struct db_command *ptr)
>  #endif /* DB_MACHINE_COMMANDS */
>  
>  
> -struct db_command    *db_last_command = 0;
> +const struct db_command      *db_last_command = 0;
>  
>  void
>  db_help_cmd(void)
> @@ -500,7 +500,11 @@ db_fncall(void)
>       db_expr_t       args[MAXARGS];
>       int             nargs = 0;
>       db_expr_t       retval;
> -     db_expr_t       (*func)();
> +     typedef db_expr_t(*function_t)(db_expr_t, db_expr_t, db_expr_t,
> +                     db_expr_t, db_expr_t, db_expr_t,
> +                     db_expr_t, db_expr_t, db_expr_t,
> +                     db_expr_t);
> +     function_t func;
>       int             t;
>  
>       if (!db_expression(&fn_addr)) {
> @@ -508,7 +512,7 @@ db_fncall(void)
>           db_flush_lex();
>           return;
>       }
> -     func = (db_expr_t (*) ()) fn_addr;
> +     func = (function_t) fn_addr;
>  
>       t = db_read_token();
>       if (t == tLPAREN) {
> diff --git a/ddb/db_command.h b/ddb/db_command.h
> index 4208bda8..73690a48 100644
> --- a/ddb/db_command.h
> +++ b/ddb/db_command.h
> @@ -53,12 +53,14 @@ extern db_addr_t  db_next;        /* next address to be 
> examined
>                                          or written */
>  extern jmp_buf_t *   db_recover;     /* error recovery */
>  
> +typedef void (*db_command_fun_t)(db_expr_t, boolean_t, db_expr_t, const char 
> *);
> +
>  /*
>   * Command table
>   */
>  struct db_command {
>       char *  name;           /* command name */
> -     void    (*fcn)();       /* function to call */
> +     db_command_fun_t fcn;   /* function to call */
>       int     flag;           /* extra info: */
>  #define      CS_OWN          0x1         /* non-standard syntax */
>  #define      CS_MORE         0x2         /* standard syntax, but may have 
> other
> diff --git a/ddb/db_cond.c b/ddb/db_cond.c
> index 31e1d241..8f0c8b30 100644
> --- a/ddb/db_cond.c
> +++ b/ddb/db_cond.c
> @@ -121,7 +121,11 @@ db_cond_print(bkpt)
>  }
>  
>  void
> -db_cond_cmd(void)
> +db_cond_cmd(
> +     db_expr_t,
> +     boolean_t,
> +     db_expr_t,
> +     const char *)
>  {
>       int c;
>       struct db_cond *cp;
> diff --git a/ddb/db_cond.h b/ddb/db_cond.h
> index 6b9c3a5b..c867c6ee 100644
> --- a/ddb/db_cond.h
> +++ b/ddb/db_cond.h
> @@ -30,6 +30,10 @@ extern boolean_t db_cond_check (db_thread_breakpoint_t 
> bkpt);
>  
>  extern void db_cond_print (db_thread_breakpoint_t bkpt);
>  
> -extern void db_cond_cmd (void);
> +extern void db_cond_cmd (
> +     db_expr_t       addr,
> +     boolean_t       have_addr,
> +     db_expr_t       count,
> +     const char *    modif);
>  
>  #endif /* _DDB_DB_COND_H_ */
> diff --git a/ddb/db_examine.c b/ddb/db_examine.c
> index 75bc1834..62a887ad 100644
> --- a/ddb/db_examine.c
> +++ b/ddb/db_examine.c
> @@ -346,7 +346,11 @@ db_strcpy(char *dst, const char *src)
>   * Syntax: search [/bhl] addr value [mask] [,count] [thread]
>   */
>  void
> -db_search_cmd(void)
> +db_search_cmd(
> +     db_expr_t,
> +     boolean_t,
> +     db_expr_t,
> +     const char *)
>  {
>       int             t;
>       db_addr_t       addr;
> diff --git a/ddb/db_examine.h b/ddb/db_examine.h
> index df578a02..56a1a346 100644
> --- a/ddb/db_examine.h
> +++ b/ddb/db_examine.h
> @@ -63,7 +63,11 @@ int db_xcdump(
>  
>  void db_print_cmd(void);
>  
> -void db_search_cmd(void);
> +void db_search_cmd(
> +     db_expr_t       addr,
> +     boolean_t       have_addr,
> +     db_expr_t       count,
> +     const char *    modif);
>  
>  void db_search(
>       db_addr_t       addr,
> diff --git a/ddb/db_input.c b/ddb/db_input.c
> index a564025e..357474b7 100644
> --- a/ddb/db_input.c
> +++ b/ddb/db_input.c
> @@ -68,18 +68,14 @@ char *  db_history_prev = (char *) 0;     /* start of 
> previous line */
>  #define      BACKUP          '\b'
>  
>  static void
> -db_putstring(s, count)
> -     const char      *s;
> -     int             count;
> +db_putstring(const char *s, int count)
>  {
>       while (--count >= 0)
>           cnputc(*s++);
>  }
>  
>  static void
> -db_putnchars(c, count)
> -     int     c;
> -     int     count;
> +db_putnchars(int c, int count)
>  {
>       while (--count >= 0)
>           cnputc(c);
> diff --git a/ddb/db_macro.c b/ddb/db_macro.c
> index 2a28a442..d417abe1 100644
> --- a/ddb/db_macro.c
> +++ b/ddb/db_macro.c
> @@ -72,7 +72,11 @@ db_lookup_macro(const char *name)
>  }
>  
>  void
> -db_def_macro_cmd(void)
> +db_def_macro_cmd(
> +     db_expr_t,
> +     boolean_t,
> +     db_expr_t,
> +     const char *)
>  {
>       char *p;
>       int c;
> @@ -103,7 +107,11 @@ db_def_macro_cmd(void)
>  }
>  
>  void
> -db_del_macro_cmd(void)
> +db_del_macro_cmd(
> +     db_expr_t,
> +     boolean_t,
> +     db_expr_t,
> +     const char *)
>  {
>       struct db_user_macro *mp;
>  
> @@ -119,7 +127,11 @@ db_del_macro_cmd(void)
>  }
>  
>  void
> -db_show_macro(void)
> +db_show_macro(
> +     db_expr_t,
> +     boolean_t,
> +     db_expr_t,
> +     const char *)
>  {
>       struct db_user_macro *mp;
>       int  t;
> diff --git a/ddb/db_macro.h b/ddb/db_macro.h
> index 2c0a599b..91882470 100644
> --- a/ddb/db_macro.h
> +++ b/ddb/db_macro.h
> @@ -24,11 +24,23 @@
>  #include <sys/types.h>
>  #include <ddb/db_variables.h>
>  
> -extern void db_def_macro_cmd (void);
> -
> -extern void db_del_macro_cmd (void);
> -
> -extern void db_show_macro (void);
> +extern void db_def_macro_cmd (
> +     db_expr_t       addr,
> +     boolean_t       have_addr,
> +     db_expr_t       count,
> +     const char *    modif);
> +
> +extern void db_del_macro_cmd (
> +     db_expr_t       addr,
> +     boolean_t       have_addr,
> +     db_expr_t       count,
> +     const char *    modif);
> +
> +extern void db_show_macro (
> +     db_expr_t       addr,
> +     boolean_t       have_addr,
> +     db_expr_t       count,
> +     const char *    modif);
>  
>  extern int db_exec_macro (const char *name);
>  
> diff --git a/ddb/db_print.c b/ddb/db_print.c
> index 0781b836..6d4c59d3 100644
> --- a/ddb/db_print.c
> +++ b/ddb/db_print.c
> @@ -467,7 +467,7 @@ db_show_one_task(
>  }
>  
>  static int
> -db_port_iterate(const thread_t thread, void (*func)())
> +db_port_iterate(const thread_t thread, void (*func)(int, const ipc_port_t, 
> unsigned, int))
>  {
>       ipc_entry_t entry;
>       int n = 0;
> diff --git a/ddb/db_sym.c b/ddb/db_sym.c
> index 585e0ea7..d205ff74 100644
> --- a/ddb/db_sym.c
> +++ b/ddb/db_sym.c
> @@ -192,7 +192,7 @@ db_lookup(char *symstr)
>   */
>  db_sym_t
>  db_sym_parse_and_lookup(
> -     db_sym_t        (*func) (db_symtab_t *, char*, char*, int),
> +     db_sym_t        (*func) (db_symtab_t *, const char*, const char*, int),
>       db_symtab_t     *symtab,
>       char            *symstr)
>  {
> diff --git a/ddb/db_sym.h b/ddb/db_sym.h
> index da4a0626..8b586996 100644
> --- a/ddb/db_sym.h
> +++ b/ddb/db_sym.h
> @@ -263,7 +263,7 @@ db_search_in_task_symbol(
>  
>  extern db_sym_t
>  db_sym_parse_and_lookup(
> -     db_sym_t        (*func) (db_symtab_t *, char*, char*, int),
> +     db_sym_t        (*func) (db_symtab_t *, const char*, const char*, int),
>       db_symtab_t     *symtab,
>       char            *symstr);
>  
> diff --git a/ddb/db_variables.c b/ddb/db_variables.c
> index af982e12..3e20e689 100644
> --- a/ddb/db_variables.c
> +++ b/ddb/db_variables.c
> @@ -183,7 +183,7 @@ db_read_write_variable(
>       int                     rw_flag,
>       db_var_aux_param_t      ap)
>  {
> -     void    (*func)() = vp->fcn;
> +     void    (*func)(struct db_variable *, db_expr_t *, int, 
> db_var_aux_param_t) = vp->fcn;
>       struct  db_var_aux_param aux_param;
>  
>       if (ap == 0) {
> diff --git a/ddb/db_watch.c b/ddb/db_watch.c
> index 6ad820e7..5db3f300 100644
> --- a/ddb/db_watch.c
> +++ b/ddb/db_watch.c
> @@ -248,7 +248,11 @@ db_watchpoint_cmd(
>  
>  /* list watchpoints */
>  void
> -db_listwatch_cmd(void)
> +db_listwatch_cmd(
> +     db_expr_t,
> +     boolean_t,
> +     db_expr_t,
> +     const char *)
>  {
>       db_list_watchpoints();
>  }
> diff --git a/ddb/db_watch.h b/ddb/db_watch.h
> index 7ef1a207..86f07fb1 100644
> --- a/ddb/db_watch.h
> +++ b/ddb/db_watch.h
> @@ -57,7 +57,11 @@ extern void db_set_watchpoint(const task_t task, db_addr_t 
> addr, vm_size_t size)
>  extern void db_delete_watchpoint(const task_t task, db_addr_t addr);
>  extern void db_list_watchpoints(void);
>  
> -void db_listwatch_cmd(void);
> +void db_listwatch_cmd(
> +     db_expr_t       addr,
> +     boolean_t       have_addr,
> +     db_expr_t       count,
> +     const char *    modif);
>  
>  void db_deletewatch_cmd(
>       db_expr_t       addr,
> diff --git a/i386/i386/trap.c b/i386/i386/trap.c
> index 6e446ab0..1128145e 100644
> --- a/i386/i386/trap.c
> +++ b/i386/i386/trap.c
> @@ -58,6 +58,7 @@
>  #include <kern/exception.h>
>  
>  #if MACH_KDB
> +#include <ddb/db_break.h>
>  #include <ddb/db_run.h>
>  #include <ddb/db_watch.h>
>  #endif
> @@ -416,8 +417,6 @@ int user_trap(struct i386_saved_state *regs)
>  #endif       /* MACH_TTD */
>  #if  MACH_KDB
>           {
> -             boolean_t db_find_breakpoint_here();
> -
>               if (db_find_breakpoint_here(
>                       (current_thread())? current_thread()->task: TASK_NULL,
>                       regs->eip - 1)) {
> diff --git a/kern/lock.h b/kern/lock.h
> index 2781a48a..2548409d 100644
> --- a/kern/lock.h
> +++ b/kern/lock.h
> @@ -217,6 +217,8 @@ extern void               lock_clear_recursive(lock_t);
>  #endif       /* MACH_LDEBUG */
>  #define have_lock(l)         (have_read_lock(l) || have_write_lock(l))
>  
> -void db_show_all_slocks(void);
> +#if  MACH_KDB
> +extern void db_show_all_slocks(void);
> +#endif       /* MACH_KDB */
>  
>  #endif       /* _KERN_LOCK_H_ */
> -- 
> 2.37.2
> 
> 

-- 
Samuel
---
Pour une évaluation indépendante, transparente et rigoureuse !
Je soutiens la Commission d'Évaluation de l'Inria.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]