From 1f099db7e2ca978b467f0d524261af1d588d1d0a Mon Sep 17 00:00:00 2001 From: Frederic Lecaille Date: Tue, 21 Jan 2025 16:26:42 +0100 Subject: [PATCH] BUILD: quic: Move an ASSUME_NONNULL() for variable which is not null MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some new compilers warn that variable can be null even this cannot be the case as mentioned by the comment about an already present ASSUME_NONNULL() call comment as follows: src/quic_loss.c: In function ‘qc_release_lost_pkts’: src/quic_loss.c:307:86: error: potential null pointer dereference [-Werror=null-dereference] 307 | unsigned int period = newest_lost->time_sent_ms - oldest_lost->time_sent_ms; | ~~~~~~~~~~~^~~~~~~~~~~~~~ Move up this ASSUME_NONNULL() statement to please these compiler. Must be backported as far as 2.6 to easy any further backport around this code part. --- src/quic_loss.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/quic_loss.c b/src/quic_loss.c index 1c32d92c4..79b5d35b7 100644 --- a/src/quic_loss.c +++ b/src/quic_loss.c @@ -283,6 +283,12 @@ int qc_release_lost_pkts(struct quic_conn *qc, struct quic_pktns *pktns, tot_lost++; } + /* cannot be NULL at this stage because we have ensured + * that list is not empty. Without this, GCC 12.2.0 reports a + * possible overflow on a 0 byte region with O2 optimization. + */ + ASSUME_NONNULL(oldest_lost); + if (!close) { if (newest_lost) { struct quic_cc *cc = &qc->path->cc; @@ -313,11 +319,6 @@ int qc_release_lost_pkts(struct quic_conn *qc, struct quic_pktns *pktns, } } - /* cannot be NULL at this stage because we have ensured - * that list is not empty. Without this, GCC 12.2.0 reports a - * possible overflow on a 0 byte region with O2 optimization. - */ - ASSUME_NONNULL(oldest_lost); quic_tx_packet_refdec(oldest_lost); if (newest_lost != oldest_lost) quic_tx_packet_refdec(newest_lost);