Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1542712

[PATCH] x86-64: Fix gcc-7 warning in relocs.c

From Markus Trippelsdorf <markus@trippelsdorf.de>
Newsgroups linux.kernel
Subject [PATCH] x86-64: Fix gcc-7 warning in relocs.c
Date 2016-12-15 14:00 +0100
Message-ID <sODNE-5R6-11@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


gcc-7 warns:

In file included from arch/x86/tools/relocs_64.c:17:0:
arch/x86/tools/relocs.c: In function ‘process_64’:
arch/x86/tools/relocs.c:953:2: warning: argument 1 null where non-null expected [-Wnonnull]
  qsort(r->offset, r->count, sizeof(r->offset[0]), cmp_relocs);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from arch/x86/tools/relocs.h:6:0,
                 from arch/x86/tools/relocs_64.c:1:
/usr/include/stdlib.h:741:13: note: in a call to function ‘qsort’ declared here         
 extern void qsort 

This happens because relocs16 is not used for ELF_BITS == 64, 
so there is no point in trying to sort it.
Fixed by guarding the sort_relocs(&relocs16) call.

Signed-off-by: Markus Trippelsdorf <markus@trippelsdorf.de>

diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
index 0c2fae8d929d..73eb7fd4aec4 100644
--- a/arch/x86/tools/relocs.c
+++ b/arch/x86/tools/relocs.c
@@ -992,11 +992,12 @@ static void emit_relocs(int as_text, int use_real_mode)
 		die("Segment relocations found but --realmode not specified\n");
 
 	/* Order the relocations for more efficient processing */
-	sort_relocs(&relocs16);
 	sort_relocs(&relocs32);
 #if ELF_BITS == 64
 	sort_relocs(&relocs32neg);
 	sort_relocs(&relocs64);
+#else
+	sort_relocs(&relocs16);
 #endif
 
 	/* Print the relocations */
-- 
Markus

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] x86-64: Fix gcc-7 warning in relocs.c Markus Trippelsdorf <markus@trippelsdorf.de> - 2016-12-15 14:00 +0100
  [tip:x86/urgent] x86/tools: Fix gcc-7 warning in relocs.c tip-bot for Markus Trippelsdorf <tipbot@zytor.com> - 2016-12-19 12:00 +0100
    Re: [tip:x86/urgent] x86/tools: Fix gcc-7 warning in relocs.c "H. Peter Anvin" <hpa@zytor.com> - 2016-12-20 10:40 +0100
      Re: [tip:x86/urgent] x86/tools: Fix gcc-7 warning in relocs.c Markus Trippelsdorf <markus@trippelsdorf.de> - 2016-12-20 11:10 +0100
        Re: [tip:x86/urgent] x86/tools: Fix gcc-7 warning in relocs.c "H. Peter Anvin" <hpa@zytor.com> - 2016-12-20 12:20 +0100
          Re: [tip:x86/urgent] x86/tools: Fix gcc-7 warning in relocs.c Markus Trippelsdorf <markus@trippelsdorf.de> - 2016-12-20 13:00 +0100
            Re: [tip:x86/urgent] x86/tools: Fix gcc-7 warning in relocs.c hpa@zytor.com - 2016-12-20 19:40 +0100
              Re: [tip:x86/urgent] x86/tools: Fix gcc-7 warning in relocs.c Markus Trippelsdorf <markus@trippelsdorf.de> - 2016-12-20 20:40 +0100
                Re: [tip:x86/urgent] x86/tools: Fix gcc-7 warning in relocs.c "H. Peter Anvin" <hpa@zytor.com> - 2016-12-20 22:20 +0100

csiph-web