raidframe: use existing routines to print an error and panic.

fixes the i386 ALL build with clang which complained about the
format string not being a string literal, and lets us get rid of
rf_panicbuf.

note: kern_assert is not KASSERT. it should panic as long as the
string is not NULL.

No functional change intended.
This commit is contained in:
maya 2016-12-10 23:03:27 +00:00
parent 219b8dae14
commit 7126f38657
2 changed files with 7 additions and 14 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_driver.c,v 1.132 2015/12/26 00:58:45 pgoyette Exp $ */ /* $NetBSD: rf_driver.c,v 1.133 2016/12/10 23:03:27 maya Exp $ */
/*- /*-
* Copyright (c) 1999 The NetBSD Foundation, Inc. * Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
@ -66,7 +66,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.132 2015/12/26 00:58:45 pgoyette Exp $"); __KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.133 2016/12/10 23:03:27 maya Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "opt_raid_diagnostic.h" #include "opt_raid_diagnostic.h"
@ -121,9 +121,6 @@ __KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.132 2015/12/26 00:58:45 pgoyette Exp
#define RF_MAX_FREE_RAD 128 #define RF_MAX_FREE_RAD 128
#define RF_MIN_FREE_RAD 32 #define RF_MIN_FREE_RAD 32
/* debug variables */
char rf_panicbuf[2048]; /* a buffer to hold an error msg when we panic */
/* main configuration routines */ /* main configuration routines */
static int raidframe_booted = 0; static int raidframe_booted = 0;
@ -888,17 +885,15 @@ rf_ConfigureDebug(RF_Config_t *cfgPtr)
void void
rf_print_panic_message(int line, const char *file) rf_print_panic_message(int line, const char *file)
{ {
snprintf(rf_panicbuf, sizeof(rf_panicbuf), kern_assert("raidframe error at line %d file %s", line, file);
"raidframe error at line %d file %s", line, file);
} }
#ifdef RAID_DIAGNOSTIC #ifdef RAID_DIAGNOSTIC
void void
rf_print_assert_panic_message(int line, const char *file, const char *condition) rf_print_assert_panic_message(int line, const char *file, const char *condition)
{ {
snprintf(rf_panicbuf, sizeof(rf_panicbuf), kern_assert("raidframe error at line %d file %s (failed asserting %s)\n",
"raidframe error at line %d file %s (failed asserting %s)\n", line, file, condition);
line, file, condition);
} }
#endif #endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_general.h,v 1.21 2014/03/25 16:19:14 christos Exp $ */ /* $NetBSD: rf_general.h,v 1.22 2016/12/10 23:03:27 maya Exp $ */
/* /*
* Copyright (c) 1995 Carnegie-Mellon University. * Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved. * All rights reserved.
@ -54,14 +54,12 @@ void rf_print_unable_to_init_mutex(const char *, int, int);
void rf_print_unable_to_add_shutdown(const char *, int, int); void rf_print_unable_to_add_shutdown(const char *, int, int);
extern char rf_panicbuf[]; #define RF_PANIC() {rf_print_panic_message(__LINE__,__FILE__);}
#define RF_PANIC() {rf_print_panic_message(__LINE__,__FILE__); panic("%s", rf_panicbuf);}
#if defined(RAID_DIAGNOSTIC) || defined(__COVERITY__) #if defined(RAID_DIAGNOSTIC) || defined(__COVERITY__)
#define RF_ASSERT(_x_) { \ #define RF_ASSERT(_x_) { \
if (!(_x_)) { \ if (!(_x_)) { \
rf_print_assert_panic_message(__LINE__, __FILE__, #_x_); \ rf_print_assert_panic_message(__LINE__, __FILE__, #_x_); \
panic(rf_panicbuf); \
} \ } \
} }
#else /* RAID_DIAGNOSTIC */ #else /* RAID_DIAGNOSTIC */