From: Edward Liaw via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Cc: kernel-team@android.com
Subject: [LTP] [PATCH v2 1/3] tst_device.c: Use PATH_MAX more consistently
Date: Mon, 20 Mar 2023 23:51:06 +0000 [thread overview]
Message-ID: <20230320235108.2058967-2-edliaw@google.com> (raw)
In-Reply-To: <20230320235108.2058967-1-edliaw@google.com>
Replace hardcoded 1024 path sizes with PATH_MAX.
Signed-off-by: Edward Liaw <edliaw@google.com>
---
lib/tst_device.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/tst_device.c b/lib/tst_device.c
index 48d7e3ab6..a61c5a748 100644
--- a/lib/tst_device.c
+++ b/lib/tst_device.c
@@ -50,7 +50,7 @@
#define UUID_STR_SZ 37
#define UUID_FMT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
-static char dev_path[1024];
+static char dev_path[PATH_MAX];
static int device_acquired;
static unsigned long prev_dev_sec_write;
@@ -79,7 +79,7 @@ int tst_find_free_loopdev(char *path, size_t path_len)
{
int ctl_fd, dev_fd, rc, i;
struct loop_info loopinfo;
- char buf[1024];
+ char buf[PATH_MAX];
/* since Linux 3.1 */
ctl_fd = open(LOOP_CONTROL_FILE, O_RDWR);
@@ -489,7 +489,7 @@ int find_stat_file(const char *dev, char *path, size_t path_len)
unsigned long tst_dev_bytes_written(const char *dev)
{
unsigned long dev_sec_write = 0, dev_bytes_written, io_ticks = 0;
- char dev_stat_path[1024];
+ char dev_stat_path[PATH_MAX];
if (!find_stat_file(dev, dev_stat_path, sizeof(dev_stat_path)))
tst_brkm(TCONF, NULL, "Test device stat file: %s not found",
@@ -641,7 +641,7 @@ int tst_dev_block_size(const char *path)
{
int fd;
int size;
- char dev_name[1024];
+ char dev_name[PATH_MAX];
tst_find_backing_dev(path, dev_name);
--
2.40.0.rc1.284.g88254d51c5-goog
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2023-03-20 23:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-20 23:51 [LTP] [PATCH v2 0/3] tst_device.c: Handle Android path for backing device Edward Liaw via ltp
2023-03-20 23:51 ` Edward Liaw via ltp [this message]
2023-03-23 8:13 ` [LTP] [PATCH v2 1/3] tst_device.c: Use PATH_MAX more consistently Petr Vorel
2023-03-20 23:51 ` [LTP] [PATCH v2 2/3] set_dev_loop_path: Refactor set_dev_path and check return value Edward Liaw via ltp
2023-03-23 8:52 ` Petr Vorel
2023-03-23 23:47 ` Edward Liaw via ltp
2023-03-24 6:12 ` Petr Vorel
2023-03-20 23:51 ` [LTP] [PATCH v2 3/3] tst_find_backing_dev: Also check /dev/block/ for backing device Edward Liaw via ltp
2023-03-23 8:53 ` Petr Vorel
2023-03-23 8:24 ` [LTP] [PATCH v2 0/3] tst_device.c: Handle Android path " Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230320235108.2058967-2-edliaw@google.com \
--to=ltp@lists.linux.it \
--cc=edliaw@google.com \
--cc=kernel-team@android.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox