From 53b229770199e197d6482a96710650a55609afe1 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 6 May 2020 22:29:46 +0200 Subject: [PATCH] ndisc: avoid static analysis complaining about overflow check in receive_ra() lgtm.com flags this. The check was there to be better safe than sorry. Also, it seems better to have code that shows what happens instead of a verbose code comment (or no comment at all). Anyway, avoid the false positive. --- src/ndisc/nm-lndp-ndisc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ndisc/nm-lndp-ndisc.c b/src/ndisc/nm-lndp-ndisc.c index b698489c0d..cff3db827b 100644 --- a/src/ndisc/nm-lndp-ndisc.c +++ b/src/ndisc/nm-lndp-ndisc.c @@ -179,9 +179,9 @@ receive_ra (struct ndp *ndp, struct ndp_msg *msg, gpointer user_data) */ #define NM_NDISC_VLTIME_MULT ((guint32) 48) clamp_pltime = ndp_msgra_router_lifetime (msgra); - clamp_vltime = (clamp_pltime < G_MAXUINT32 / NM_NDISC_VLTIME_MULT) - ? clamp_pltime * NM_NDISC_VLTIME_MULT - : G_MAXUINT32; + + /* clamp_pltime has at most 16 bit set, and multiplication cannot overflow. */ + clamp_vltime = clamp_pltime * NM_NDISC_VLTIME_MULT; ndp_msg_opt_for_each_offset (offset, msg, NDP_MSG_OPT_PREFIX) { guint8 r_plen;