From 792f1747c770355f3a9888a2d2b8240b26b79dd7 Mon Sep 17 00:00:00 2001 From: Kabir Mohammed Date: Wed, 28 Oct 2015 18:05:20 +0530 Subject: [PATCH] rangefinders : remove annoying gotos --- src/drivers/ll40ls/LidarLiteI2C.cpp | 6 +++--- src/drivers/ll40ls/LidarLitePWM.cpp | 2 +- src/drivers/mb12xx/mb12xx.cpp | 8 ++++---- src/drivers/px4flow/px4flow.cpp | 8 ++++---- src/drivers/sf0x/sf0x.cpp | 2 +- src/drivers/srf02/srf02.cpp | 8 ++++---- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/drivers/ll40ls/LidarLiteI2C.cpp b/src/drivers/ll40ls/LidarLiteI2C.cpp index 9896c0e940..7c3e4f1dbc 100644 --- a/src/drivers/ll40ls/LidarLiteI2C.cpp +++ b/src/drivers/ll40ls/LidarLiteI2C.cpp @@ -114,14 +114,14 @@ int LidarLiteI2C::init() /* do I2C init (and probe) first */ if (I2C::init() != OK) { - goto out; + return ret; } /* allocate basic report buffers */ _reports = new ringbuffer::RingBuffer(2, sizeof(struct distance_sensor_s)); if (_reports == nullptr) { - goto out; + return ret; } _class_instance = register_class_devname(RANGE_FINDER_BASE_DEVICE_PATH); @@ -140,7 +140,7 @@ int LidarLiteI2C::init() ret = OK; /* sensor is ok, but we don't really know if it is within range */ _sensor_ok = true; -out: + return ret; } diff --git a/src/drivers/ll40ls/LidarLitePWM.cpp b/src/drivers/ll40ls/LidarLitePWM.cpp index 02af12b950..0157081832 100644 --- a/src/drivers/ll40ls/LidarLitePWM.cpp +++ b/src/drivers/ll40ls/LidarLitePWM.cpp @@ -109,7 +109,7 @@ int LidarLitePWM::init() _class_instance = register_class_devname(RANGE_FINDER_BASE_DEVICE_PATH); /* get a publish handle on the distance_sensor topic */ - struct distance_sensor_s ds_report; + struct distance_sensor_s ds_report = {}; measure(); _reports->get(&ds_report); _distance_sensor_topic = orb_advertise_multi(ORB_ID(distance_sensor), &ds_report, diff --git a/src/drivers/mb12xx/mb12xx.cpp b/src/drivers/mb12xx/mb12xx.cpp index c1e0734466..39f151f1d6 100644 --- a/src/drivers/mb12xx/mb12xx.cpp +++ b/src/drivers/mb12xx/mb12xx.cpp @@ -255,7 +255,7 @@ MB12XX::init() /* do I2C init (and probe) first */ if (I2C::init() != OK) { - goto out; + return ret; } /* allocate basic report buffers */ @@ -265,13 +265,13 @@ MB12XX::init() set_address(_index_counter); /* set I2c port to temp sonar i2c adress */ if (_reports == nullptr) { - goto out; + return ret; } _class_instance = register_class_devname(RANGE_FINDER_BASE_DEVICE_PATH); /* get a publish handle on the range finder topic */ - struct distance_sensor_s ds_report; + struct distance_sensor_s ds_report = {}; _distance_sensor_topic = orb_advertise_multi(ORB_ID(distance_sensor), &ds_report, &_orb_class_instance, ORB_PRIO_LOW); @@ -319,7 +319,7 @@ MB12XX::init() ret = OK; /* sensor is ok, but we don't really know if it is within range */ _sensor_ok = true; -out: + return ret; } diff --git a/src/drivers/px4flow/px4flow.cpp b/src/drivers/px4flow/px4flow.cpp index 869e5509ed..18acccc00c 100644 --- a/src/drivers/px4flow/px4flow.cpp +++ b/src/drivers/px4flow/px4flow.cpp @@ -229,20 +229,20 @@ PX4FLOW::init() /* do I2C init (and probe) first */ if (I2C::init() != OK) { - goto out; + return ret; } /* allocate basic report buffers */ _reports = new ringbuffer::RingBuffer(2, sizeof(optical_flow_s)); if (_reports == nullptr) { - goto out; + return ret; } _class_instance = register_class_devname(RANGE_FINDER_BASE_DEVICE_PATH); /* get a publish handle on the range finder topic */ - struct distance_sensor_s ds_report; + struct distance_sensor_s ds_report = {}; _distance_sensor_topic = orb_advertise_multi(ORB_ID(distance_sensor), &ds_report, &_orb_class_instance, ORB_PRIO_HIGH); @@ -254,7 +254,7 @@ PX4FLOW::init() ret = OK; /* sensor is ok, but we don't really know if it is within range */ _sensor_ok = true; -out: + return ret; } diff --git a/src/drivers/sf0x/sf0x.cpp b/src/drivers/sf0x/sf0x.cpp index 9dd7b1614d..41730618b2 100644 --- a/src/drivers/sf0x/sf0x.cpp +++ b/src/drivers/sf0x/sf0x.cpp @@ -297,7 +297,7 @@ SF0X::init() _class_instance = register_class_devname(RANGE_FINDER_BASE_DEVICE_PATH); /* get a publish handle on the range finder topic */ - struct distance_sensor_s ds_report; + struct distance_sensor_s ds_report = {}; _distance_sensor_topic = orb_advertise_multi(ORB_ID(distance_sensor), &ds_report, &_orb_class_instance, ORB_PRIO_HIGH); diff --git a/src/drivers/srf02/srf02.cpp b/src/drivers/srf02/srf02.cpp index 8e5c37a88f..e3f6ad7d08 100644 --- a/src/drivers/srf02/srf02.cpp +++ b/src/drivers/srf02/srf02.cpp @@ -254,7 +254,7 @@ SRF02::init() /* do I2C init (and probe) first */ if (I2C::init() != OK) { - goto out; + return ret; } /* allocate basic report buffers */ @@ -264,13 +264,13 @@ SRF02::init() set_address(_index_counter); /* set I2c port to temp sonar i2c adress */ if (_reports == nullptr) { - goto out; + return ret; } _class_instance = register_class_devname(RANGE_FINDER_BASE_DEVICE_PATH); /* get a publish handle on the range finder topic */ - struct distance_sensor_s ds_report; + struct distance_sensor_s ds_report = {}; _distance_sensor_topic = orb_advertise_multi(ORB_ID(distance_sensor), &ds_report, &_orb_class_instance, ORB_PRIO_LOW); @@ -318,7 +318,7 @@ SRF02::init() ret = OK; /* sensor is ok, but we don't really know if it is within range */ _sensor_ok = true; -out: + return ret; }