2022-08-16 07:35:06

by Khem Raj

[permalink] [raw]
Subject: [PATCH v2 1/2] mountd: Check for return of stat function

simplify the check, stat() return 0 on success -1 on failure

Fixes clang reported errors e.g.

| v4clients.c:29:6: error: logical not is only applied to the left hand side of this comparison [-Werror,-Wlogical-not-parentheses]
| if (!stat("/proc/fs/nfsd/clients", &sb) == 0 ||
| ^ ~~

Signed-off-by: Khem Raj <[email protected]>
Cc: Konstantin Khorenko <[email protected]>
Cc: Steve Dickson <[email protected]>
---
v2: rebased

support/export/v4clients.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/support/export/v4clients.c b/support/export/v4clients.c
index 5f15b61..3230251 100644
--- a/support/export/v4clients.c
+++ b/support/export/v4clients.c
@@ -26,7 +26,7 @@ void v4clients_init(void)
{
struct stat sb;

- if (!stat("/proc/fs/nfsd/clients", &sb) == 0 ||
+ if (stat("/proc/fs/nfsd/clients", &sb) != 0 ||
!S_ISDIR(sb.st_mode))
return;
if (clients_fd >= 0)
--
2.37.2


2022-09-13 18:25:51

by Steve Dickson

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] mountd: Check for return of stat function



On 8/15/22 10:44 PM, Khem Raj wrote:
> simplify the check, stat() return 0 on success -1 on failure
>
> Fixes clang reported errors e.g.
>
> | v4clients.c:29:6: error: logical not is only applied to the left hand side of this comparison [-Werror,-Wlogical-not-parentheses]
> | if (!stat("/proc/fs/nfsd/clients", &sb) == 0 ||
> | ^ ~~
>
> Signed-off-by: Khem Raj <[email protected]>
Committed... (tag: nfs-utils-2-6-3-rc1)

steved
> Cc: Konstantin Khorenko <[email protected]>
> Cc: Steve Dickson <[email protected]>
> ---
> v2: rebased
>
> support/export/v4clients.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/support/export/v4clients.c b/support/export/v4clients.c
> index 5f15b61..3230251 100644
> --- a/support/export/v4clients.c
> +++ b/support/export/v4clients.c
> @@ -26,7 +26,7 @@ void v4clients_init(void)
> {
> struct stat sb;
>
> - if (!stat("/proc/fs/nfsd/clients", &sb) == 0 ||
> + if (stat("/proc/fs/nfsd/clients", &sb) != 0 ||
> !S_ISDIR(sb.st_mode))
> return;
> if (clients_fd >= 0)

2022-09-13 18:25:57

by Steve Dickson

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] mountd: Check for return of stat function



On 8/15/22 10:44 PM, Khem Raj wrote:
> simplify the check, stat() return 0 on success -1 on failure
>
> Fixes clang reported errors e.g.
>
> | v4clients.c:29:6: error: logical not is only applied to the left hand side of this comparison [-Werror,-Wlogical-not-parentheses]
> | if (!stat("/proc/fs/nfsd/clients", &sb) == 0 ||
> | ^ ~~
>
> Signed-off-by: Khem Raj <[email protected]>
> Cc: Konstantin Khorenko <[email protected]>
Committed... (tag: nfs-utils-2-6-3-rc1)

steved
> Cc: Steve Dickson <[email protected]>
> ---
> v2: rebased
>
> support/export/v4clients.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/support/export/v4clients.c b/support/export/v4clients.c
> index 5f15b61..3230251 100644
> --- a/support/export/v4clients.c
> +++ b/support/export/v4clients.c
> @@ -26,7 +26,7 @@ void v4clients_init(void)
> {
> struct stat sb;
>
> - if (!stat("/proc/fs/nfsd/clients", &sb) == 0 ||
> + if (stat("/proc/fs/nfsd/clients", &sb) != 0 ||
> !S_ISDIR(sb.st_mode))
> return;
> if (clients_fd >= 0)