summaryrefslogtreecommitdiffstats
path: root/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0002-Instead-of-doing-preprocessor-magic-just-output-off_.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0002-Instead-of-doing-preprocessor-magic-just-output-off_.patch')
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0002-Instead-of-doing-preprocessor-magic-just-output-off_.patch326
1 files changed, 326 insertions, 0 deletions
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0002-Instead-of-doing-preprocessor-magic-just-output-off_.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0002-Instead-of-doing-preprocessor-magic-just-output-off_.patch
new file mode 100644
index 000000000..bb675a7be
--- /dev/null
+++ b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0002-Instead-of-doing-preprocessor-magic-just-output-off_.patch
@@ -0,0 +1,326 @@
1From 01c98d5d5d044d9a125abcdbb2f3d771966365b0 Mon Sep 17 00:00:00 2001
2From: mirabilos <m@mirbsd.org>
3Date: Thu, 1 Feb 2018 15:34:07 +0100
4Subject: [PATCH 2/4] Instead of doing preprocessor magic, just output off_t as
5 long long
6
7Fix warnings abot PRIdoff_t in libmtd.c, in mtd_read (and mtd_write):
8
9In file included from ../git/lib/libmtd.c:40:0:
10../git/lib/libmtd.c: In function 'mtd_read':
11../git/include/common.h:110:18: warning: format '%ld' expects argument of
12 type 'long int', but argument 5 has type 'off_t {aka long long int}'
13 [-Wformat=]
14
15../git/include/common.h:120:2: note: in expansion of macro 'errmsg'
16 errmsg(fmt, ##__VA_ARGS__); \
17 ^~~~~~
18../git/lib/libmtd.c:1082:10: note: in expansion of macro 'sys_errmsg'
19 return sys_errmsg("cannot seek mtd%d to offset %"PRIdoff_t,
20 ^~~~~~~~~~
21
22/usr/lib/klibc/include/inttypes.h:28:17: note: format string is defined here
23 #define PRId32 "d"
24
25Upstream-Status: Submitted
26
27Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
28---
29 include/common.h | 18 ------------------
30 jffsX-utils/mkfs.jffs2.c | 20 ++++++++++----------
31 lib/libmtd.c | 8 ++++----
32 misc-utils/flash_erase.c | 6 +++---
33 misc-utils/flash_otp_write.c | 2 +-
34 misc-utils/ftl_check.c | 2 +-
35 misc-utils/mtd_debug.c | 4 ++--
36 misc-utils/serve_image.c | 4 ++--
37 tests/fs-tests/integrity/integck.c | 4 ++--
38 tests/mtd-tests/nandpagetest.c | 4 ++--
39 tests/ubi-tests/integ.c | 6 +++---
40 ubifs-utils/mkfs.ubifs/mkfs.ubifs.c | 6 +++---
41 12 files changed, 33 insertions(+), 51 deletions(-)
42
43diff --git a/include/common.h b/include/common.h
44index f8f72ea..642c212 100644
45--- a/include/common.h
46+++ b/include/common.h
47@@ -70,24 +70,6 @@ extern "C" {
48 #define O_CLOEXEC 0
49 #endif
50
51-/* define a print format specifier for off_t */
52-#if (SIZEOF_OFF_T >= 8)
53-#define PRIxoff_t PRIx64
54-#define PRIdoff_t PRId64
55-#else
56-#define PRIxoff_t "l"PRIx32
57-#define PRIdoff_t "l"PRId32
58-#endif
59-
60-/* define a print format specifier for loff_t */
61-#if (SIZEOF_LOFF_T >= 8)
62-#define PRIxloff_t PRIx64
63-#define PRIdloff_t PRId64
64-#else
65-#define PRIxloff_t "l"PRIx32
66-#define PRIdloff_t "l"PRId32
67-#endif
68-
69 /* Verbose messages */
70 #define bareverbose(verbose, fmt, ...) do { \
71 if (verbose) \
72diff --git a/jffsX-utils/mkfs.jffs2.c b/jffsX-utils/mkfs.jffs2.c
73index 9aa6c39..0661786 100644
74--- a/jffsX-utils/mkfs.jffs2.c
75+++ b/jffsX-utils/mkfs.jffs2.c
76@@ -1237,8 +1237,8 @@ static void recursive_populate_directory(struct filesystem_entry *dir)
77 } else switch (e->sb.st_mode & S_IFMT) {
78 case S_IFDIR:
79 if (verbose) {
80- printf("\td %04o %9" PRIdoff_t " %5d:%-3d %s\n",
81- e->sb.st_mode & ~S_IFMT, e->sb.st_size,
82+ printf("\td %04o %9lld %5d:%-3d %s\n",
83+ e->sb.st_mode & ~S_IFMT, (long long)e->sb.st_size,
84 (int) (e->sb.st_uid), (int) (e->sb.st_gid),
85 e->name);
86 }
87@@ -1247,8 +1247,8 @@ static void recursive_populate_directory(struct filesystem_entry *dir)
88 break;
89 case S_IFSOCK:
90 if (verbose) {
91- printf("\ts %04o %9" PRIdoff_t " %5d:%-3d %s\n",
92- e->sb.st_mode & ~S_IFMT, e->sb.st_size,
93+ printf("\ts %04o %9lld %5d:%-3d %s\n",
94+ e->sb.st_mode & ~S_IFMT, (long long)e->sb.st_size,
95 (int) e->sb.st_uid, (int) e->sb.st_gid, e->name);
96 }
97 write_pipe(e);
98@@ -1256,8 +1256,8 @@ static void recursive_populate_directory(struct filesystem_entry *dir)
99 break;
100 case S_IFIFO:
101 if (verbose) {
102- printf("\tp %04o %9" PRIdoff_t " %5d:%-3d %s\n",
103- e->sb.st_mode & ~S_IFMT, e->sb.st_size,
104+ printf("\tp %04o %9lld %5d:%-3d %s\n",
105+ e->sb.st_mode & ~S_IFMT, (long long)e->sb.st_size,
106 (int) e->sb.st_uid, (int) e->sb.st_gid, e->name);
107 }
108 write_pipe(e);
109@@ -1285,8 +1285,8 @@ static void recursive_populate_directory(struct filesystem_entry *dir)
110 break;
111 case S_IFLNK:
112 if (verbose) {
113- printf("\tl %04o %9" PRIdoff_t " %5d:%-3d %s -> %s\n",
114- e->sb.st_mode & ~S_IFMT, e->sb.st_size,
115+ printf("\tl %04o %9lld %5d:%-3d %s -> %s\n",
116+ e->sb.st_mode & ~S_IFMT, (long long)e->sb.st_size,
117 (int) e->sb.st_uid, (int) e->sb.st_gid, e->name,
118 e->link);
119 }
120@@ -1297,8 +1297,8 @@ static void recursive_populate_directory(struct filesystem_entry *dir)
121 wrote = write_regular_file(e);
122 write_xattr_entry(e);
123 if (verbose) {
124- printf("\tf %04o %9" PRIdoff_t " (%9u) %5d:%-3d %s\n",
125- e->sb.st_mode & ~S_IFMT, e->sb.st_size, wrote,
126+ printf("\tf %04o %9lld (%9u) %5d:%-3d %s\n",
127+ e->sb.st_mode & ~S_IFMT, (long long)e->sb.st_size, wrote,
128 (int) e->sb.st_uid, (int) e->sb.st_gid, e->name);
129 }
130 break;
131diff --git a/lib/libmtd.c b/lib/libmtd.c
132index 86c89ae..f375381 100644
133--- a/lib/libmtd.c
134+++ b/lib/libmtd.c
135@@ -1079,8 +1079,8 @@ int mtd_read(const struct mtd_dev_info *mtd, int fd, int eb, int offs,
136 /* Seek to the beginning of the eraseblock */
137 seek = (off_t)eb * mtd->eb_size + offs;
138 if (lseek(fd, seek, SEEK_SET) != seek)
139- return sys_errmsg("cannot seek mtd%d to offset %"PRIdoff_t,
140- mtd->mtd_num, seek);
141+ return sys_errmsg("cannot seek mtd%d to offset %lld",
142+ mtd->mtd_num, (long long)seek);
143
144 while (rd < len) {
145 ret = read(fd, buf + rd, len - rd);
146@@ -1188,8 +1188,8 @@ int mtd_write(libmtd_t desc, const struct mtd_dev_info *mtd, int fd, int eb,
147 if (data) {
148 /* Seek to the beginning of the eraseblock */
149 if (lseek(fd, seek, SEEK_SET) != seek)
150- return sys_errmsg("cannot seek mtd%d to offset %"PRIdoff_t,
151- mtd->mtd_num, seek);
152+ return sys_errmsg("cannot seek mtd%d to offset %lld",
153+ mtd->mtd_num, (long long)seek);
154 ret = write(fd, data, len);
155 if (ret != len)
156 return sys_errmsg("cannot write %d bytes to mtd%d "
157diff --git a/misc-utils/flash_erase.c b/misc-utils/flash_erase.c
158index 0c9449f..ec4b2e1 100644
159--- a/misc-utils/flash_erase.c
160+++ b/misc-utils/flash_erase.c
161@@ -53,8 +53,8 @@ int target_endian = __BYTE_ORDER;
162 static void show_progress(struct mtd_dev_info *mtd, off_t start, int eb,
163 int eb_start, int eb_cnt)
164 {
165- bareverbose(!quiet, "\rErasing %d Kibyte @ %"PRIxoff_t" -- %2i %% complete ",
166- mtd->eb_size / 1024, start, ((eb - eb_start) * 100) / eb_cnt);
167+ bareverbose(!quiet, "\rErasing %d Kibyte @ %llx -- %2i %% complete ",
168+ mtd->eb_size / 1024, (unsigned long long)start, ((eb - eb_start) * 100) / eb_cnt);
169 fflush(stdout);
170 }
171
172@@ -210,7 +210,7 @@ int main(int argc, char *argv[])
173 if (!noskipbad) {
174 int ret = mtd_is_bad(&mtd, fd, eb);
175 if (ret > 0) {
176- verbose(!quiet, "Skipping bad block at %08"PRIxoff_t, offset);
177+ verbose(!quiet, "Skipping bad block at %08llx", (unsigned long long)offset);
178 continue;
179 } else if (ret < 0) {
180 if (errno == EOPNOTSUPP) {
181diff --git a/misc-utils/flash_otp_write.c b/misc-utils/flash_otp_write.c
182index b02d0b0..04c96c6 100644
183--- a/misc-utils/flash_otp_write.c
184+++ b/misc-utils/flash_otp_write.c
185@@ -76,7 +76,7 @@ int main(int argc,char *argv[])
186 return errno;
187 }
188
189- printf("Writing OTP user data on %s at offset 0x%"PRIxoff_t"\n", argv[2], offset);
190+ printf("Writing OTP user data on %s at offset 0x%llx\n", argv[2], (unsigned long long)offset);
191
192 if (mtd_type_is_nand_user(&mtdInfo))
193 len = mtdInfo.writesize;
194diff --git a/misc-utils/ftl_check.c b/misc-utils/ftl_check.c
195index a853cf4..e854922 100644
196--- a/misc-utils/ftl_check.c
197+++ b/misc-utils/ftl_check.c
198@@ -131,7 +131,7 @@ static void check_partition(int fd)
199 perror("read failed");
200 break;
201 }
202- printf("\nErase unit %"PRIdoff_t":\n", i);
203+ printf("\nErase unit %lld:\n", (long long)i);
204 if ((hdr2.FormattedSize != hdr.FormattedSize) ||
205 (hdr2.NumEraseUnits != hdr.NumEraseUnits) ||
206 (hdr2.SerialNumber != hdr.SerialNumber))
207diff --git a/misc-utils/mtd_debug.c b/misc-utils/mtd_debug.c
208index ac37e23..d65ad36 100644
209--- a/misc-utils/mtd_debug.c
210+++ b/misc-utils/mtd_debug.c
211@@ -160,7 +160,7 @@ retry:
212 if (buf != NULL)
213 free(buf);
214 close(outfd);
215- printf("Copied %zu bytes from address 0x%.8"PRIxoff_t" in flash to %s\n", len, offset, filename);
216+ printf("Copied %zu bytes from address 0x%.8llx in flash to %s\n", len, (unsigned long long)offset, filename);
217 return 0;
218
219 err2:
220@@ -225,7 +225,7 @@ retry:
221 if (buf != NULL)
222 free(buf);
223 fclose(fp);
224- printf("Copied %d bytes from %s to address 0x%.8"PRIxoff_t" in flash\n", len, filename, offset);
225+ printf("Copied %d bytes from %s to address 0x%.8llx in flash\n", len, filename, (unsigned long long)offset);
226 return 0;
227 }
228
229diff --git a/misc-utils/serve_image.c b/misc-utils/serve_image.c
230index f2475d6..6c8c8fb 100644
231--- a/misc-utils/serve_image.c
232+++ b/misc-utils/serve_image.c
233@@ -129,8 +129,8 @@ int main(int argc, char **argv)
234 }
235
236 if (st.st_size % erasesize) {
237- fprintf(stderr, "Image size %" PRIdoff_t " bytes is not a multiple of erasesize %d bytes\n",
238- st.st_size, erasesize);
239+ fprintf(stderr, "Image size %lld bytes is not a multiple of erasesize %d bytes\n",
240+ (long long)st.st_size, erasesize);
241 exit(1);
242 }
243 image = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, rfd, 0);
244diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
245index 84753d6..0a7f142 100644
246--- a/tests/fs-tests/integrity/integck.c
247+++ b/tests/fs-tests/integrity/integck.c
248@@ -897,8 +897,8 @@ static ssize_t file_write_data(struct file_info *file, int fd, off_t offset,
249 remains = size;
250 actual = 0;
251 written = IO_BUFFER_SIZE;
252- v("write %zd bytes, offset %"PRIdoff_t", file %s",
253- size, offset, get_file_name(file));
254+ v("write %zd bytes, offset %lld, file %s",
255+ size, (long long)offset, get_file_name(file));
256 while (remains) {
257 /* Fill up buffer with random data */
258 if (written < IO_BUFFER_SIZE) {
259diff --git a/tests/mtd-tests/nandpagetest.c b/tests/mtd-tests/nandpagetest.c
260index c6812df..465e548 100644
261--- a/tests/mtd-tests/nandpagetest.c
262+++ b/tests/mtd-tests/nandpagetest.c
263@@ -232,8 +232,8 @@ static int verify_eraseblock(int ebnum)
264 return err;
265
266 if (lseek(fd, addr, SEEK_SET) != addr) {
267- fprintf(stderr, "cannot seek mtd%d to offset %"PRIdloff_t,
268- mtd.mtd_num, addr);
269+ fprintf(stderr, "cannot seek mtd%d to offset %lld",
270+ mtd.mtd_num, (long long)addr);
271 return -1;
272 }
273
274diff --git a/tests/ubi-tests/integ.c b/tests/ubi-tests/integ.c
275index 26c2ce5..1cd0649 100644
276--- a/tests/ubi-tests/integ.c
277+++ b/tests/ubi-tests/integ.c
278@@ -243,7 +243,7 @@ static void check_erase_block(struct erase_block_info *erase_block, int fd)
279 while (size)
280 if (read_buffer[--size] != 0xff) {
281 fprintf(stderr, "block no. = %d\n" , erase_block->block_number);
282- fprintf(stderr, "offset = %"PRIdoff_t"\n" , gap_start);
283+ fprintf(stderr, "offset = %lld\n" , (long long)gap_start);
284 fprintf(stderr, "size = %ld\n" , (long) bytes_read);
285 error_exit("verify 0xff failed");
286 }
287@@ -254,7 +254,7 @@ static void check_erase_block(struct erase_block_info *erase_block, int fd)
288 errno = 0;
289 bytes_read = read(fd, read_buffer, w->size);
290 if (bytes_read != w->size) {
291- fprintf(stderr, "offset = %"PRIdoff_t"\n" , w->offset);
292+ fprintf(stderr, "offset = %lld\n" , (long long)w->offset);
293 fprintf(stderr, "size = %ld\n" , (long) w->size);
294 fprintf(stderr, "bytes_read = %ld\n" , (long) bytes_read);
295 error_exit("read failed");
296@@ -279,7 +279,7 @@ static void check_erase_block(struct erase_block_info *erase_block, int fd)
297 while (size)
298 if (read_buffer[--size] != 0xff) {
299 fprintf(stderr, "block no. = %d\n" , erase_block->block_number);
300- fprintf(stderr, "offset = %"PRIdoff_t"\n" , gap_start);
301+ fprintf(stderr, "offset = %lld\n" , (long long)gap_start);
302 fprintf(stderr, "size = %ld\n" , (long) bytes_read);
303 error_exit("verify 0xff failed!");
304 }
305diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
306index c916f48..f0237ab 100644
307--- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
308+++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
309@@ -772,11 +772,11 @@ int write_leb(int lnum, int len, void *buf)
310 return sys_err_msg("ubi_leb_change_start failed");
311
312 if (lseek(out_fd, pos, SEEK_SET) != pos)
313- return sys_err_msg("lseek failed seeking %"PRIdoff_t, pos);
314+ return sys_err_msg("lseek failed seeking %lld", (long long)pos);
315
316 if (write(out_fd, buf, c->leb_size) != c->leb_size)
317- return sys_err_msg("write failed writing %d bytes at pos %"PRIdoff_t,
318- c->leb_size, pos);
319+ return sys_err_msg("write failed writing %d bytes at pos %lld",
320+ c->leb_size, (long long)pos);
321
322 return 0;
323 }
324--
3252.7.4
326