Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/raidframe For the RF_ASSERT() and RF_PANIC() macros, ...



details:   https://anonhg.NetBSD.org/src/rev/47c6e42444e6
branches:  trunk
changeset: 500663:47c6e42444e6
user:      oster <oster%NetBSD.org@localhost>
date:      Fri Dec 15 02:12:58 2000 +0000

description:
For the RF_ASSERT() and RF_PANIC() macros, call a function to do the
sprintf, instead of doing the sprintf in the macros.  This means just
1 copy of each of the error messages, chopping about about 16K off the
size of an i386 kernel.  Thanks to Simon Burge and Enami Tsugutomo
for providing the inspiration to do this.

diffstat:

 sys/dev/raidframe/rf_driver.c  |  23 ++++++++++++++++++++++-
 sys/dev/raidframe/rf_general.h |  11 ++++++-----
 2 files changed, 28 insertions(+), 6 deletions(-)

diffs (67 lines):

diff -r 5e7343458456 -r 47c6e42444e6 sys/dev/raidframe/rf_driver.c
--- a/sys/dev/raidframe/rf_driver.c     Fri Dec 15 01:30:36 2000 +0000
+++ b/sys/dev/raidframe/rf_driver.c     Fri Dec 15 02:12:58 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_driver.c,v 1.38 2000/09/21 01:45:46 oster Exp $     */
+/*     $NetBSD: rf_driver.c,v 1.39 2000/12/15 02:12:58 oster Exp $     */
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -995,3 +995,24 @@
        printf("Average access size (sect): %ld\n", RF_DB0_CHECK(raidPtr->userstats.num_sect_moved, raidPtr->userstats.num_ios));
        printf("Achieved data rate:         %ld.%ld MB/sec\n", mbs, mbs_frac);
 }
+
+
+void
+rf_print_panic_message(line,file)
+       int line;
+       char *file;
+{
+       sprintf(rf_panicbuf,"raidframe error at line %d file %s",
+               line, file);
+}
+
+void
+rf_print_assert_panic_message(line,file,condition)
+       int line;
+       char *file;
+       char *condition;
+{
+       sprintf(rf_panicbuf,
+               "raidframe error at line %d file %s (failed asserting %s)\n",
+               line, file, condition);
+}
diff -r 5e7343458456 -r 47c6e42444e6 sys/dev/raidframe/rf_general.h
--- a/sys/dev/raidframe/rf_general.h    Fri Dec 15 01:30:36 2000 +0000
+++ b/sys/dev/raidframe/rf_general.h    Fri Dec 15 02:12:58 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_general.h,v 1.5 2000/03/03 02:04:48 oster Exp $     */
+/*     $NetBSD: rf_general.h,v 1.6 2000/12/15 02:12:58 oster Exp $     */
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -46,8 +46,11 @@
 #define RF_ERRORMSG2(s,a,b)       printf((s),(a),(b))
 #define RF_ERRORMSG3(s,a,b,c)     printf((s),(a),(b),(c))
 
+void rf_print_panic_message(int, char *);
+void rf_print_assert_panic_message(int, char *, char *);
+
 extern char rf_panicbuf[];
-#define RF_PANIC() {sprintf(rf_panicbuf,"raidframe error at line %d file %s",__LINE__,__FILE__); panic(rf_panicbuf);}
+#define RF_PANIC() {rf_print_panic_message(__LINE__,__FILE__); panic(rf_panicbuf);}
 
 #ifdef _KERNEL
 #ifdef RF_ASSERT
@@ -56,9 +59,7 @@
 #ifndef NOASSERT
 #define RF_ASSERT(_x_) { \
   if (!(_x_)) { \
-    sprintf(rf_panicbuf, \
-        "raidframe error at line %d file %s (failed asserting %s)\n", \
-        __LINE__, __FILE__, #_x_); \
+    rf_print_assert_panic_message(__LINE__, __FILE__, #_x_); \
     panic(rf_panicbuf); \
   } \
 }



Home | Main Index | Thread Index | Old Index