Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1 | From b2efcc20617d6317f74c4acb2a6af5b765f20b34 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Fri, 14 Jul 2017 13:11:25 -0700 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 4 | Subject: [PATCH] ir-ctl: Define TEMP_FAILURE_RETRY if undefined |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 5 | |
| 6 | use strndup() instead of strndupa() which is not |
| 7 | universally available in C libraries |
| 8 | |
| 9 | Taken from AlpineLinux |
| 10 | |
| 11 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 13 | --- |
| 14 | utils/ir-ctl/ir-ctl.c | 14 +++++++++++++- |
| 15 | 1 file changed, 13 insertions(+), 1 deletion(-) |
| 16 | |
| 17 | diff --git a/utils/ir-ctl/ir-ctl.c b/utils/ir-ctl/ir-ctl.c |
| 18 | index 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); |