From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NelsondeMBP.localdomain (114-25-54-207.dynamic-ip.hinet.net [114.25.54.207]) by sourceware.org (Postfix) with ESMTP id 274BE385D0FD for ; Thu, 27 Oct 2022 08:48:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 274BE385D0FD Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=NelsondeMBP.localdomain Received: by NelsondeMBP.localdomain (Postfix, from userid 501) id 6197837488F; Thu, 27 Oct 2022 16:48:22 +0800 (CST) From: Nelson Chu 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 Message-Id: <20221027084808.37252-1-nelson@rivosinc.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,KHOP_HELO_FCRDNS,NO_DNS_FOR_FROM,PDS_RDNS_DYNAMIC_FP,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_PBL,RCVD_IN_SORBS_DUL,RDNS_DYNAMIC,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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)