mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 01:53:34 +08:00
HMC driver: Return value handling
This commit is contained in:
@@ -1355,10 +1355,9 @@ start_bus(struct hmc5883_bus_option &bus, enum Rotation rotation)
|
||||
void
|
||||
start(enum HMC5883_BUS busid, enum Rotation rotation)
|
||||
{
|
||||
uint8_t i;
|
||||
bool started = false;
|
||||
|
||||
for (i=0; i<NUM_BUS_OPTIONS; i++) {
|
||||
for (unsigned i = 0; i < NUM_BUS_OPTIONS; i++) {
|
||||
if (busid == HMC5883_BUS_ALL && bus_options[i].dev != NULL) {
|
||||
// this device is already started
|
||||
continue;
|
||||
@@ -1373,7 +1372,6 @@ start(enum HMC5883_BUS busid, enum Rotation rotation)
|
||||
if (!started)
|
||||
errx(1, "driver start failed");
|
||||
|
||||
// one or more drivers started OK
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -1382,13 +1380,13 @@ start(enum HMC5883_BUS busid, enum Rotation rotation)
|
||||
*/
|
||||
struct hmc5883_bus_option &find_bus(enum HMC5883_BUS busid)
|
||||
{
|
||||
for (uint8_t i=0; i<NUM_BUS_OPTIONS; i++) {
|
||||
for (unsigned i = 0; i < NUM_BUS_OPTIONS; i++) {
|
||||
if ((busid == HMC5883_BUS_ALL ||
|
||||
busid == bus_options[i].busid) && bus_options[i].dev != NULL) {
|
||||
return bus_options[i];
|
||||
}
|
||||
}
|
||||
errx(1,"bus %u not started", (unsigned)busid);
|
||||
errx(1, "bus %u not started", (unsigned)busid);
|
||||
}
|
||||
|
||||
|
||||
@@ -1625,6 +1623,8 @@ hmc5883_main(int argc, char *argv[])
|
||||
} else {
|
||||
errx(1, "calibration failed");
|
||||
}
|
||||
} else {
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user