From 7766e34ed1a5f8f20207d92c7947762e4df9c2c5 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 20 Dec 2006 03:49:36 +0000 Subject: Split strerror() out from errno.c --- src/core/errno.c | 47 ++--------------------------------------------- src/hci/strerror.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 45 deletions(-) create mode 100644 src/hci/strerror.c (limited to 'src') diff --git a/src/core/errno.c b/src/core/errno.c index 84c3424a..b4f44cec 100644 --- a/src/core/errno.c +++ b/src/core/errno.c @@ -1,23 +1,10 @@ #include -#include -#include /** @file * - * Error codes and descriptions. + * Error codes * - * This file provides the global variable #errno and the function - * strerror(). These function much like their standard C library - * equivalents. - * - * The error numbers used by Etherboot are a superset of those defined - * by the PXE specification version 2.1. See errno.h for a listing of - * the error values. - * - * To save space in ROM images, error string tables are optional. Use - * the ERRORMSG_XXX options in config.h to select which error string - * tables you want to include. If an error string table is omitted, - * strerror() will simply return the text "Error 0x". + * This file provides the global variable #errno. * */ @@ -29,33 +16,3 @@ * */ int errno; - -static struct errortab errortab_start[0] __table_start(errortab); -static struct errortab errortab_end[0] __table_end(errortab); - -/** - * Retrieve string representation of error number. - * - * @v errno Error number - * @ret strerror Pointer to error text - * - * If the error is not found in the linked-in error tables, generates - * a generic "Error 0x" message. - * - * The pointer returned by strerror() is valid only until the next - * call to strerror(). - * - */ -const char * strerror ( int errno ) { - static char *generic_message = "Error 0x0000"; - struct errortab *errortab; - - for ( errortab = errortab_start ; errortab < errortab_end ; - errortab++ ) { - if ( errortab->errno == errno ) - return errortab->text; - } - - sprintf ( generic_message + 8, "%hx", errno ); - return generic_message; -} diff --git a/src/hci/strerror.c b/src/hci/strerror.c new file mode 100644 index 00000000..10344f55 --- /dev/null +++ b/src/hci/strerror.c @@ -0,0 +1,49 @@ +#include +#include +#include +#include + +/** @file + * + * Error descriptions. + * + * The error numbers used by Etherboot are a superset of those defined + * by the PXE specification version 2.1. See errno.h for a listing of + * the error values. + * + * To save space in ROM images, error string tables are optional. Use + * the ERRORMSG_XXX options in config.h to select which error string + * tables you want to include. If an error string table is omitted, + * strerror() will simply return the text "Error 0x". + * + */ + +static struct errortab errortab_start[0] __table_start(errortab); +static struct errortab errortab_end[0] __table_end(errortab); + +/** + * Retrieve string representation of error number. + * + * @v errno Error number + * @ret strerror Pointer to error text + * + * If the error is not found in the linked-in error tables, generates + * a generic "Error 0x" message. + * + * The pointer returned by strerror() is valid only until the next + * call to strerror(). + * + */ +const char * strerror ( int errno ) { + static char *generic_message = "Error 0x0000"; + struct errortab *errortab; + + for ( errortab = errortab_start ; errortab < errortab_end ; + errortab++ ) { + if ( errortab->errno == errno ) + return errortab->text; + } + + sprintf ( generic_message + 8, "%hx", errno ); + return generic_message; +} -- cgit v1.2.3-55-g7522