MCUs: update deprecated use of term_from_int32#2241
MCUs: update deprecated use of term_from_int32#2241UncleGrumpy wants to merge 7 commits intoatomvm:release-0.7from
Conversation
90bf284 to
0bd3c10
Compare
There was a problem hiding this comment.
All values encoded in adc_driver.c with term_from_int28 are 17 bits or less.
0bd3c10 to
793c199
Compare
| err_t delete_res = netconn_delete(socket_data->conn); | ||
|
|
||
| socket_data->conn = NULL; | ||
| struct ESP32PlatformData *platform = ctx->global->platform_data; |
There was a problem hiding this comment.
Could we, as a bonus, handle the warning here?
There was a problem hiding this comment.
It looks like there may be a bug around there:
struct ESP32PlatformData *platform = ctx->global->platform_data;
synclist_remove(&platform->sockets, &socket_data->sockets_head);
It appears that struct ESP32PlatformData *platform is intended to be used. The same pattern emits a warning at lines 675-676. Is this warning just a false positive?
There was a problem hiding this comment.
If SMP is disabled, platform is unused.
There was a problem hiding this comment.
I understand now, thanks for the clarification.
| term_set_map_assoc(ret, 1, globalcontext_make_atom(glb, features_atom), get_features(ctx, info.features)); | ||
| term_set_map_assoc(ret, 2, globalcontext_make_atom(glb, model_atom), get_model(ctx, info.model)); | ||
| term_set_map_assoc(ret, 3, globalcontext_make_atom(glb, revision_atom), term_from_int32(info.revision)); | ||
| term_set_map_assoc(ret, 3, globalcontext_make_atom(glb, revision_atom), term_from_int11(info.revision)); |
There was a problem hiding this comment.
Let's add something like:
_Static_assert(SOC_CPU_CORES_NUM <= 7, "core count may exceed term_from_int4 range");
_Static_assert(CONFIG_ESP_REV_MAX_FULL <= 1023, "chip revision may not fit in term_from_int11");
There was a problem hiding this comment.
Great idea, it will likely be many years (if ever) before these need to be updated, and this could end up slipping past unnoticed.
793c199 to
4bb7414
Compare
|
Know this extends the scope - but the last remaining is below: Remaining
|
064164e to
2dcde17
Compare
Update the use of deprecated `term_from_int32` to `term_from_int11` for encoding gpio pin values. The values will fit in an int4, but the type is uint16_t, so `term_to_int11` is used for correctness. Signed-off-by: Winford <winford@object.stream>
Change all uses of the `term_from_int32` to `term_from_int11`, which is of adequate size to contain all of the encoded terms. Signed-off-by: Winford <winford@object.stream>
Replace use of `term_from_int32` other safe term_from_int* variants. Signed-off-by: Winford <winford@object.stream>
Updates use of deprecated `term_from_int32` to `term_from_int` when encoding the `send_timeout_ms` value. Signed-off-by: Winford <winford@object.stream>
Update the use of `term_from_int32` to encode `port` (`u16_t`) values to the new `term_from_int28`. Signed-off-by: Winford <winford@object.stream>
Update the use of deprecated `term_from_int32` to `term_from_int11` for encoding gpio pin values. The 11-bit value is more than enough to allow for the number of pins available on any ESP32 for many years. Signed-off-by: Winford <winford@object.stream>
Update deprecated `term_from_int32` to use `term_from_int28`. See also: atomvm#1897 Signed-off-by: Winford <winford@object.stream>
2dcde17 to
9d2a026
Compare
|
This should take care of all of the remaining uses of |
Update all MCU platforms useage of
term_from_int32to safer variants ofterm_from_int*See also: #1897
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