Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

permit SPIFFS_write() on NULL buffer #111

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

benpicco
Copy link
Contributor

SPIFFS_write(&spi_fs, fd, buf, count) with buf = NULL can be valid when dumping the firmware of a microcontroller with internal flash mapped to address 0x0.

SPIFFS_write(&spi_fs, fd, 0x0, firmware_size) would previously omit the first page when dumping the firmware to flash (all 0xFF).

Visualization of the problem:

first page missing

Use len instead to signal where only page header is stored in spiffs_page_allocate_data.

@christianeisendle
Copy link

My 2 cents on this: If NULL points on a specific platform to a valid address, then the defintion for NULL should be changed instead removing NULL pointer checks from code.

@benpicco
Copy link
Contributor Author

benpicco commented Mar 1, 2017

Well it's not really a NULL pointer check in this case rather than the use of the NULL parameter for in-band signalling. It's just as valid to use the len parameter for in-band signaling here without breaking this use-case.

SPIFFS_write(&spi_fs, fd, buf, count) with buf = 0x0 can be valid when dumping the firmware of the microcontroller mapped to address 0x0.

SPIFFS_write(&spi_fs, fd, 0x0, firmware_size) would previously omit the first page when dumping the firmware to flash (all 0xFF).

Use len instead to signal where only page header is stored in spiffs_page_allocate_data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants