On Sat, 8 Jun 2019 13:40:57 +0000 (UTC) Konstantin Belousov
<k...@freebsd.org> wrote:
> Author: kib
> Date: Sat Jun  8 13:40:57 2019
> New Revision: 348798
> URL: https://svnweb.freebsd.org/changeset/base/348798
> 
> Log:
>   amd64 trap.c: Modernize syntax around trap_msg[].
>   
>   Convert the array to use C99 initializers.
>   Make it constant.
>   Replace MAX_TRAP_MSG with nitems().
>   
>   Sponsored by:       The FreeBSD Foundation
>   MFC after:  1 week
> 
> Modified:
>   head/sys/amd64/amd64/trap.c
> 
> Modified: head/sys/amd64/amd64/trap.c
> ==============================================================================
> --- head/sys/amd64/amd64/trap.c       Sat Jun  8 09:34:02 2019        
> (r348797)
> +++ head/sys/amd64/amd64/trap.c       Sat Jun  8 13:40:57 2019        
> (r348798)
> @@ -118,41 +118,41 @@ static bool trap_user_dtrace(struct trapframe *,
>      int (**hook)(struct trapframe *));
>  #endif
>  
> -#define MAX_TRAP_MSG         32
> -static char *trap_msg[] = {
> -     "",                                     /*  0 unused */
> -     "privileged instruction fault",         /*  1 T_PRIVINFLT */
> -     "",                                     /*  2 unused */
> -     "breakpoint instruction fault",         /*  3 T_BPTFLT */
> -     "",                                     /*  4 unused */
> -     "",                                     /*  5 unused */
> -     "arithmetic trap",                      /*  6 T_ARITHTRAP */
> -     "",                                     /*  7 unused */
> -     "",                                     /*  8 unused */
> -     "general protection fault",             /*  9 T_PROTFLT */
> -     "debug exception",                      /* 10 T_TRCTRAP */
> -     "",                                     /* 11 unused */
> -     "page fault",                           /* 12 T_PAGEFLT */
> -     "",                                     /* 13 unused */
> -     "alignment fault",                      /* 14 T_ALIGNFLT */
> -     "",                                     /* 15 unused */
> -     "",                                     /* 16 unused */
> -     "",                                     /* 17 unused */
> -     "integer divide fault",                 /* 18 T_DIVIDE */
> -     "non-maskable interrupt trap",          /* 19 T_NMI */
> -     "overflow trap",                        /* 20 T_OFLOW */
> -     "FPU bounds check fault",               /* 21 T_BOUND */
> -     "FPU device not available",             /* 22 T_DNA */
> -     "double fault",                         /* 23 T_DOUBLEFLT */
> -     "FPU operand fetch fault",              /* 24 T_FPOPFLT */
> -     "invalid TSS fault",                    /* 25 T_TSSFLT */
> -     "segment not present fault",            /* 26 T_SEGNPFLT */
> -     "stack fault",                          /* 27 T_STKFLT */
> -     "machine check trap",                   /* 28 T_MCHK */
> -     "SIMD floating-point exception",        /* 29 T_XMMFLT */
> -     "reserved (unknown) fault",             /* 30 T_RESERVED */
> -     "",                                     /* 31 unused (reserved) */
> -     "DTrace pid return trap",               /* 32 T_DTRACE_RET */
> +static const char UNKNOWN[] = "unknown";
> +static const char *trap_msg[] = {

Maybe the array itself can also be const:
static const char *const trap_msg[]
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to