Ver código fonte

Split strerror() out from errno.c

tags/v0.9.3
Michael Brown 18 anos atrás
pai
commit
7766e34ed1
2 arquivos alterados com 51 adições e 45 exclusões
  1. 2
    45
      src/core/errno.c
  2. 49
    0
      src/hci/strerror.c

+ 2
- 45
src/core/errno.c Ver arquivo

@@ -1,23 +1,10 @@
1 1
 #include <errno.h>
2
-#include <console.h>
3
-#include <gpxe/errortab.h>
4 2
 
5 3
 /** @file
6 4
  *
7
- * Error codes and descriptions.
5
+ * Error codes
8 6
  *
9
- * This file provides the global variable #errno and the function
10
- * strerror().  These function much like their standard C library
11
- * equivalents.
12
- *
13
- * The error numbers used by Etherboot are a superset of those defined
14
- * by the PXE specification version 2.1.  See errno.h for a listing of
15
- * the error values.
16
- *
17
- * To save space in ROM images, error string tables are optional.  Use
18
- * the ERRORMSG_XXX options in config.h to select which error string
19
- * tables you want to include.  If an error string table is omitted,
20
- * strerror() will simply return the text "Error 0x<errno>".
7
+ * This file provides the global variable #errno.
21 8
  *
22 9
  */
23 10
 
@@ -29,33 +16,3 @@
29 16
  *
30 17
  */
31 18
 int errno;
32
-
33
-static struct errortab errortab_start[0] __table_start(errortab);
34
-static struct errortab errortab_end[0] __table_end(errortab);
35
-
36
-/**
37
- * Retrieve string representation of error number.
38
- *
39
- * @v errno		Error number
40
- * @ret strerror	Pointer to error text
41
- *
42
- * If the error is not found in the linked-in error tables, generates
43
- * a generic "Error 0x<errno>" message.
44
- *
45
- * The pointer returned by strerror() is valid only until the next
46
- * call to strerror().
47
- *
48
- */
49
-const char * strerror ( int errno ) {
50
-	static char *generic_message = "Error 0x0000";
51
-	struct errortab *errortab;
52
-
53
-	for ( errortab = errortab_start ; errortab < errortab_end ;
54
-	      errortab++ ) {
55
-		if ( errortab->errno == errno )
56
-			return errortab->text;
57
-	}
58
-
59
-	sprintf ( generic_message + 8, "%hx", errno );
60
-	return generic_message;
61
-}

+ 49
- 0
src/hci/strerror.c Ver arquivo

@@ -0,0 +1,49 @@
1
+#include <errno.h>
2
+#include <string.h>
3
+#include <console.h>
4
+#include <gpxe/errortab.h>
5
+
6
+/** @file
7
+ *
8
+ * Error descriptions.
9
+ *
10
+ * The error numbers used by Etherboot are a superset of those defined
11
+ * by the PXE specification version 2.1.  See errno.h for a listing of
12
+ * the error values.
13
+ *
14
+ * To save space in ROM images, error string tables are optional.  Use
15
+ * the ERRORMSG_XXX options in config.h to select which error string
16
+ * tables you want to include.  If an error string table is omitted,
17
+ * strerror() will simply return the text "Error 0x<errno>".
18
+ *
19
+ */
20
+
21
+static struct errortab errortab_start[0] __table_start(errortab);
22
+static struct errortab errortab_end[0] __table_end(errortab);
23
+
24
+/**
25
+ * Retrieve string representation of error number.
26
+ *
27
+ * @v errno		Error number
28
+ * @ret strerror	Pointer to error text
29
+ *
30
+ * If the error is not found in the linked-in error tables, generates
31
+ * a generic "Error 0x<errno>" message.
32
+ *
33
+ * The pointer returned by strerror() is valid only until the next
34
+ * call to strerror().
35
+ *
36
+ */
37
+const char * strerror ( int errno ) {
38
+	static char *generic_message = "Error 0x0000";
39
+	struct errortab *errortab;
40
+
41
+	for ( errortab = errortab_start ; errortab < errortab_end ;
42
+	      errortab++ ) {
43
+		if ( errortab->errno == errno )
44
+			return errortab->text;
45
+	}
46
+
47
+	sprintf ( generic_message + 8, "%hx", errno );
48
+	return generic_message;
49
+}

Carregando…
Cancelar
Salvar