Skip to contentSkip to conversation

ir-ctl: use strndup instead of strndupa (fixes musl compile)

PATCH New Peter Seiderer 1 participant 2 messages Feb 20, 2017 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ir-ctl: use strndup instead of strndupa (fixes musl compile)

Fixes buildroot musl compile (see [1], [2]):

ir-ctl.c:(.text+0xb06): undefined reference to `strndupa'

[1] http://autobuild.buildroot.net/results/b8b96c7bbf2147dacac62485cbfdbcfd758271a5
[2] http://lists.busybox.net/pipermail/buildroot/2017-February/184048.html

---
 utils/ir-ctl/ir-ctl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
utils/ir-ctl/ir-ctl.c +3 -1
index bc58cee0..f938b429 100644
@@ -344,12 +344,14 @@ static struct file *read_scancode(const char *name)
 		return NULL;
 	}
 
-	pstr = strndupa(name, p - name);
+	pstr = strndup(name, p - name);
 
 	if (!protocol_match(pstr, &proto)) {
 		fprintf(stderr, _("error: protocol '%s' not found\n"), pstr);
+		free(pstr);
 		return NULL;
 	}
+	free(pstr);
 
 	if (!strtoscancode(p + 1, &scancode)) {
 		fprintf(stderr, _("error: invalid scancode '%s'\n"), p + 1);
Signature · 1 line
2.11.0
#1 lore raw

PATCH 2/2 ir-ctl: add optional copy of TEMP_FAILURE_RETRY macro (fix musl compile)

Fixes buildroot musl compile (see [1], [2]):

ir-ctl.c:(.text+0xe01): undefined reference to `TEMP_FAILURE_RETRY'

[1] http://autobuild.buildroot.net/results/b8b96c7bbf2147dacac62485cbfdbcfd758271a5
[2] http://lists.busybox.net/pipermail/buildroot/2017-February/184048.html

---
 utils/ir-ctl/ir-ctl.c | 9 +++++++++
 1 file changed, 9 insertions(+)
utils/ir-ctl/ir-ctl.c +9 -0
index f938b429..e9da7778 100644
@@ -44,6 +44,15 @@
 
 # define N_(string) string
 
+/* taken from glibc unistd.h */
+#ifndef TEMP_FAILURE_RETRY
+#define TEMP_FAILURE_RETRY(expression) \
+  (__extension__                                                              \
+    ({ long int __result;                                                     \
+       do __result = (long int) (expression);                                 \
+       while (__result == -1L && errno == EINTR);                             \
+       __result; }))
+#endif
 
 /* See drivers/media/rc/ir-lirc-codec.c line 23 */
 #define LIRCBUF_SIZE	512
Signature · 1 line
2.11.0