This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 0989d820e testing/[sd_bench|sd_stress]: make print compatible for both
32-bit and 64-bit environment.
0989d820e is described below
commit 0989d820edd62c7ab6b01ca2b5779ea30d2c4b4b
Author: Windrow14 <[email protected]>
AuthorDate: Thu Jul 4 10:55:19 2024 +0800
testing/[sd_bench|sd_stress]: make print compatible for both 32-bit and
64-bit environment.
Use size_t and %zu in printf of sd modules to fix compilation errors in
64-bit environment.
Signed-off-by: Yinzhe Wu <[email protected]>
Reviewed-by: Yuezhang Mo <[email protected]>
Reviewed-by: Jacky Cao <[email protected]>
Tested-by: Yinzhe Wu <[email protected]>
---
testing/sd_bench/sd_bench_main.c | 18 +++++++++---------
testing/sd_stress/sd_stress_main.c | 14 +++++++-------
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/testing/sd_bench/sd_bench_main.c b/testing/sd_bench/sd_bench_main.c
index c8d465b62..a8a06f8d2 100644
--- a/testing/sd_bench/sd_bench_main.c
+++ b/testing/sd_bench/sd_bench_main.c
@@ -176,7 +176,7 @@ static void write_test(int fd, sdb_config_t *cfg, uint8_t
*block,
uint64_t elapsed;
uint64_t total_elapsed = 0.;
size_t total_blocks = 0;
- size_t *blocknumber = (unsigned int *)(void *)&block[0];
+ size_t *blocknumber = (size_t *)(void *)&block[0];
printf("\n");
printf("Testing Sequential Write Speed...\n");
@@ -277,7 +277,7 @@ static int read_test(int fd, sdb_config_t *cfg, uint8_t
*block,
total_elapsed = 0.;
total_blocks = 0;
- size_t *blocknumber = (unsigned int *)(void *) &read_block[0];
+ size_t *blocknumber = (size_t *)(void *) &read_block[0];
for (int run = 0; run < cfg->num_runs; ++run)
{
@@ -306,8 +306,8 @@ static int read_test(int fd, sdb_config_t *cfg, uint8_t
*block,
if (*blocknumber != total_blocks + num_blocks)
{
- printf("Read data error at block: %d wrote:0x%04x read:0x%04x",
- (total_blocks + num_blocks),
+ printf("Read data error at block: %zu wrote:0x%04zx "
+ "read:0x%04zx", total_blocks + num_blocks,
total_blocks + num_blocks, *blocknumber);
}
@@ -316,7 +316,7 @@ static int read_test(int fd, sdb_config_t *cfg, uint8_t
*block,
{
if (block[i] != read_block[i])
{
- printf("Read data error at offset: %d wrote:0x%02x "
+ printf("Read data error at offset: %zu wrote:0x%02x "
"read:0x%02x", total_blocks + num_blocks + i,
block[i], read_block[i]);
}
@@ -353,11 +353,11 @@ static void usage(void)
printf("Test the speed of an SD card or mount point\n");
printf(CONFIG_TESTING_SD_BENCH_PROGNAME
": [-b] [-r] [-d] [-k] [-s] [-a] [-v]\n");
- printf(" -b Block size per write (%u-%u), default %u\n",
+ printf(" -b Block size per write (%zu-%zu), default %zu\n",
min_block, max_block, default_block);
- printf(" -r Number of runs (%u-%u), default %u\n",
+ printf(" -r Number of runs (%zu-%zu), default %zu\n",
min_runs, max_runs, default_runs);
- printf(" -d Max duration of a test (ms) (%u-%u), default %u\n",
+ printf(" -d Max duration of a test (ms) (%zu-%zu), default %zu\n",
min_duration, max_duration, default_duration);
printf(" -k Keep test file when finished, default %s\n",
print_bool(default_keep_test));
@@ -481,7 +481,7 @@ int main(int argc, char *argv[])
block[j] = (uint8_t)j;
}
- printf("Using block size = %u bytes, sync = %s\n", block_size,
+ printf("Using block size = %zu bytes, sync = %s\n", block_size,
print_bool(cfg.synchronized));
write_test(bench_fd, &cfg, block, block_size);
diff --git a/testing/sd_stress/sd_stress_main.c
b/testing/sd_stress/sd_stress_main.c
index b65455a66..6720dcb39 100644
--- a/testing/sd_stress/sd_stress_main.c
+++ b/testing/sd_stress/sd_stress_main.c
@@ -85,11 +85,11 @@ static void usage(void)
{
printf("Stress test on a mount point\n");
printf(CONFIG_TESTING_SD_STRESS_PROGNAME ": [-r] [-b] [-f]\n");
- printf(" -r Number of runs (%u-%u), default %u\n",
+ printf(" -r Number of runs (%zu-%zu), default %zu\n",
min_runs, max_runs, default_runs);
- printf(" -b Number of bytes (%u-%u), default %u\n",
+ printf(" -b Number of bytes (%zu-%zu), default %zu\n",
min_bytes, max_bytes, default_bytes);
- printf(" -f Number of files (%u-%u), default %u\n",
+ printf(" -f Number of files (%zu-%zu), default %zu\n",
min_files, max_files, default_files);
}
@@ -150,7 +150,7 @@ static bool create_files(const char *dir, const char *name,
for (size_t i = 0; i < num_files; ++i)
{
char path[MAX_PATH_LEN];
- snprintf(path, MAX_PATH_LEN, "%s/%s%03u", dir, name, i);
+ snprintf(path, MAX_PATH_LEN, "%s/%s%03zu", dir, name, i);
memset(read_bytes, 0x0, num_bytes);
@@ -243,7 +243,7 @@ static bool remove_files(const char *dir, const char *name,
for (size_t i = 0; i < num_files; ++i)
{
char path[MAX_PATH_LEN];
- snprintf(path, MAX_PATH_LEN, "%s/%s%03u", dir, name, i);
+ snprintf(path, MAX_PATH_LEN, "%s/%s%03zu", dir, name, i);
int ret = unlink(path);
@@ -354,7 +354,7 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
- printf("Start stress test with %u files, %u bytes and %u iterations.\n",
+ printf("Start stress test with %zu files, %zu bytes and %zu iterations.\n",
num_files, num_bytes, num_runs);
bytes = (char *)malloc(num_bytes);
@@ -386,7 +386,7 @@ int main(int argc, char *argv[])
elapsed_time = get_elapsed_time_ms(&start);
total_time += elapsed_time;
- printf("iteration %u took %.3f ms: %s\n", i,
+ printf("iteration %zu took %.3f ms: %s\n", i,
elapsed_time, result ? "OK" : "FAIL");
if (!result)