From 77ec6312c31dd5871c1f96450f8c6f7d892e8842 Mon Sep 17 00:00:00 2001 From: JosiahMg Date: Sun, 16 Jun 2024 19:43:58 +0800 Subject: [PATCH] the variable of the UNSIGNED INT may be negative when converting to INT --- soft_bfddpd/session.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/soft_bfddpd/session.c b/soft_bfddpd/session.c index 78853b4..79cd3c4 100644 --- a/soft_bfddpd/session.c +++ b/soft_bfddpd/session.c @@ -38,7 +38,18 @@ static int bsessions_cmp(const struct bfd_session_data *bsda, const struct bfd_session_data *bsdb) { - return (int)(bsda->bsd_bs->bs_lid - bsdb->bsd_bs->bs_lid); + if (bsda->bsd_bs->bs_lid > bsdb->bsd_bs->bs_lid) + { + return 1; + } + else if(bsda->bsd_bs->bs_lid < bsd->bsd_bs->bs_lid) + { + return -1; + } + else + { + return 0; + } } RBT_HEAD(bsessionst, bfd_session_data) bsessionst;