]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Use CMP() in _trunk_connection_order_by_shortest_queue() (#4205)
authorJames Jones <jejones3141@gmail.com>
Tue, 24 Aug 2021 12:50:44 +0000 (07:50 -0500)
committerGitHub <noreply@github.com>
Tue, 24 Aug 2021 12:50:44 +0000 (07:50 -0500)
src/lib/server/trunk.c

index c0d56adbfc6faa966efb35789f1aa4d6268510a0..8806ffef0fc46a2545ff181d476cc7fbf6bfffa1 100644 (file)
@@ -4455,15 +4455,12 @@ int fr_trunk_connection_manage_schedule(fr_trunk_t *trunk)
  */
 static int8_t _trunk_connection_order_by_shortest_queue(void const *one, void const *two)
 {
-       fr_trunk_connection_t   const *a = talloc_get_type_abort_const(one, fr_trunk_connection_t);
-       fr_trunk_connection_t   const *b = talloc_get_type_abort_const(two, fr_trunk_connection_t);
+       fr_trunk_connection_t const     *a = talloc_get_type_abort_const(one, fr_trunk_connection_t);
+       fr_trunk_connection_t const     *b = talloc_get_type_abort_const(two, fr_trunk_connection_t);
+       uint32_t                        a_count = fr_trunk_request_count_by_connection(a, FR_TRUNK_REQUEST_STATE_ALL);
+       uint32_t                        b_count = fr_trunk_request_count_by_connection(b, FR_TRUNK_REQUEST_STATE_ALL);
 
-       if (fr_trunk_request_count_by_connection(a, FR_TRUNK_REQUEST_STATE_ALL) >
-           fr_trunk_request_count_by_connection(b, FR_TRUNK_REQUEST_STATE_ALL)) return +1;
-       if (fr_trunk_request_count_by_connection(a, FR_TRUNK_REQUEST_STATE_ALL) <
-           fr_trunk_request_count_by_connection(b, FR_TRUNK_REQUEST_STATE_ALL)) return -1;
-
-       return 0;
+       return CMP(a_count, b_count);
 }
 
 /** Free a trunk, gracefully closing all connections.