[PATCH] debuginfod-client: Remove always-false comparisons

tbaeder@redhat.com tbaeder@redhat.com
Tue Mar 2 08:30:24 GMT 2021


From: Timm Bäder <tbaeder@redhat.com>

When comparing a long to a double, clang prints the following warning:

../../debuginfod/debuginfod-client.c:917:28: error: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Werror,-Wimplicit-int-float-conversion]
                pb = (cl > LONG_MAX ? LONG_MAX : (long)cl);
                         ~ ^~~~~~~~
/usr/lib64/clang/10.0.1/include/limits.h:47:19: note: expanded from macro 'LONG_MAX'
                  ^~~~~~~~~~~~
<built-in>:38:22: note: expanded from here
                     ^~~~~~~~~~~~~~~~~~~~
1 error generated.

However, cl and dl in are doubles and will never be greater than
LONG_MAX, so always just assign them to pa or pb.

Signed-off-by: Timm Bäder <tbaeder@redhat.com>
---
 debuginfod/debuginfod-client.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c
index de26af5b..c5f2ace5 100644
--- a/debuginfod/debuginfod-client.c
+++ b/debuginfod/debuginfod-client.c
@@ -896,7 +896,7 @@ debuginfod_query_server (debuginfod_client *c,
                                            CURLINFO_SIZE_DOWNLOAD,
                                            &dl);
               if (curl_res == 0)
-                pa = (dl > LONG_MAX ? LONG_MAX : (long)dl);
+                pa = (long)dl;
 #endif
 
               /* NB: If going through deflate-compressing proxies, this
@@ -914,7 +914,7 @@ debuginfod_query_server (debuginfod_client *c,
                                            CURLINFO_CONTENT_LENGTH_DOWNLOAD,
                                            &cl);
               if (curl_res == 0)
-                pb = (cl > LONG_MAX ? LONG_MAX : (long)cl);
+                pb = (long)cl;
 #endif
             }
 
-- 
2.26.2



More information about the Elfutils-devel mailing list