public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] debuginfod-client: Don't compare a double to a long
@ 2021-03-04  8:34 tbaeder
  2021-03-07 18:09 ` Frank Ch. Eigler
  0 siblings, 1 reply; 2+ messages in thread
From: tbaeder @ 2021-03-04  8:34 UTC (permalink / raw)
  To: elfutils-devel

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

clang warns about this:

../../debuginfod/debuginfod-client.c:899:28: error: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Werror,-Wimplicit-int-float-conversion]
                pa = (dl > LONG_MAX ? LONG_MAX : (long)dl);
                         ~ ^~~~~~~~
/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
                     ^~~~~~~~~~~~~~~~~~~~
../../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
                     ^~~~~~~~~~~~~~~~~~~~
---
 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..df238e07 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 = (dl > (double)LONG_MAX ? LONG_MAX : (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 = (cl > (double)LONG_MAX ? LONG_MAX : (long)cl);
 #endif
             }
 
-- 
2.26.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] debuginfod-client: Don't compare a double to a long
  2021-03-04  8:34 [PATCH] debuginfod-client: Don't compare a double to a long tbaeder
@ 2021-03-07 18:09 ` Frank Ch. Eigler
  0 siblings, 0 replies; 2+ messages in thread
From: Frank Ch. Eigler @ 2021-03-07 18:09 UTC (permalink / raw)
  To: tbaeder; +Cc: elfutils-devel

Hi -

Merged (along with Jakub's suggestions).

- FChE


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-07 18:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-04  8:34 [PATCH] debuginfod-client: Don't compare a double to a long tbaeder
2021-03-07 18:09 ` Frank Ch. Eigler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).