From 212dbd3c653edfa4839f67023dfd556fe192d9f0 Mon Sep 17 00:00:00 2001 From: Pete Skeggs Date: Thu, 2 Jan 2025 13:18:07 -0800 Subject: [PATCH] net: lib: nrf_cloud: Add comment for AGNSS Add a comment to explain how a tricky part of nrf_cloud_agnss_process() works. This comment is meant to explain a false positive error found by static analysis. Jira: IRIS-9985 Signed-off-by: Pete Skeggs --- subsys/net/lib/nrf_cloud/src/nrf_cloud_agnss.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/subsys/net/lib/nrf_cloud/src/nrf_cloud_agnss.c b/subsys/net/lib/nrf_cloud/src/nrf_cloud_agnss.c index a92ba81fc1b2..72ca2ed99d8c 100644 --- a/subsys/net/lib/nrf_cloud/src/nrf_cloud_agnss.c +++ b/subsys/net/lib/nrf_cloud/src/nrf_cloud_agnss.c @@ -619,6 +619,23 @@ int nrf_cloud_agnss_process(const char *buf, size_t buf_len) LOG_DBG("Parsed_len: %d", parsed_len); + /** + * The else clause below was incorrectly flagged by Coverity as a copy of + * overlapped memory bug. + * + * This is by design. The cloud will transmit 0 or more, up to 32, + * nrf_cloud_agnss_tow_element structs, which will be copied into the local + * sys_time struct's sv_tow array. The cloud side does this to conserve data + * bandwidth, as quite often there are few if any TOW elements. + * + * In the same data buffer, there will be exactly one + * nrf_cloud_agnss_system_time element struct (the first 12 bytes only), + * which will then be copied into the local sys_time struct before the + * sv_tow array. + * + * This locally-assembled sys_time struct will then be passed to + * agnss_send_to_modem(), which expects this combined structure. + */ if (element.type == NRF_CLOUD_AGNSS_GPS_TOWS) { memcpy(&sys_time.sv_tow[element.tow->sv_id - 1], element.tow,