Fix -Wuninitialized-const-pointer warnings in shell route
and tcp commands, that are generated, if a unitialized
variable of type struct net_sockaddr_storage is passed to
net_sad() function.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Packets allocated by another L2 do not have the Ethernet header
headroom reserved by ethernet_l2_alloc().
Use a separate header fragment when a forwarded packet cannot
accommodate the reserved Ethernet header in its first fragment.
Assisted-by: Codex:GPT-5
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
net_context_packet_received() and net_context_raw_packet_received()
resolved the owning context of a connection with find_context(), a
linear scan of the whole contexts[] array comparing conn_handler
pointers, executed for every delivered UDP/RAW datagram.
The connection layer already stores the owning context in
conn->context (set at net_conn_register() time), so use it directly and
keep the exact validity checks the scan performed: the context must be
in use and the connection must still be its current handler.
With the default CONFIG_NET_MAX_CONTEXTS=6 this saves a measured 10
instructions per received datagram (callgrind, native_sim loopback);
the win grows linearly with CONFIG_NET_MAX_CONTEXTS on larger systems,
and the RX fast path no longer depends on the context table size.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
zsock_sendto_ctx() called net_context_recv() before every datagram or
stream send to (re-)register zsock_received_cb. After the first
registration this is a no-op: it takes the context lock, re-runs
bind_default(), rewrites the callback pointers and re-copies the
local/remote sockaddrs into the connection table entry on every single
send() call.
The registration parameters can only change via bind(), connect() or
accept(), and those paths already (re-)register the callback themselves.
Skip the per-send call when zsock_received_cb is already registered and
a connection handler exists. Offloaded contexts never set conn_handler
and therefore keep the previous per-send behaviour.
Measured with callgrind on native_sim/native/64 (UDP loopback, 32-byte
datagrams): zsock_sendto_ctx() drops from 9955 to 9523 instructions per
call (-4.3%), removing one context mutex lock/unlock pair and one
connection-table update per send.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
A Sync waiting for its transmit timestamp is stranded when the port that
was to produce it goes down or stops being capable: the sync send state
machine is left in SEND_FUP waiting for a timestamp that never comes. The
reset path returns without releasing the held Sync or its registered
timestamp callback, so the packet reference is dropped on the floor at
the next SEND_SYNC, which loses a packet and its buffers from the pool
for good, and the stale callback keeps pointing at a packet that is never
transmitted again, leaving no later Sync timestamped.
Unregister the timestamp callback through the new
gptp_sync_timestamp_cb_unregister(), then release the pending Sync. The
callback is removed first so a timestamp delivered in between cannot
match a packet whose reference was already dropped. The next Sync then
registers a callback of its own.
Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
net_pkt_unref() already returns early for a NULL packet, so passing
NULL is a harmless no-op. In debug builds it also logged an error
line for that case, which pushed callers to add their own NULL check
just to keep the log quiet. That check duplicates the early return
and the log no longer serves a purpose.
Remove the log so a NULL argument is ignored silently and callers do
not need to guard the call.
Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
After the changes to the RX transfer path, there is a pool per instance
for the RX path and OUT transfers. The existing bulk endpoints pool and
relevant Kconfig options are limited to the bulk IN endpoint. Update
their descriptions.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Instead of storing RX data in ring_buf and copying it, store it in
k_fifo of net_bufs allocated from per instance buf pool.
Signed-off-by: Antoni Duda <antoni.duda@nordicsemi.no>
When there was a networking error in the s_http_start function,
the hawkbit state would change to terminate, and the s_http_end function
would run, freeing any k_malloc memory. But because there was no return
statement, the function would proceed to allocate memory, which would
not get freed because the state was already terminate which does not
have a cleanup exit function assigned.
Signed-off-by: Avary Higbee <avary.higbee@lvt.com>
Move channel state transition to config rsp sent callback to ensure
the response is actually transmitted before marking the channel as
connected. Previously, the state was updated with connected state and
the channel `connected` will also be involved immediately after queuing
the response. In the callback `connected`, the packets will be sent by
the upper layer profiles to the sending queue immediately. Because the
config RSP and the upper-layer profile send data through different
channels, the host cannot guarantee that these packets are sent in the
order of the sending function calls. Therefore, it is possible that
profile packets may precede config RSP packets on the HCI bus.
This change introduces `l2cap_br_config_rsp_sent_cb()` to handle the
`L2CAP_FLAG_CONN_RCONF_DONE` flag and state transition only after the
config response is successfully sent. Error responses continue to use
the non-callback send path as they don't affect channel state.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
as we already check device_is_ready in net_if_up and
the iface admin state will not be up if the device is not
ready, we don't need to check in update_operational_state
directly after checking the admin state.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Even if the L2 does not support enable, we
still want that a iface can not be up if
the device is not ready.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Replace programming error checking with runtime assertions in
`mce_mns_accept()` and `mse_mas_accept()` functions. The instance
and callback validation checks are converted to `__ASSERT()` calls
since these conditions indicate programming errors rather than
runtime failures.
Initialize mce_mns and mse_mas to NULL to ensure the assertions can
properly detect uninitialized instances passed from the accept
callbacks.
The change aligns with the error handling approach used in the GOEP
layers' accept callbacks, treating invalid instance parameters and
initialization failures as programming errors that should be caught
during development.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Replace programming error checking with runtime assertions in
`bip_rfcomm_accept()` and `bip_l2cap_accept()` functions. The bip
instance validation is converted to `__ASSERT()` calls since a NULL
instance indicates a programming error in the upper layer's accept
callback implementation rather than a runtime failure.
Initialize bip to NULL to ensure the assertion can properly detect
uninitialized instances passed from the accept callbacks.
The change aligns with the error handling approach used in the GOEP
layers' accept callbacks, treating invalid instance parameters as
programming errors that should be caught during development.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Replace programming errors with runtime assertions in
`pbap_pse_rfcomm_accept()` and `pbap_pse_l2cap_accept()` functions.
The pbap_pse instance validation is converted to `__ASSERT()` calls
since a NULL instance indicates a programming error in the upper
layer's accept callback implementation.
Initialize pbap_pse to NULL to ensure the assertion can properly
detect uninitialized instances passed from the accept callbacks.
The change aligns with the error handling approach used in the GOEP
layer's accept callbacks, treating invalid instance parameters as
programming errors that should be caught during development.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
In original implementation, there is a corner case that the instance
has been allocated by upper layer and passed it through `accept()`
callbacks. And normally the allocated instance will be destroyed after
the connection broken. While in the post-accept, due to some errors,
it is possible that the connection may not be accepted by
`goep_rfcomm_accept()` or `goep_l2cap_accept()` functions. And all of
these errors are programming errors.
Replace programming error checking with runtime assertions in
`goep_rfcomm_accept()` and `goep_l2cap_accept()` functions. The
parameter validation and initialization error checks are converted to
`__ASSERT()` calls since these conditions indicate programming errors
rather than runtime failures.
The change is used to treat invalid instance parameters as programming
errors that should be caught during development.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
The `goep_rfcomm_init()` and `goep_l2cap_init()` functions are used
internally during transport setup, and their error conditions
represent programming errors.
Convert both initialization functions from returning error codes to
using runtime assertions.
The change treats transport initialization failures as programming
errors that should be caught during development.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
The function `bt_obex_reg_transport()` is used internally by the
Bluetooth Classic Host, and its parameter should not be NULL unless
there is a programming error.
Convert `bt_obex_reg_transport()` from returning error codes to using
runtime assertions. Replace if-condition NULL pointer checks with
`__ASSERT()` to catch invalid parameters during development.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Replace direct NVIC_SetPendingIRQ()/NVIC_ClearPendingIRQ() calls with
k_irq_set_pending()/k_irq_clear_pending(), dropping the dependency on
cmsis_core.h where nothing else needed it. These platforms are
plain-NVIC Cortex-M, so the pending-state capabilities are always
available where this code builds.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Remove ZTEST_SHUFFLE_SUITE_REPEAT_COUNT and
ZTEST_SHUFFLE_TEST_REPEAT_COUNT, deprecated in Zephyr 4.0 when
ZTEST_REPEAT introduced the generic ZTEST_SUITE_REPEAT_COUNT and
ZTEST_TEST_REPEAT_COUNT options.
ZTEST_SHUFFLE now only controls ordering: a shuffled run executes each
suite and test once unless ZTEST_REPEAT is enabled, whereas the removed
options used to imply three iterations of each. No in-tree test sets
either option.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
coredump_mem_window_backend_start() unconditionally force-seized debug
slot 1 for ADSP_DW_SLOT_TELEMETRY, even when telemetry_init() had
already been assigned a different slot by the dynamic debug slot
manager. This could leave two descriptors of type
ADSP_DW_SLOT_TELEMETRY around, with the host possibly reading the
stale one instead of the slot the coredump was actually written to.
Try adsp_dw_request_slot() first so the coredump reuses the slot
telemetry already owns, if any, and only fall back to forcibly
seizing slot 1 (then slot 0) when no telemetry slot exists yet.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
coredump_mem_window_backend_buffer_output() only rejected a write that
starts at or past the end of the slot; it never clamped buflen itself.
A chunk that pushes mem_wptr from just below the ADSP_DW_SLOT_SIZE - 4
limit to past it therefore overruns the current debug window slot and
spills into whatever slot is physically adjacent in memory.
With the static slot layout (CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER=n)
this overrun landed in unused space past the last real slot, so it
went unnoticed. With the dynamic debug slot manager enabled, the
telemetry/coredump slot can end up placed right before another
consumer's slot (e.g. the mtrace log ring buffer), and the same
overrun corrupts that live slot instead.
Clamp buflen to the remaining space in the slot before copying so a
write can never cross into the next slot.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
For the BIS specific data configuration, we should check
stream_param->data for NULL before supplying that to memcpy,
even if stream_param->data_len == 0, as memcpy does not
support NULL pointers.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit updates the usage of ring_buf to utilize the new
put_ptr/commit/get_ptr/consume pattern instead of the traditional
claim/finish approach. This change is part of a larger refactor aimed at
streamlining the ring_buf API and improving its efficiency.
Signed-off-by: Måns Ansgariusson <mansgariusson@gmail.com>
The check was comparing `rank` to `rank`, rather than
the minimum and maxmimum values of rank.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
BT_MESH_IVU_HOURS is BT_MESH_IVU_MIN_HOURS divided by
CONFIG_BT_MESH_IVU_DIVIDER with integer truncation, so the step by
which bt_mesh.ivu_duration grows need not divide 96. For dividers 5,
7, 9, 10, 13, 17, 18 and 19 the step is 19, 13, 10, 9, 7, 5, 5 and
5, and the duration steps over the 96 hour boundary without landing
on it. The old exact-multiple test then never flushed the beacon
cache, so a beacon refused because of the limit stayed cached, every
identical retransmission was dropped as a duplicate, and the node
never ran IV Update or IV Index Recovery once the limit expired.
Assisted-by: GitHub Copilot:claude-opus-5
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
bt_mesh_iv_update_test() lifts the 96-hour dwell time of the IV Update
procedure, but left the Secure Network beacon cache untouched. A
beacon that arrives while the limit is in force is cached by
net_beacon_resolve() and only then refused, so every identical
retransmission is filtered as a duplicate and the IV Update never
happens.
ivu_refresh() already clears the cache when the limit expires in
normal operation. Test mode lifts it without the timer running, so
apply the same invalidation there. Caching stays independent of test
mode, as required by MshPRT v1.1.1, section 3.11.5.1.
Assisted-by: GitHub Copilot:claude-opus-5
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
hfp_hf_disconnected() cancels hf->work and hf->deferred_work, but not
hf->slc_work, which is submitted to the system work queue both from
hfp_hf_connected() and from the SDP discovery callback. Once the
object has been marked as free (hf->acl == NULL), hfp_hf_create()
wipes the whole object with memset() when the slot is reused. Wiping a
work item that is still queued corrupts the work queue's pending list.
Additionally, an ongoing SDP discovery cannot be canceled
(bt_sdp_discover_cancel() is declared but has no implementation), so
the discovery callback may fire after the RFCOMM DLC has been
disconnected and re-submit slc_work for an already released object.
Fix this by canceling slc_work in hfp_hf_disconnected(), and by making
the discovery callback check that the object has not been released by
hfp_hf_disconnected() while the discovery was still ongoing. To make
that check reliable also on the connecting path, assign hf->acl before
starting the discovery in hfp_hf_create(), since the callback may
otherwise run before the assignment and treat the object as released.
Assisted-by: Claude:claude-fable-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
The prior implementation had its own ring buffer implementation, which
relied on the claim/finish api of the ring_buf implementation.
As the ring_buf implementation is moving towards removing the claim/finish
api, this commit refactors the tracing_buffer to use the ring_buf api
directly, without relying on the trace_buffers abstraction.
Signed-off-by: Måns Ansgariusson <mansgariusson@gmail.com>
The Passkey Entry protocol carries the 6-digit passkey one bit per
confirm/random round, over exactly 20 rounds. The peripheral however
re-armed BT_SMP_CMD_PAIRING_CONFIRM in smp_pairing_random() before
checking whether the last round had been reached, so a peer was able to
keep sending confirm/random pairs indefinitely once the real passkey bits
were exhausted.
Those extra rounds also passed validation: smp->passkey is a 20-bit value
held in a uint32_t, so rounds 20 through 31 simply compared the zero bits
above the passkey. Beyond round 31 the shift in smp_send_pairing_confirm()
and sc_smp_check_confirm() exceeds the width of the promoted operand and
is undefined behaviour.
Only arm BT_SMP_CMD_PAIRING_CONFIRM when a round actually remains, so that
a 21st Pairing Confirm is rejected as an unexpected command and pairing
fails. Additionally reject a round past the last one wherever the round
counter is incremented, so it can never exceed SMP_PASSKEY_ROUNDS and the
terminating comparisons stay exact. Replace the open-coded round count
with SMP_PASSKEY_ROUNDS.
Fixes#114792
Assisted-by: Claude:claude-fable-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
The PAwR advertiser previously discarded fragmented Periodic Advertising
Response Reports, so applications never received responses that spanned
multiple HCI reports.
Add optional reassembly, guarded by the new
CONFIG_BT_PER_ADV_RSP_REASSEMBLY (disabled by default). Fragments are
buffered per advertising set and delivered to the pawr_response callback
once the COMPLETE report arrives. Buffer overflow, a fragment for a
different chain, or an RX_FAILED report resets the reassembly state.
Signed-off-by: Alex Zhou <alex.zhou@nxp.com>
The stats_name used by CONFIG_STATS must be defined if stats are
registered. CONFIG_STATS_NAMES covers individual stats, not the stats
group, which must have a name.
Letting stats_name be initializing to NULL, the stats module will hit
a NULL dereference if either stats_group_find or stats_register is
called after icbmsg has registered itself.
The issue was not found since icbmsg is the only stats module
registering itself, thus stats_register() did not need to access the
stats_name to validate no duplicates are registered on the next
call to stats_register().
Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
Remove the data race between double-tap detection and timeout
processing.
The first-tap state was accessed by both the input callback and the
delayed work handler. Store it as an atomic value and use the previous
value returned by atomic_set() to test and clear it in one operation.
Signed-off-by: gao shuai <dylangao616@outlook.com>
This commit updates the usage of ring_buf to utilize the new
put_ptr/commit/get_ptr/consume pattern instead of the traditional
claim/finish approach. This change is part of a larger refactor aimed at
streamlining the ring_buf API and improving its efficiency.
Signed-off-by: Måns Ansgariusson <mansgariusson@gmail.com>
The extended advertising reassembly timeout handler mutates the
reassembling_advertiser state, which is also read and written by the
extended advertising report processing without any locking. The report
processing runs on the Bluetooth workqueue, while the timeout handler
was scheduled with k_work_reschedule() and so ran on the system
workqueue.
This is serialized only implicitly, by cooperative scheduling: it
holds because both workqueues run at cooperative priority (the
Bluetooth subsystem clamps SYSTEM_WORKQUEUE_PRIORITY to the
cooperative range for this reason) and as long as they share a CPU.
The latter is not structural: on SMP builds cooperative threads on
different CPUs run concurrently, in which case a timeout firing
concurrently with report processing can flip the state mid-sequence,
e.g. letting a chain that should have been discarded be delivered.
Schedule the timeout on the Bluetooth workqueue instead, making the
serialization structural instead of relying on scheduler
characteristics. This also makes the non-blocking
k_work_cancel_delayable() performed by the report processing reliably
effective, as canceller and handler now share a workqueue. The
remaining reset callers (HCI reset complete, bt_finalize_init() and
scan teardown) run while no advertising reports are being processed.
This is host-internal work with no application callback, so there are
no application-visible context changes.
Assisted-by: Claude:claude-fable-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
bt_hfp_ag_connect() wipes the whole AG object with memset() when
bt_rfcomm_dlc_connect() fails. At that point the SDP discovery started
by hfp_ag_create() is still ongoing, and the embedded
ag->sdp_param._node is linked in the SDP client's request list, so the
memset() corrupts that list in place. It can also wipe a queued
ag->slc_work item, corrupting the work queue's pending list.
This is the same issue as the HF side one fixed in the preceding
commit; fix it in the same way by deferring the release of the object
to the SDP discovery callback, since an ongoing SDP discovery cannot
be canceled (bt_sdp_discover_cancel() is declared in the public header
but has no implementation).
Additionally, make the discovery callback check that the AG object has
not been released by hfp_ag_disconnected() while the discovery was
still ongoing. Since the discovery cannot be canceled, the callback
would otherwise set the DISCOVER_DONE flag and re-submit slc_work for
an already released object. To make that check reliable also on the
connecting path, assign ag->acl_conn before starting the discovery in
hfp_ag_create(), since the callback may otherwise run before the
assignment and treat the object as released.
Assisted-by: Claude:claude-fable-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
bt_hfp_hf_connect() wipes the whole HF object with memset() when
bt_rfcomm_dlc_connect() fails. At that point the SDP discovery started
by hfp_hf_create() is still ongoing, and the embedded
hf->sdp_param._node is linked in the SDP client's request list, so the
memset() corrupts that list in place. It can also wipe a queued
hf->slc_work item, corrupting the work queue's pending list.
An ongoing SDP discovery cannot be canceled (bt_sdp_discover_cancel()
is declared in the public header but has no implementation), so the
object cannot be safely torn down synchronously. Instead, keep the
object allocated and mark it with the new RELEASING flag, making the
SDP discovery callback release it once the discovery has completed,
rather than proceeding with SLC establishment. In the unlikely case
that the discovery has already completed when the RFCOMM connection
creation fails, release the object immediately.
Assisted-by: Claude:claude-fable-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
sc_save() only calls sc_store() when a bond already exists for the peer,
so a client that subscribes to Service Changed before it bonds gets an
sc_cfg entry in RAM that is never written to settings. iOS does exactly
this: it subscribes right after connecting and only pairs later, once the
user accepts the dialog.
bt_gatt_identity_resolved() does not cover it either, since its sc_store()
call is likewise conditional on the bond already existing, and identity
resolution happens during key distribution rather than after the bond has
been committed.
The result is that the subscription survives in RAM for the current
connection but is lost across a reboot, so a characteristic change made
while disconnected is never indicated and the client keeps a stale cache.
Reconnecting papers over it, because the client subscribes again and by
then the bond exists.
Store the Service Changed configuration from bt_gatt_pairing_complete(),
where the ccc and cf data is already persisted for the same reason.
Fixes: #111078
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Assisted-by: Claude:claude-opus-5
__ASSERT_PRINT() is an internal helper of <zephyr/sys/__assert.h>. The
ARM64 RNG driver called it directly to print a message before panicking on
repeated RNDR failures.
Use __ASSERT(false, ...) instead, which emits the message and takes the
assert action on assert-enabled builds; the following k_panic() keeps the
terminal behaviour unchanged.
Signed-off-by: Måns Ansgariusson <mansgariusson@gmail.com>
__ASSERT_MSG_INFO() is an internal helper of <zephyr/sys/__assert.h>, not a
public API. A handful of drivers and inline helpers called it directly to
emit a message without an accompanying assertion.
Replace those direct uses with the appropriate mechanism: LOG_ERR() for the
recoverable runtime error paths in the display, RTC, SPI and CRC code, and
__ASSERT(false, ...) for the out-of-range programming errors in the ADC and
DAC inline helpers.
Signed-off-by: Måns Ansgariusson <mansgariusson@gmail.com>
Invert the in-tree ethernet driver configuration logic.
The current logic is boards enabling `NET_L2_ETHERNET`, which then
unconditionally defaults `ETH_DRIVER` to enabled. This means that
`ETH_DRIVER` end up set for boards that use the L2 Ethernet layer but
don't have an ethernet device (see some WiFi drivers).
This commit:
* Removes the `default y if NET_L2_ETHERNET` from `ETH_DRIVER`
* Adds `default y if ETH_DRIVER` to `NET_L2_ETHERNET`
* Adds `imply ETH_DRIVER` to `NET_QEMU_ETHERNET`
* Updates in-tree ethernet boards to default `ETH_DRIVER` instead of
`NET_L2_ETHERNET`
The outcome of this PR is that Kconfig can now use `ETH_DRIVER` to
reasonably assume that an actual ethernet driver is enabled.
Conversion of in-tree boards/samples performed by GPT-5.5.
Assisted-by: GPT-5.5
Signed-off-by: Jordan Yates <jordan@embeint.com>
handle_http2_static_fs_resource() passed &client->data_len as the file_size
output of http_server_find_file(), corrupting the connection RX length and
leading to an out-of-bounds write. Use a local variable instead.
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
In reassemble_packet(), a mid-loop net_pkt_get_data() failure used the
shared error path that only unref'd the current fragment. Other packets
in the reassembly slot were left behind after the timer was cancelled,
causing a net_pkt leak and possibly use-after-free issue.
Call reassembly_cancel() on that failure path, matching the existing
net_pkt_pull() failure handling.
Signed-off-by: Swamidas Nampalli <Swami.Das@silabs.com>
Move the interface carrier state out of `modem_cellular` into
`modem_ppp`, as the PPP module is the true "carrier" for the PPP
networking interface.
Signed-off-by: Jordan Yates <jordan@embeint.com>
MISRA C:2012 Rule 8.2 requires every parameter in a function type to be
named, including the parameters of function pointer parameters.
The LLCP remote request helper, the LLL test and scan helpers and the
PSoC 6 BLESS receive thread left parameters unnamed. The BLESS thread
gets ARG_UNUSED() for the arguments it deliberately ignores.
Name them after the arguments the documentation or the
definitions already use. No functional change.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Report the error code when bt_disable() fails, including the new
-EAGAIN case where initialization has not yet completed.
Signed-off-by: Guotao Zhang <guotao.zhang@nxp.com>
When bt_enable() is called with a ready callback, bt_init() runs
asynchronously on the system workqueue. If bt_disable() is invoked
before that work item completes, it races with bt_init() over
bt_dev.sent_cmd, which can be freed twice and trigger a buf.c:472
assert.
Fix this by checking k_work_busy_get(&bt_dev.init) at the top of
bt_disable(). If init is still queued or running, return -EAGAIN so
the caller can retry once the ready callback fires.
Note: the same race can occur with a synchronous bt_enable(NULL)
called concurrently from another thread; that case will be covered
by BT_DEV_ENABLING/BT_DEV_DISABLING transition flags introduced in
a follow-up change.
Document the new -EAGAIN return code in bt_disable()'s Doxygen.
Signed-off-by: Guotao Zhang <guotao.zhang@nxp.com>
Use the correct `NET_SOCK_STREAM` constant when registering TCP
test callbacks for TTCN-3 based TCP sanity checks.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>