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