diff options
Diffstat (limited to 'meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0005-common.h-replace-getline-with-fgets.patch')
-rw-r--r-- | meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0005-common.h-replace-getline-with-fgets.patch | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0005-common.h-replace-getline-with-fgets.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0005-common.h-replace-getline-with-fgets.patch new file mode 100644 index 000000000..adef377b8 --- /dev/null +++ b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0005-common.h-replace-getline-with-fgets.patch | |||
@@ -0,0 +1,56 @@ | |||
1 | From 2137eb1a6cd0326510bd3b9faf8037d9bf34ca3d Mon Sep 17 00:00:00 2001 | ||
2 | From: Andrea Adami <andrea.adami@gmail.com> | ||
3 | Date: Wed, 23 May 2018 15:52:34 +0200 | ||
4 | Subject: [PATCH 5/5] common.h: replace getline() with fgets | ||
5 | |||
6 | There is an unofficial upstream patch adding a simple getline() | ||
7 | to libmissing.h. Unfortunately the patch creates issues if the | ||
8 | toolchain is using glibc (autotools cache?) so for the moment | ||
9 | keep the old hack and wait for commits upstream. | ||
10 | |||
11 | Fix: | ||
12 | |||
13 | | ubi-utils/ubiformat.o: In function `prompt.constprop.4': | ||
14 | | ubiformat.c:(.text+0x70): undefined reference to `getline' | ||
15 | |||
16 | Upstrea-Status: Inappropriate [klibc specific] | ||
17 | |||
18 | Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | ||
19 | --- | ||
20 | include/common.h | 11 +++++++++++ | ||
21 | 1 file changed, 11 insertions(+) | ||
22 | |||
23 | diff --git a/include/common.h b/include/common.h | ||
24 | index a1d59d0..96b0bdb 100644 | ||
25 | --- a/include/common.h | ||
26 | +++ b/include/common.h | ||
27 | @@ -126,15 +126,26 @@ extern "C" { | ||
28 | */ | ||
29 | static inline bool prompt(const char *msg, bool def) | ||
30 | { | ||
31 | + | ||
32 | +#ifndef __KLIBC__ | ||
33 | char *line = NULL; | ||
34 | size_t len; | ||
35 | +#else | ||
36 | + char *line; | ||
37 | + const int sizeof_line = 2; | ||
38 | + line = malloc(sizeof_line); | ||
39 | +#endif | ||
40 | bool ret = def; | ||
41 | |||
42 | do { | ||
43 | normsg_cont("%s (%c/%c) ", msg, def ? 'Y' : 'y', def ? 'n' : 'N'); | ||
44 | fflush(stdout); | ||
45 | |||
46 | +#ifndef __KLIBC__ | ||
47 | while (getline(&line, &len, stdin) == -1) { | ||
48 | +#else | ||
49 | + while (fgets(line, sizeof_line, stdin) == NULL) { | ||
50 | +#endif | ||
51 | printf("failed to read prompt; assuming '%s'\n", | ||
52 | def ? "yes" : "no"); | ||
53 | break; | ||
54 | -- | ||
55 | 2.7.4 | ||
56 | |||