From 914e6c54975b79bf9cf568cc25fd432273a0b483 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 19 Aug 2019 09:46:02 +1000 Subject: [PATCH] AP_HAL_Linux: check return value of system command Compilation fails on disco without this patch as system is declared with attribute warn_unused_result --- libraries/AP_HAL_Linux/GPIO_Sysfs.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/AP_HAL_Linux/GPIO_Sysfs.cpp b/libraries/AP_HAL_Linux/GPIO_Sysfs.cpp index 9d2fefdb2a..bca92728a9 100644 --- a/libraries/AP_HAL_Linux/GPIO_Sysfs.cpp +++ b/libraries/AP_HAL_Linux/GPIO_Sysfs.cpp @@ -287,7 +287,10 @@ void GPIO_Sysfs::_gpio_script_thread(void) char cmd[100]; snprintf(cmd, sizeof(cmd)-1, "/bin/sh %s %u %u", HAL_GPIO_SCRIPT, pv.pin, pv.value); hal.console->printf("Running: %s\n", cmd); - system(cmd); + const int system_ret = system(cmd); + if (system_ret != 0) { + hal.console->printf("Unexpected return value (%d)\n", system_ret); + } } } }