Skip to content

Commit b0e1e6e

Browse files
Revert "[nrf fromlist] storage/stream: allow NULL data pointer when len is 0"
This reverts commit d9b5c11. Signed-off-by: Martí Bolívar <[email protected]>
1 parent 9eb446d commit b0e1e6e

File tree

2 files changed

+1
-22
lines changed

2 files changed

+1
-22
lines changed

subsys/storage/stream/stream_flash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ int stream_flash_buffered_write(struct stream_flash_ctx *ctx, const u8_t *data,
115115
size_t fill_length;
116116
u8_t filler;
117117

118-
if (ctx == NULL || (data == NULL && len != 0)) {
118+
if (!ctx || !data) {
119119
return -EFAULT;
120120
}
121121

tests/subsys/storage/stream/stream_flash/src/main.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -306,26 +306,6 @@ static void test_stream_flash_buffered_write_callback(void)
306306
zassert_equal(rc, -EFAULT, "expected failure from callback");
307307
}
308308

309-
static void test_stream_flash_flush(void)
310-
{
311-
int rc;
312-
int num_pages = MAX_NUM_PAGES - 1;
313-
314-
init_target();
315-
316-
rc = stream_flash_buffered_write(&ctx, write_buf,
317-
(page_size * num_pages) + 128, false);
318-
zassert_equal(rc, 0, "expected success");
319-
320-
/* Perform flush with NULL data pointer and non-0 lentgth */
321-
rc = stream_flash_buffered_write(&ctx, NULL, 4, true);
322-
zassert_true(rc < 0, "expected failure");
323-
324-
/* Perform flush with NULL data pointer and 0 lentgth */
325-
rc = stream_flash_buffered_write(&ctx, NULL, 0, true);
326-
zassert_equal(rc, 0, "expected success");
327-
}
328-
329309
#ifdef CONFIG_STREAM_FLASH_ERASE
330310
static void test_stream_flash_buffered_write_whole_page(void)
331311
{
@@ -401,7 +381,6 @@ void test_main(void)
401381
ztest_unit_test(test_stream_flash_buffered_write_multi_page),
402382
ztest_unit_test(test_stream_flash_buf_size_greater_than_page_size),
403383
ztest_unit_test(test_stream_flash_buffered_write_callback),
404-
ztest_unit_test(test_stream_flash_flush),
405384
ztest_unit_test(test_stream_flash_buffered_write_whole_page),
406385
ztest_unit_test(test_stream_flash_erase_page),
407386
ztest_unit_test(test_stream_flash_bytes_written)

0 commit comments

Comments
 (0)