blob: f1e11da3fdbc984cc608db1a2da06eb15d864b96 [file] [log] [blame]
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001From e60aea50e41ae8a17672beb5859beecb66e7a305 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 14 Jul 2017 13:11:25 -0700
4Subject: [PATCH 1/3] ir-ctl: Define TEMP_FAILURE_RETRY if undefined
5
6use strndup() instead of strndupa() which is not
7universally available in C libraries
8
9Taken from AlpineLinux
10
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13 utils/ir-ctl/ir-ctl.c | 14 +++++++++++++-
14 1 file changed, 13 insertions(+), 1 deletion(-)
15
16diff --git a/utils/ir-ctl/ir-ctl.c b/utils/ir-ctl/ir-ctl.c
17index bc58cee..1a44011 100644
18--- a/utils/ir-ctl/ir-ctl.c
19+++ b/utils/ir-ctl/ir-ctl.c
20@@ -42,6 +42,16 @@
21 # define _(string) string
22 #endif
23
24+/* taken from glibc unistd.h */
25+#ifndef TEMP_FAILURE_RETRY
26+#define TEMP_FAILURE_RETRY(expression) \
27+ (__extension__ \
28+ ({ long int __result; \
29+ do __result = (long int) (expression); \
30+ while (__result == -1L && errno == EINTR); \
31+ __result; }))
32+#endif
33+
34 # define N_(string) string
35
36
37@@ -344,12 +354,14 @@ static struct file *read_scancode(const char *name)
38 return NULL;
39 }
40
41- pstr = strndupa(name, p - name);
42+ pstr = strndup(name, p - name);
43
44 if (!protocol_match(pstr, &proto)) {
45 fprintf(stderr, _("error: protocol '%s' not found\n"), pstr);
46+ free(pstr);
47 return NULL;
48 }
49+ free(pstr);
50
51 if (!strtoscancode(p + 1, &scancode)) {
52 fprintf(stderr, _("error: invalid scancode '%s'\n"), p + 1);
53--
542.13.3
55