diff options
author | Angus Gratton <angus@redyak.com.au> | 2024-02-27 15:32:29 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-03-07 14:20:42 +1100 |
commit | decf8e6a8bb940d5829ca3296790631fcece7b21 (patch) | |
tree | 55b7cd31de14b73e4b72d49344e9084f402767a9 /ports/zephyr/modbluetooth_zephyr.c | |
parent | b3f2f18f927fa2fad10daf63d8c391331f5edf58 (diff) |
all: Remove the "STATIC" macro and just use "static" instead.
The STATIC macro was introduced a very long time ago in commit
d5df6cd44a433d6253a61cb0f987835fbc06b2de. The original reason for this was
to have the option to define it to nothing so that all static functions
become global functions and therefore visible to certain debug tools, so
one could do function size comparison and other things.
This STATIC feature is rarely (if ever) used. And with the use of LTO and
heavy inline optimisation, analysing the size of individual functions when
they are not static is not a good representation of the size of code when
fully optimised.
So the macro does not have much use and it's simpler to just remove it.
Then you know exactly what it's doing. For example, newcomers don't have
to learn what the STATIC macro is and why it exists. Reading the code is
also less "loud" with a lowercase static.
One other minor point in favour of removing it, is that it stops bugs with
`STATIC inline`, which should always be `static inline`.
Methodology for this commit was:
1) git ls-files | egrep '\.[ch]$' | \
xargs sed -Ei "s/(^| )STATIC($| )/\1static\2/"
2) Do some manual cleanup in the diff by searching for the word STATIC in
comments and changing those back.
3) "git-grep STATIC docs/", manually fixed those cases.
4) "rg -t python STATIC", manually fixed codegen lines that used STATIC.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Diffstat (limited to 'ports/zephyr/modbluetooth_zephyr.c')
-rw-r--r-- | ports/zephyr/modbluetooth_zephyr.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/ports/zephyr/modbluetooth_zephyr.c b/ports/zephyr/modbluetooth_zephyr.c index 279e4ca9a..b427a6cd9 100644 --- a/ports/zephyr/modbluetooth_zephyr.c +++ b/ports/zephyr/modbluetooth_zephyr.c @@ -61,21 +61,21 @@ typedef struct _mp_bluetooth_zephyr_root_pointers_t { mp_gatts_db_t gatts_db; } mp_bluetooth_zephyr_root_pointers_t; -STATIC int mp_bluetooth_zephyr_ble_state; +static int mp_bluetooth_zephyr_ble_state; #if MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE -STATIC int mp_bluetooth_zephyr_gap_scan_state; -STATIC struct k_timer mp_bluetooth_zephyr_gap_scan_timer; -STATIC struct bt_le_scan_cb mp_bluetooth_zephyr_gap_scan_cb_struct; +static int mp_bluetooth_zephyr_gap_scan_state; +static struct k_timer mp_bluetooth_zephyr_gap_scan_timer; +static struct bt_le_scan_cb mp_bluetooth_zephyr_gap_scan_cb_struct; #endif -STATIC int bt_err_to_errno(int err) { +static int bt_err_to_errno(int err) { // Zephyr uses errno codes directly, but they are negative. return -err; } // modbluetooth (and the layers above it) work in BE for addresses, Zephyr works in LE. -STATIC void reverse_addr_byte_order(uint8_t *addr_out, const bt_addr_le_t *addr_in) { +static void reverse_addr_byte_order(uint8_t *addr_out, const bt_addr_le_t *addr_in) { for (int i = 0; i < 6; ++i) { addr_out[i] = addr_in->a.val[5 - i]; } @@ -98,12 +98,12 @@ void gap_scan_cb_recv(const struct bt_le_scan_recv_info *info, struct net_buf_si mp_bluetooth_gap_on_scan_result(info->addr->type, addr, info->adv_type, info->rssi, buf->data, buf->len); } -STATIC mp_obj_t gap_scan_stop(mp_obj_t unused) { +static mp_obj_t gap_scan_stop(mp_obj_t unused) { (void)unused; mp_bluetooth_gap_scan_stop(); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(gap_scan_stop_obj, gap_scan_stop); +static MP_DEFINE_CONST_FUN_OBJ_1(gap_scan_stop_obj, gap_scan_stop); void gap_scan_cb_timeout(struct k_timer *timer_id) { DEBUG_printf("gap_scan_cb_timeout\n"); @@ -212,7 +212,7 @@ int mp_bluetooth_gap_set_device_name(const uint8_t *buf, size_t len) { // Zephyr takes advertising/scan data as an array of (type, len, payload) packets, // and this function constructs such an array from raw advertising/scan data. -STATIC void mp_bluetooth_prepare_bt_data(const uint8_t *data, size_t len, struct bt_data *bt_data, size_t *bt_len) { +static void mp_bluetooth_prepare_bt_data(const uint8_t *data, size_t len, struct bt_data *bt_data, size_t *bt_len) { size_t i = 0; const uint8_t *d = data; while (d < data + len && i < *bt_len) { |