From c3990892484c52a5e064e1393cafca525368fecd Mon Sep 17 00:00:00 2001 From: safocl Date: Wed, 29 Jan 2025 23:25:27 +0400 Subject: [PATCH] refactor(components/fatfs): replace assert EXPR assert expressions in the diskio_wl.c file contains a magical calculations. Replace them with an equality check. --- components/fatfs/diskio/diskio_wl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/fatfs/diskio/diskio_wl.c b/components/fatfs/diskio/diskio_wl.c index 6c74695d41..7de9061ad5 100644 --- a/components/fatfs/diskio/diskio_wl.c +++ b/components/fatfs/diskio/diskio_wl.c @@ -33,7 +33,7 @@ DRESULT ff_wl_read (BYTE pdrv, BYTE *buff, DWORD sector, UINT count) { ESP_LOGV(TAG, "ff_wl_read - pdrv=%i, sector=%i, count=%i", (unsigned int)pdrv, (unsigned int)sector, (unsigned int)count); wl_handle_t wl_handle = ff_wl_handles[pdrv]; - assert(wl_handle + 1); + assert(wl_handle != WL_INVALID_HANDLE); esp_err_t err = wl_read(wl_handle, sector * wl_sector_size(wl_handle), buff, count * wl_sector_size(wl_handle)); if (unlikely(err != ESP_OK)) { ESP_LOGE(TAG, "wl_read failed (0x%x)", err); @@ -46,7 +46,7 @@ DRESULT ff_wl_write (BYTE pdrv, const BYTE *buff, DWORD sector, UINT count) { ESP_LOGV(TAG, "ff_wl_write - pdrv=%i, sector=%i, count=%i", (unsigned int)pdrv, (unsigned int)sector, (unsigned int)count); wl_handle_t wl_handle = ff_wl_handles[pdrv]; - assert(wl_handle + 1); + assert(wl_handle != WL_INVALID_HANDLE); esp_err_t err = wl_erase_range(wl_handle, sector * wl_sector_size(wl_handle), count * wl_sector_size(wl_handle)); if (unlikely(err != ESP_OK)) { ESP_LOGE(TAG, "wl_erase_range failed (0x%x)", err); @@ -64,7 +64,7 @@ DRESULT ff_wl_ioctl (BYTE pdrv, BYTE cmd, void *buff) { wl_handle_t wl_handle = ff_wl_handles[pdrv]; ESP_LOGV(TAG, "ff_wl_ioctl: cmd=%i", cmd); - assert(wl_handle + 1); + assert(wl_handle != WL_INVALID_HANDLE); switch (cmd) { case CTRL_SYNC: return RES_OK;