cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] selftests: cgroup: Fixes code style errors
@ 2023-11-06 18:11 Atul Kumar Pant
  2023-11-30 23:46 ` Shuah Khan
  0 siblings, 1 reply; 2+ messages in thread
From: Atul Kumar Pant @ 2023-11-06 18:11 UTC (permalink / raw)
  To: tj, lizefan.x, hannes, shuah
  Cc: Atul Kumar Pant, cgroups, linux-kselftest, linux-kernel

Fixes following checkpatch.pl issues:
ERROR: do not use assignment in if condition
ERROR: Macros starting with if should be enclosed by a do - while

Signed-off-by: Atul Kumar Pant <atulpant.linux@gmail.com>
---
 tools/testing/selftests/cgroup/cgroup_util.c | 14 ++++++++------
 tools/testing/selftests/cgroup/test_core.c   |  3 ++-
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c
index 0340d4ca8f51..e165c4a703a6 100644
--- a/tools/testing/selftests/cgroup/cgroup_util.c
+++ b/tools/testing/selftests/cgroup/cgroup_util.c
@@ -411,12 +411,14 @@ int dirfd_open_opath(const char *dir)
 	return open(dir, O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW | O_PATH);
 }
 
-#define close_prot_errno(fd)                                                   \
-	if (fd >= 0) {                                                         \
-		int _e_ = errno;                                               \
-		close(fd);                                                     \
-		errno = _e_;                                                   \
-	}
+#define close_prot_errno(fd)				\
+	do {						\
+		if (fd >= 0) {                          \
+			int _e_ = errno;                \
+			close(fd);                      \
+			errno = _e_;                    \
+		}					\
+	} while (0);
 
 static int clone_into_cgroup_run_nowait(const char *cgroup,
 					int (*fn)(const char *cgroup, void *arg),
diff --git a/tools/testing/selftests/cgroup/test_core.c b/tools/testing/selftests/cgroup/test_core.c
index 80aa6b2373b9..ad758e510174 100644
--- a/tools/testing/selftests/cgroup/test_core.c
+++ b/tools/testing/selftests/cgroup/test_core.c
@@ -817,7 +817,8 @@ static int test_cgcore_lesser_ns_open(const char *root)
 	if (cg_enter_current(cg_test_a))
 		goto cleanup;
 
-	if ((status = write(cg_test_b_procs_fd, "0", 1)) >= 0 || errno != ENOENT)
+	status = write(cg_test_b_procs_fd, "0", 1);
+	if (status >= 0 || errno != ENOENT)
 		goto cleanup;
 
 	ret = KSFT_PASS;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] selftests: cgroup: Fixes code style errors
  2023-11-06 18:11 [PATCH v1] selftests: cgroup: Fixes code style errors Atul Kumar Pant
@ 2023-11-30 23:46 ` Shuah Khan
  0 siblings, 0 replies; 2+ messages in thread
From: Shuah Khan @ 2023-11-30 23:46 UTC (permalink / raw)
  To: Atul Kumar Pant, tj, lizefan.x, hannes, shuah
  Cc: cgroups, linux-kselftest, linux-kernel, Shuah Khan

On 11/6/23 11:11, Atul Kumar Pant wrote:
> Fixes following checkpatch.pl issues:
> ERROR: do not use assignment in if condition
> ERROR: Macros starting with if should be enclosed by a do - while
> 
> Signed-off-by: Atul Kumar Pant <atulpant.linux@gmail.com>
> ---
>   tools/testing/selftests/cgroup/cgroup_util.c | 14 ++++++++------
>   tools/testing/selftests/cgroup/test_core.c   |  3 ++-
>   2 files changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c
> index 0340d4ca8f51..e165c4a703a6 100644
> --- a/tools/testing/selftests/cgroup/cgroup_util.c
> +++ b/tools/testing/selftests/cgroup/cgroup_util.c
> @@ -411,12 +411,14 @@ int dirfd_open_opath(const char *dir)
>   	return open(dir, O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW | O_PATH);
>   }
>   
> -#define close_prot_errno(fd)                                                   \
> -	if (fd >= 0) {                                                         \
> -		int _e_ = errno;                                               \
> -		close(fd);                                                     \
> -		errno = _e_;                                                   \
> -	}
> +#define close_prot_errno(fd)				\
> +	do {						\
> +		if (fd >= 0) {                          \
> +			int _e_ = errno;                \
> +			close(fd);                      \
> +			errno = _e_;                    \
> +		}					\
> +	} while (0);

Did you run checkpatch on this patch? You are fixing
checkpatch errors - :)

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-30 23:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-06 18:11 [PATCH v1] selftests: cgroup: Fixes code style errors Atul Kumar Pant
2023-11-30 23:46 ` Shuah Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).