From e2b602339adef80af84d6d396adc1962b1f86826 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 30 Aug 2013 17:05:21 +0200 Subject: [PATCH] Cleanup of detect return --- src/drivers/px4io/px4io.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/drivers/px4io/px4io.cpp b/src/drivers/px4io/px4io.cpp index 1fa3fbbfbe..026b879497 100644 --- a/src/drivers/px4io/px4io.cpp +++ b/src/drivers/px4io/px4io.cpp @@ -1966,18 +1966,16 @@ detect(int argc, char *argv[]) if (g_dev == nullptr) errx(1, "driver alloc failed"); - if (OK != g_dev->detect()) { - delete g_dev; - g_dev = nullptr; + ret = g_dev->detect() + + delete g_dev; + g_dev = nullptr; + + if (ret) + /* nonzero, error */ exit(1); - } - - if (g_dev != nullptr) { - delete g_dev; - g_dev = nullptr; - } - - exit(0); + else + exit(0); } void