Skip to content

Commit 4a6e5a9

Browse files
committed
Merge pull request #1644 from pguyot/w18/fix-spi-driver-error-result
Fix error result in esp32 spi_driver Also replace 3 with TUPLE_SIZE(2) for clarity These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
2 parents 369ff35 + 54d6221 commit 4a6e5a9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/platforms/esp32/components/avm_builtins/gpio_driver.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ static NativeHandlerResult consume_gpio_mailbox(Context *ctx)
630630
}
631631

632632
term ret_msg;
633-
if (UNLIKELY(memory_ensure_free_with_roots(ctx, 3, 1, &ret, MEMORY_CAN_SHRINK) != MEMORY_GC_OK)) {
633+
if (UNLIKELY(memory_ensure_free_with_roots(ctx, TUPLE_SIZE(2), 1, &ret, MEMORY_CAN_SHRINK) != MEMORY_GC_OK)) {
634634
ret_msg = OUT_OF_MEMORY_ATOM;
635635
} else {
636636
ret_msg = create_pair(ctx, gen_message.ref, ret);

src/platforms/esp32/components/avm_builtins/spi_driver.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -655,14 +655,14 @@ static NativeHandlerResult spidriver_consume_mailbox(Context *ctx)
655655
default:
656656
TRACE("spi: error: unrecognized command.\n");
657657
if (UNLIKELY(memory_ensure_free(ctx, TUPLE_SIZE(2)) != MEMORY_GC_OK)) {
658-
return OUT_OF_MEMORY_ATOM;
658+
ret = OUT_OF_MEMORY_ATOM;
659659
}
660660
term unkn_a = globalcontext_make_atom(ctx->global, ATOM_STR("\xF", "unknown_command"));
661-
return create_pair(ctx, ERROR_ATOM, esp_err_to_term(ctx->global, unkn_a));
661+
ret = create_pair(ctx, ERROR_ATOM, esp_err_to_term(ctx->global, unkn_a));
662662
}
663663

664664
term ret_msg;
665-
if (UNLIKELY(memory_ensure_free_with_roots(ctx, 3, 1, &ret, MEMORY_CAN_SHRINK) != MEMORY_GC_OK)) {
665+
if (UNLIKELY(memory_ensure_free_with_roots(ctx, TUPLE_SIZE(2), 1, &ret, MEMORY_CAN_SHRINK) != MEMORY_GC_OK)) {
666666
ret_msg = OUT_OF_MEMORY_ATOM;
667667
} else {
668668
ret_msg = create_pair(ctx, gen_message.ref, ret);

0 commit comments

Comments
 (0)