Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/lib/libsa Save some space
details: https://anonhg.NetBSD.org/src/rev/b5037364a28c
branches: trunk
changeset: 542557:b5037364a28c
user: dsl <dsl%NetBSD.org@localhost>
date: Sat Feb 01 14:53:38 2003 +0000
description:
Save some space
(agreed by christos)
diffstat:
sys/lib/libsa/strerror.c | 76 ++++++++++++++++++++---------------------------
1 files changed, 33 insertions(+), 43 deletions(-)
diffs (90 lines):
diff -r f1b7c11ba62e -r b5037364a28c sys/lib/libsa/strerror.c
--- a/sys/lib/libsa/strerror.c Sat Feb 01 14:52:13 2003 +0000
+++ b/sys/lib/libsa/strerror.c Sat Feb 01 14:53:38 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: strerror.c,v 1.13 2002/02/17 23:18:32 thorpej Exp $ */
+/* $NetBSD: strerror.c,v 1.14 2003/02/01 14:53:38 dsl Exp $ */
/*-
* Copyright (c) 1993
@@ -37,48 +37,38 @@
#include "saerrno.h"
#include "stand.h"
-char *
-strerror(err)
- int err;
-{
-static char ebuf[64];
+static const struct mi {
+ int errno;
+ char *msg;
+} errlist[] = {
+ { EADAPT, "bad adaptor number" },
+ { ECTLR, "bad controller number" },
+ { EUNIT, "bad drive number" },
+ { EPART, "bad partition" },
+ { ERDLAB, "can't read disk label" },
+ { EUNLAB, "unlabeled" },
+ { ENXIO, "Device not configured" },
+ { EPERM, "Operation not permitted" },
+ { ENOENT, "No such file or directory" },
+ { ESTALE, "Stale NFS file handle" },
+ { EFTYPE, "Inappropriate file type or format" },
+ { ENOEXEC, "Exec format error" },
+ { EIO, "Input/output error" },
+ { EINVAL, "Invalid argument" },
+ { ENOTDIR, "Not a directory" },
+ { EOFFSET, "invalid file offset" },
+ { 0, 0 } };
- switch (err) {
- case EADAPT:
- return "bad adaptor number";
- case ECTLR:
- return "bad controller number";
- case EUNIT:
- return "bad drive number";
- case EPART:
- return "bad partition";
- case ERDLAB:
- return "can't read disk label";
- case EUNLAB:
- return "unlabeled";
- case ENXIO:
- return "Device not configured";
- case EPERM:
- return "Operation not permitted";
- case ENOENT:
- return "No such file or directory";
- case ESTALE:
- return "Stale NFS file handle";
- case EFTYPE:
- return "Inappropriate file type or format";
- case ENOEXEC:
- return "Exec format error";
- case EIO:
- return "Input/output error";
- case EINVAL:
- return "Invalid argument";
- case ENOTDIR:
- return "Not a directory";
- case EOFFSET:
- return "invalid file offset";
+char *
+strerror(int err)
+{
+ static char ebuf[36];
+ const struct mi *mi;
- default:
- sprintf(ebuf, "Unknown error: code %d", err);
- return ebuf;
- }
+ for (mi = errlist; mi->msg; mi++)
+ if (mi->errno == err)
+ return mi->msg;
+
+ snprintf(ebuf, sizeof ebuf, "Unknown error: code %d", err);
+ return ebuf;
}
Home |
Main Index |
Thread Index |
Old Index