Skip to content

Commit 2802a9a

Browse files
sylvioalveskartben
authored andcommitted
drivers: flash: esp32: handle zero-length reads as no-op
Add a guard clause in flash_esp32_read() to return 0 when the requested length is zero. This avoids unnecessary operations and aligns with expected flash API behavior, where reading zero bytes is treated as a no-op. Signed-off-by: Sylvio Alves <[email protected]>
1 parent d7d5aeb commit 2802a9a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/flash/flash_esp32.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ static int flash_esp32_read(const struct device *dev, off_t address, void *buffe
8989
{
9090
int ret = 0;
9191

92+
if (length == 0U) {
93+
return 0;
94+
}
95+
9296
#ifdef CONFIG_MCUBOOT
9397
uint8_t *dest_ptr = (uint8_t *)buffer;
9498
size_t remaining = length;

0 commit comments

Comments
 (0)