* [PATCH] selftests/mount: Explicitly define buffer size
@ 2025-02-22 8:17 ritvikfoss
2025-02-22 8:36 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: ritvikfoss @ 2025-02-22 8:17 UTC (permalink / raw)
To: shuah; +Cc: linux-kselftest, linux-kernel, skhan, linux-kernel-mentees
From: Ritvik Gupta <ritvikfoss@gmail.com>
Define macro ('MAX_BUF_SIZE') for buffer size
instead of hardcoded value '4096', to improve
readability.
Signed-off-by: Ritvik Gupta <ritvikfoss@gmail.com>
---
tools/testing/selftests/mount/unprivileged-remount-test.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/mount/unprivileged-remount-test.c b/tools/testing/selftests/mount/unprivileged-remount-test.c
index d2917054fe3a..67a550b7c69b 100644
--- a/tools/testing/selftests/mount/unprivileged-remount-test.c
+++ b/tools/testing/selftests/mount/unprivileged-remount-test.c
@@ -45,6 +45,8 @@
# define MS_STRICTATIME (1 << 24)
#endif
+#define MAX_BUF_SIZE 4096
+
static void die(char *fmt, ...)
{
va_list ap;
@@ -56,7 +58,7 @@ static void die(char *fmt, ...)
static void vmaybe_write_file(bool enoent_ok, char *filename, char *fmt, va_list ap)
{
- char buf[4096];
+ char buf[MAX_BUF_SIZE];
int fd;
ssize_t written;
int buf_len;
--
2.48.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] selftests/mount: Explicitly define buffer size
2025-02-22 8:17 [PATCH] selftests/mount: Explicitly define buffer size ritvikfoss
@ 2025-02-22 8:36 ` Greg KH
2025-02-22 9:30 ` Ritvik Gupta
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2025-02-22 8:36 UTC (permalink / raw)
To: ritvikfoss
Cc: shuah, linux-kselftest, linux-kernel, skhan, linux-kernel-mentees
On Sat, Feb 22, 2025 at 01:47:11PM +0530, ritvikfoss@gmail.com wrote:
> From: Ritvik Gupta <ritvikfoss@gmail.com>
>
> Define macro ('MAX_BUF_SIZE') for buffer size
> instead of hardcoded value '4096', to improve
> readability.
>
> Signed-off-by: Ritvik Gupta <ritvikfoss@gmail.com>
> ---
> tools/testing/selftests/mount/unprivileged-remount-test.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/mount/unprivileged-remount-test.c b/tools/testing/selftests/mount/unprivileged-remount-test.c
> index d2917054fe3a..67a550b7c69b 100644
> --- a/tools/testing/selftests/mount/unprivileged-remount-test.c
> +++ b/tools/testing/selftests/mount/unprivileged-remount-test.c
> @@ -45,6 +45,8 @@
> # define MS_STRICTATIME (1 << 24)
> #endif
>
> +#define MAX_BUF_SIZE 4096
> +
> static void die(char *fmt, ...)
> {
> va_list ap;
> @@ -56,7 +58,7 @@ static void die(char *fmt, ...)
>
> static void vmaybe_write_file(bool enoent_ok, char *filename, char *fmt, va_list ap)
> {
> - char buf[4096];
> + char buf[MAX_BUF_SIZE];
As this is only used once, why is a #define really needed at all? Only
do that if it makes sense (i.e. is checked in different places.)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-02-22 9:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-22 8:17 [PATCH] selftests/mount: Explicitly define buffer size ritvikfoss
2025-02-22 8:36 ` Greg KH
2025-02-22 9:30 ` Ritvik Gupta
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox