diff mbox series

[v2,1/2] mountd: Check for return of stat function

Message ID 20220816024403.2694169-1-raj.khem@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/2] mountd: Check for return of stat function | expand

Commit Message

Khem Raj Aug. 16, 2022, 2:44 a.m. UTC
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 <raj.khem@gmail.com>
Cc: Konstantin Khorenko <khorenko@virtuozzo.com>
Cc: Steve Dickson <steved@redhat.com>
---
v2: rebased

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

Comments

Steve Dickson Sept. 13, 2022, 5:37 p.m. UTC | #1
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 <raj.khem@gmail.com>
Committed... (tag: nfs-utils-2-6-3-rc1)

steved
> Cc: Konstantin Khorenko <khorenko@virtuozzo.com>
> Cc: Steve Dickson <steved@redhat.com>
> ---
> 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)
Steve Dickson Sept. 13, 2022, 5:38 p.m. UTC | #2
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 <raj.khem@gmail.com>
> Cc: Konstantin Khorenko <khorenko@virtuozzo.com>
Committed... (tag: nfs-utils-2-6-3-rc1)

steved
> Cc: Steve Dickson <steved@redhat.com>
> ---
> 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)
diff mbox series

Patch

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)