diff options
| author | Zixun LI <[email protected]> | 2026-05-05 11:36:41 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-05-05 11:36:41 +0200 |
| commit | f61b99f47934873e3a8133ddba77e8887a3e0d84 (patch) | |
| tree | 0c74d28e62fe9abb42aec7eeb6659608ff394a38 /examples | |
| parent | 17d24b397f772fb475b2be6c387c3023664df0a6 (diff) | |
Apply suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/host/msc_file_explorer_freertos/src/msc_app.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/examples/host/msc_file_explorer_freertos/src/msc_app.c b/examples/host/msc_file_explorer_freertos/src/msc_app.c index 09a1d3f08..c7e00e52a 100644 --- a/examples/host/msc_file_explorer_freertos/src/msc_app.c +++ b/examples/host/msc_file_explorer_freertos/src/msc_app.c @@ -448,14 +448,26 @@ void cli_cmd_dd(EmbeddedCli *cli, char *args, void *context) { const uint32_t start_ms = tusb_time_millis_api(); const uint8_t pdrv = dev_addr - 1; + bool submit_failed = false; for (uint32_t i = 0; i < count; i += sectors_per_xfer) { const uint16_t n = (uint16_t)((count - i < sectors_per_xfer) ? (count - i) : sectors_per_xfer); _disk_busy[pdrv] = true; - tuh_msc_read10(dev_addr, lun, rw_buf, i, n, disk_io_complete, 0); + + if (!tuh_msc_read10(dev_addr, lun, rw_buf, i, n, disk_io_complete, 0)) { + _disk_busy[pdrv] = false; + printf("dd: failed to submit read at sector %" PRIu32 " (%u sectors)\r\n", i, n); + submit_failed = true; + break; + } + wait_for_disk_io(pdrv); } + if (submit_failed) { + return; + } + const uint32_t elapsed_ms = tusb_time_millis_api() - start_ms; const uint32_t total_data = count * block_size; // each SCSI transaction has 31-byte CBW + data + 13-byte CSW @@ -552,6 +564,7 @@ void cli_cmd_cp(EmbeddedCli *cli, char *args, void *context) { if (FR_OK != f_open(f_dst, dst, FA_WRITE | FA_CREATE_ALWAYS)) { printf("cannot create '%s'\r\n", dst); + f_close(f_src); return; } else { UINT rd_count = 0; @@ -627,6 +640,7 @@ void cli_cmd_pwd(EmbeddedCli *cli, char *args, void *context) { char path[256]; if (FR_OK != f_getcwd(path, sizeof(path))) { printf("cannot get current working directory\r\n"); + return; } puts(path); |
