]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
conf: cast subtraction operands in source comparison
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 11 Sep 2023 13:58:17 +0000 (15:58 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 12 Sep 2023 06:03:23 +0000 (08:03 +0200)
Cast the values to int to not break the sorting in case they are changed
to unsigned types.

conf.c

diff --git a/conf.c b/conf.c
index 4c1d2e904781bd1652d363699c3bfb0bd0b860d1..5d2ba15a4271070871971b80b4c5bbf2183afbbb 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -1660,11 +1660,11 @@ compare_sources(const void *a, const void *b)
     return 1;
   if ((d = strcmp(sa->params.name, sb->params.name)) != 0)
     return d;
-  if ((d = (int)(sa->type) - (int)(sb->type)) != 0)
+  if ((d = (int)sa->type - (int)sb->type) != 0)
     return d;
-  if ((d = sa->pool - sb->pool) != 0)
+  if ((d = (int)sa->pool - (int)sb->pool) != 0)
     return d;
-  if ((d = sa->params.port - sb->params.port) != 0)
+  if ((d = (int)sa->params.port - (int)sb->params.port) != 0)
     return d;
   return memcmp(&sa->params.params, &sb->params.params, sizeof (sa->params.params));
 }