summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2011-05-31 08:44:02 +1000
committerAndrew Bartlett <abartlet@samba.org>2011-05-31 02:57:19 +0200
commitaa848c12eba441700557af78cb2ad23661d56f21 (patch)
tree3bbabde65a3a81cfd2bae6848a5917c79c9de0a3
parent8a75d738673adaca903fe71a0b9368b9bcaea4bd (diff)
downloadsamba-aa848c12eba441700557af78cb2ad23661d56f21.tar.gz
samba-aa848c12eba441700557af78cb2ad23661d56f21.tar.bz2
samba-aa848c12eba441700557af78cb2ad23661d56f21.zip
s3-lib: Use ARRAY_SIZE() to walk the error mapping tables
This gives a constant termination condition, and may help the compiler. Andrew Bartlett
-rw-r--r--source3/lib/errmap_unix.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/source3/lib/errmap_unix.c b/source3/lib/errmap_unix.c
index f0ae217222..90fd9d68c8 100644
--- a/source3/lib/errmap_unix.c
+++ b/source3/lib/errmap_unix.c
@@ -111,7 +111,6 @@ static const struct {
#ifdef ENOTSUP
{ ENOTSUP, NT_STATUS_NOT_SUPPORTED},
#endif
- { 0, NT_STATUS_OK }
};
/*********************************************************************
@@ -134,10 +133,10 @@ NTSTATUS map_nt_error_from_unix(int unix_error)
}
/* Look through list */
- while(unix_nt_errmap[i].unix_error != 0) {
- if (unix_nt_errmap[i].unix_error == unix_error)
+ for (i=0;i<ARRAY_SIZE(unix_nt_errmap);i++) {
+ if (unix_nt_errmap[i].unix_error == unix_error) {
return unix_nt_errmap[i].nt_error;
- i++;
+ }
}
/* Default return */
@@ -254,7 +253,6 @@ static const struct {
#ifdef EXDEV
{NT_STATUS_NOT_SAME_DEVICE, EXDEV},
#endif
- {NT_STATUS(0), 0}
};
int map_errno_from_nt_status(NTSTATUS status)
@@ -269,7 +267,7 @@ int map_errno_from_nt_status(NTSTATUS status)
return 0;
}
- for (i=0;nt_errno_map[i].error;i++) {
+ for (i=0;i<ARRAY_SIZE(nt_errno_map);i++) {
if (NT_STATUS_V(nt_errno_map[i].status) ==
NT_STATUS_V(status)) {
return nt_errno_map[i].error;