From de1288deee7dd0ad9e603dc5c0e430d5d654986f Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 13 Nov 2022 09:44:36 -0800 Subject: [PATCH] cgraph: squash some -Wconversion warnings This squashes the following warnings on CentOS 7 where the compiler believes the sequence ID may overflow: node.c: In function 'agnodebefore': node.c:370:23: warning: conversion to 'unsigned int:28' from 'int' may alter its value [-Wconversion] AGSEQ(n) = AGSEQ(n) + 1; ^ node.c:376:26: warning: conversion to 'unsigned int:28' from 'int' may alter its value [-Wconversion] AGSEQ(snd) = AGSEQ(fst) - 1; ^ --- lib/cgraph/node.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/cgraph/node.c b/lib/cgraph/node.c index f72970e21..f6ca59bb0 100644 --- a/lib/cgraph/node.c +++ b/lib/cgraph/node.c @@ -367,13 +367,16 @@ int agnodebefore(Agnode_t *fst, Agnode_t *snd) do { nxt = agprvnode(g,n); if (agapply (g, (Agobj_t *) n, (agobjfn_t) agnodesetfinger, n, FALSE) != SUCCESS) return FAILURE; - AGSEQ(n) = AGSEQ(n) + 1; + uint64_t seq = AGSEQ(n) + 1; + assert((seq & SEQ_MASK) == seq && "sequence ID overflow"); + AGSEQ(n) = seq & SEQ_MASK; if (agapply (g, (Agobj_t *) n, (agobjfn_t) agnoderenew, n, FALSE) != SUCCESS) return FAILURE; if (n == fst) break; n = nxt; } while (n); if (agapply (g, (Agobj_t *) snd, (agobjfn_t) agnodesetfinger, n, FALSE) != SUCCESS) return FAILURE; - AGSEQ(snd) = AGSEQ(fst) - 1; + assert(AGSEQ(fst) != 0 && "sequence ID overflow"); + AGSEQ(snd) = (AGSEQ(fst) - 1) & SEQ_MASK; if (agapply (g, (Agobj_t *) snd, (agobjfn_t) agnoderenew, snd, FALSE) != SUCCESS) return FAILURE; return SUCCESS; } -- 2.40.0