X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fmount%2Ferror.c;h=4cc9e0949e3645dbbd6b17c077161e3adb5ab2f5;hp=5fd57057705ad69f62a1c9fdb9719097f5485aa5;hb=906f0b27730b0506a24ed43029983b4d6819dd12;hpb=52fe32278aee9f359d4ef6d1fab7be405ca0b193 diff --git a/utils/mount/error.c b/utils/mount/error.c index 5fd5705..4cc9e09 100644 --- a/utils/mount/error.c +++ b/utils/mount/error.c @@ -35,8 +35,6 @@ #include #include #include -#include -#include #include "xcommon.h" #include "nls.h" @@ -302,6 +300,8 @@ void umount_error(int err, const char *dev) #define EDQUOT ENOSPC #endif +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + static struct { enum nfsstat stat; int errnum; @@ -331,19 +331,17 @@ static struct { #endif /* Throw in some NFSv3 values for even more fun (HP returns these) */ { 71, EREMOTE }, - - { -1, EIO } }; -char *nfs_strerror(int stat) +char *nfs_strerror(unsigned int stat) { - int i; + unsigned int i; static char buf[256]; - for (i = 0; nfs_errtbl[i].stat != -1; i++) { + for (i = 0; i < ARRAY_SIZE(nfs_errtbl); i++) { if (nfs_errtbl[i].stat == stat) return strerror(nfs_errtbl[i].errnum); } - sprintf(buf, _("unknown nfs status return value: %d"), stat); + sprintf(buf, _("unknown nfs status return value: %u"), stat); return buf; }