[binutils-gdb] libctf ctf-link.c labs?

Alan Modra via Binutils-cvs <[email protected]>
Newsgroups gmane.comp.gnu.binutils.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5aab589091ec550956873932cb15ea883763cd15

commit 5aab589091ec550956873932cb15ea883763cd15
Author: Alan Modra <[email protected]>
Date:   Wed Apr 22 08:02:54 2026 +0930

    libctf ctf-link.c labs?
    
    ctf-link.c has a labs that clang finds suspect when compiling for a
    32-bit host, warning about the signed/unsigned comparison.  (labs
    return is 32-bit signed, 0xffffffffe is 32-bit unsigned on a 32-bit
    host.)  I think the labs is bogus, apparently there because
    ctf_link_deduplicating_count_inputs returns a ssize_t rather than a
    size_t to cover error status returns.  However, the error status isn't
    a negative count but only -1.  So remove the labs.
    
            * ctf-link.c (ctf_link_deduplicating_per_cu): Avoid 32-bit
            host warning; don't use labs, cast "inputs" instead.
            Style/formatting fix.  Report "too many inputs" using %lu.

Diff:
---
 libctf/ctf-link.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libctf/ctf-link.c b/libctf/ctf-link.c
index 04c019cc85c..10bef42602d 100644
--- a/libctf/ctf-link.c
+++ b/libctf/ctf-link.c
@@ -1114,19 +1114,19 @@ ctf_link_deduplicating_per_cu (ctf_dict_t *fp)
       uint32_t noutputs;
       uint32_t *parents;
 
-      if ((ninputs = ctf_link_deduplicating_count_inputs (fp, in,
-							  &only_input)) == -1)
+      ninputs = ctf_link_deduplicating_count_inputs (fp, in, &only_input);
+      if (ninputs == -1)
 	goto err_open_inputs;
 
       /* CU mapping with no inputs?  Skip.  */
       if (ninputs == 0)
 	continue;
 
-      if (labs ((long int) ninputs) > 0xfffffffe)
+      if ((size_t) ninputs > 0xfffffffe)
 	{
 	  ctf_set_errno (fp, EFBIG);
 	  ctf_err_warn (fp, 0, 0, _("too many inputs in deduplicating "
-				    "link: %li"), (long int) ninputs);
+				    "link: %lu"), (long unsigned) ninputs);
 	  goto err_open_inputs;
 	}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.