kexec-tools: get kexec running on MUSL and x86 hardware
[oweals/openwrt.git] / package / boot / kexec-tools / patches / 130-dont-use-percentL.patch
1 commit f14881e87b1426d2c439e2fad9a1e03a3b35e196
2 Author: Philip Prindeville <philipp@redfish-solutions.com>
3 Date:   Fri Mar 10 19:57:11 2017 -0700
4
5     Don't use %L width specifier with integer values
6     
7     MUSL doesn't support %L except for floating-point arguments; therefore,
8     %ll must be used instead with integer arguments.
9     
10     Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
11
12 diff --git a/kexec/arch/arm/kexec-arm.c b/kexec/arch/arm/kexec-arm.c
13 index 2194b7c..49f35b1 100644
14 --- a/kexec/arch/arm/kexec-arm.c
15 +++ b/kexec/arch/arm/kexec-arm.c
16 @@ -47,7 +47,7 @@ int get_memory_ranges(struct memory_range **range, int *ranges,
17                 int count;
18                 if (memory_ranges >= MAX_MEMORY_RANGES)
19                         break;
20 -               count = sscanf(line, "%Lx-%Lx : %n",
21 +               count = sscanf(line, "%llx-%llx : %n",
22                         &start, &end, &consumed);
23                 if (count != 2)
24                         continue;
25 diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
26 index c4cf201..285dea9 100644
27 --- a/kexec/arch/i386/crashdump-x86.c
28 +++ b/kexec/arch/i386/crashdump-x86.c
29 @@ -119,7 +119,7 @@ static unsigned long long get_kernel_sym(const char *symbol)
30         }
31  
32         while(fgets(line, sizeof(line), fp) != NULL) {
33 -               if (sscanf(line, "%Lx %c %s", &vaddr, &type, sym) != 3)
34 +               if (sscanf(line, "%llx %c %s", &vaddr, &type, sym) != 3)
35                         continue;
36                 if (strcmp(sym, symbol) == 0) {
37                         dbgprintf("kernel symbol %s vaddr = %16llx\n", symbol, vaddr);
38 @@ -296,12 +296,12 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
39  
40                 if (memory_ranges >= CRASH_MAX_MEMORY_RANGES)
41                         break;
42 -               count = sscanf(line, "%Lx-%Lx : %n",
43 +               count = sscanf(line, "%llx-%llx : %n",
44                         &start, &end, &consumed);
45                 if (count != 2)
46                         continue;
47                 str = line + consumed;
48 -               dbgprintf("%016Lx-%016Lx : %s",
49 +               dbgprintf("%016llx-%016llx : %s",
50                         start, end, str);
51                 /* Only Dumping memory of type System RAM. */
52                 if (memcmp(str, "System RAM\n", 11) == 0) {
53 @@ -778,7 +778,7 @@ static int get_crash_notes(int cpu, uint64_t *addr, uint64_t *len)
54                 *addr = x86__pa(vaddr + (cpu * MAX_NOTE_BYTES));
55                 *len = MAX_NOTE_BYTES;
56  
57 -               dbgprintf("crash_notes addr = %Lx\n",
58 +               dbgprintf("crash_notes addr = %llx\n",
59                           (unsigned long long)*addr);
60  
61                 fclose(fp);
62 diff --git a/kexec/arch/i386/kexec-x86-common.c b/kexec/arch/i386/kexec-x86-common.c
63 index 3e97239..be03618 100644
64 --- a/kexec/arch/i386/kexec-x86-common.c
65 +++ b/kexec/arch/i386/kexec-x86-common.c
66 @@ -81,7 +81,7 @@ static int get_memory_ranges_proc_iomem(struct memory_range **range, int *ranges
67                 int count;
68                 if (memory_ranges >= MAX_MEMORY_RANGES)
69                         break;
70 -               count = sscanf(line, "%Lx-%Lx : %n",
71 +               count = sscanf(line, "%llx-%llx : %n",
72                         &start, &end, &consumed);
73                 if (count != 2)
74                         continue;
75 diff --git a/kexec/arch/ia64/kexec-elf-rel-ia64.c b/kexec/arch/ia64/kexec-elf-rel-ia64.c
76 index 7f7c08c..500f247 100644
77 --- a/kexec/arch/ia64/kexec-elf-rel-ia64.c
78 +++ b/kexec/arch/ia64/kexec-elf-rel-ia64.c
79 @@ -155,6 +155,6 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr,
80         }
81         return;
82  overflow:
83 -       die("overflow in relocation type %lu val %Lx\n", 
84 +       die("overflow in relocation type %lu val %llx\n",
85                         r_type, value);
86  }
87 diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c
88 index 9c33599..6308ec8 100644
89 --- a/kexec/arch/mips/crashdump-mips.c
90 +++ b/kexec/arch/mips/crashdump-mips.c
91 @@ -173,7 +173,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges)
92                 int type, consumed, count;
93                 if (memory_ranges >= CRASH_MAX_MEMORY_RANGES)
94                         break;
95 -               count = sscanf(line, "%Lx-%Lx : %n",
96 +               count = sscanf(line, "%llx-%llx : %n",
97                         &start, &end, &consumed);
98                 if (count != 2)
99                         continue;
100 diff --git a/kexec/arch/mips/kexec-mips.c b/kexec/arch/mips/kexec-mips.c
101 index ee3cd3a..2e5b700 100644
102 --- a/kexec/arch/mips/kexec-mips.c
103 +++ b/kexec/arch/mips/kexec-mips.c
104 @@ -48,7 +48,7 @@ int get_memory_ranges(struct memory_range **range, int *ranges,
105         while (fgets(line, sizeof(line), fp) != 0) {
106                 if (memory_ranges >= MAX_MEMORY_RANGES)
107                         break;
108 -               count = sscanf(line, "%Lx-%Lx : %n", &start, &end, &consumed);
109 +               count = sscanf(line, "%llx-%llx : %n", &start, &end, &consumed);
110                 if (count != 2)
111                         continue;
112                 str = line + consumed;
113 diff --git a/kexec/arch/s390/kexec-s390.c b/kexec/arch/s390/kexec-s390.c
114 index f863483..33ba6b9 100644
115 --- a/kexec/arch/s390/kexec-s390.c
116 +++ b/kexec/arch/s390/kexec-s390.c
117 @@ -170,7 +170,7 @@ int get_memory_ranges_s390(struct memory_range memory_range[], int *ranges,
118                 if (current_range == MAX_MEMORY_RANGES)
119                         break;
120  
121 -               sscanf(line,"%Lx-%Lx : %n", &start, &end, &cons);
122 +               sscanf(line,"%llx-%llx : %n", &start, &end, &cons);
123                 str = line+cons;
124                 if ((memcmp(str, sys_ram, strlen(sys_ram)) == 0) ||
125                     ((memcmp(str, crash_kernel, strlen(crash_kernel)) == 0) &&
126 diff --git a/kexec/crashdump.c b/kexec/crashdump.c
127 index 15c1105..0b363c5 100644
128 --- a/kexec/crashdump.c
129 +++ b/kexec/crashdump.c
130 @@ -98,7 +98,7 @@ int get_crash_notes_per_cpu(int cpu, uint64_t *addr, uint64_t *len)
131         }
132         if (!fgets(line, sizeof(line), fp))
133                 die("Cannot parse %s: %s\n", crash_notes, strerror(errno));
134 -       count = sscanf(line, "%Lx", &temp);
135 +       count = sscanf(line, "%llx", &temp);
136         if (count != 1)
137                 die("Cannot parse %s: %s\n", crash_notes, strerror(errno));
138         *addr = (uint64_t) temp;
139 @@ -112,7 +112,7 @@ int get_crash_notes_per_cpu(int cpu, uint64_t *addr, uint64_t *len)
140                 if (!fgets(line, sizeof(line), fp))
141                         die("Cannot parse %s: %s\n",
142                             crash_notes_size, strerror(errno));
143 -               count = sscanf(line, "%Lu", &temp);
144 +               count = sscanf(line, "%llu", &temp);
145                 if (count != 1)
146                         die("Cannot parse %s: %s\n",
147                             crash_notes_size, strerror(errno));
148 @@ -120,7 +120,7 @@ int get_crash_notes_per_cpu(int cpu, uint64_t *addr, uint64_t *len)
149                 fclose(fp);
150         }
151  
152 -       dbgprintf("%s: crash_notes addr = %Lx, size = %Lu\n", __FUNCTION__,
153 +       dbgprintf("%s: crash_notes addr = %llx, size = %llu\n", __FUNCTION__,
154                   (unsigned long long)*addr, (unsigned long long)*len);
155  
156         return 0;
157 @@ -141,7 +141,7 @@ static int get_vmcoreinfo(const char *kdump_info, uint64_t *addr, uint64_t *len)
158  
159         if (!fgets(line, sizeof(line), fp))
160                 die("Cannot parse %s: %s\n", kdump_info, strerror(errno));
161 -       count = sscanf(line, "%Lx %Lx", &temp, &temp2);
162 +       count = sscanf(line, "%llx %llx", &temp, &temp2);
163         if (count != 2)
164                 die("Cannot parse %s: %s\n", kdump_info, strerror(errno));
165  
166 diff --git a/kexec/kexec-iomem.c b/kexec/kexec-iomem.c
167 index 485a2e8..7ec3853 100644
168 --- a/kexec/kexec-iomem.c
169 +++ b/kexec/kexec-iomem.c
170 @@ -44,7 +44,7 @@ int kexec_iomem_for_each_line(char *match,
171                 die("Cannot open %s\n", iomem);
172  
173         while(fgets(line, sizeof(line), fp) != 0) {
174 -               count = sscanf(line, "%Lx-%Lx : %n", &start, &end, &consumed);
175 +               count = sscanf(line, "%llx-%llx : %n", &start, &end, &consumed);
176                 if (count != 2)
177                         continue;
178                 str = line + consumed;