public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nelson Chu <nelson@rivosinc.com>
To: binutils@sourceware.org
Cc: nelson@rivosinc.com
Subject: [committed] RISC-V: Fix build failures for -Werror=sign-compare.
Date: Thu, 27 Oct 2022 16:48:08 +0800	[thread overview]
Message-ID: <20221027084808.37252-1-nelson@rivosinc.com> (raw)

elfnn-riscv.c: In function ‘riscv_relax_resolve_delete_relocs’:
elfnn-riscv.c:4256:30: error: operand of ‘?:’ changes signedness from ‘int’ to ‘unsigned int’ due to unsignedness of other operand [-Werror=sign-compare]

So make the operands unsigned could resolve problem.

bfd/
    * elfnn-riscv.c (riscv_relax_resolve_delete_relocs): Fixed build
    failures for -Werror=sign-compare.
---
 bfd/elfnn-riscv.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index cf852636c9c..0570a971b5a 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -4239,7 +4239,10 @@ riscv_relax_resolve_delete_relocs (bfd *abfd,
 	  rel_next = relocs + i;
 	  if (ELFNN_R_TYPE ((rel_next)->r_info) == R_RISCV_DELETE
 	      && (rel_next)->r_offset > rel->r_offset)
-	    break;
+	    {
+	      BFD_ASSERT (rel_next - rel > 0);
+	      break;
+	    }
 	  else
 	    rel_next = NULL;
 	}
@@ -4253,7 +4256,8 @@ riscv_relax_resolve_delete_relocs (bfd *abfd,
       rel->r_info = ELFNN_R_INFO (0, R_RISCV_NONE);
 
       /* Skip ahead to the next delete reloc.  */
-      i = rel_next != NULL ? rel_next - relocs - 1 : sec->reloc_count;
+      i = rel_next != NULL ? (unsigned int) (rel_next - relocs - 1)
+			   : sec->reloc_count;
     }
 
   return true;
-- 
2.37.0 (Apple Git-136)


                 reply	other threads:[~2022-10-27  8:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221027084808.37252-1-nelson@rivosinc.com \
    --to=nelson@rivosinc.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).