Fix error return propagation in InterfaceController::setCfg()
ifc_add_address return -errno on error
Test: builds, atest
Bug: 142764715
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I6b46e74226538d309ad65ed4ae93817e94bcfb27
diff --git a/server/InterfaceController.cpp b/server/InterfaceController.cpp
index 755068d..7504fb9 100644
--- a/server/InterfaceController.cpp
+++ b/server/InterfaceController.cpp
@@ -55,13 +55,6 @@
using android::netdutils::toString;
using android::netdutils::status::ok;
-#define RETURN_STATUS_IF_IFCERROR(exp) \
- do { \
- if ((exp) == -1) { \
- return statusFromErrno(errno, "Failed to add addr"); \
- } \
- } while (0);
-
namespace {
const char ipv4_proc_path[] = "/proc/sys/net/ipv4/conf";
@@ -506,8 +499,9 @@
}
}
- RETURN_STATUS_IF_IFCERROR(
- ifc_add_address(cfg.ifName.c_str(), cfg.ipv4Addr.c_str(), cfg.prefixLength));
+ if (int ret = ifc_add_address(cfg.ifName.c_str(), cfg.ipv4Addr.c_str(), cfg.prefixLength)) {
+ return statusFromErrno(-ret, "Failed to add addr");
+ }
return ok;
}