Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1 | From e60aea50e41ae8a17672beb5859beecb66e7a305 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Fri, 14 Jul 2017 13:11:25 -0700 |
| 4 | Subject: [PATCH 1/3] ir-ctl: Define TEMP_FAILURE_RETRY if undefined |
| 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> |
| 12 | --- |
| 13 | utils/ir-ctl/ir-ctl.c | 14 +++++++++++++- |
| 14 | 1 file changed, 13 insertions(+), 1 deletion(-) |
| 15 | |
| 16 | diff --git a/utils/ir-ctl/ir-ctl.c b/utils/ir-ctl/ir-ctl.c |
| 17 | index 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 | -- |
| 54 | 2.13.3 |
| 55 | |