From 906f0b27730b0506a24ed43029983b4d6819dd12 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Tue, 14 Jul 2009 17:00:47 -0400 Subject: [PATCH] mount.nfs: Squelch compiler warnings in nfs_strerror() Address compiler warnings: error.c: In function nfs_strerror: error.c:341: warning: comparison between signed and unsigned error.c:342: warning: comparison between signed and unsigned Signed-off-by: Chuck Lever Signed-off-by: Steve Dickson --- utils/mount/error.c | 12 ++++++------ utils/mount/error.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/utils/mount/error.c b/utils/mount/error.c index 5c9d3f2..4cc9e09 100644 --- a/utils/mount/error.c +++ b/utils/mount/error.c @@ -300,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; @@ -329,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; } diff --git a/utils/mount/error.h b/utils/mount/error.h index 7126de5..42b28cf 100644 --- a/utils/mount/error.h +++ b/utils/mount/error.h @@ -24,7 +24,7 @@ #ifndef _NFS_UTILS_MOUNT_ERROR_H #define _NFS_UTILS_MOUNT_ERROR_H -char *nfs_strerror(int); +char *nfs_strerror(unsigned int); void mount_error(const char *, const char *, int); void rpc_mount_errors(char *, int, int); -- 2.39.5