mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-16 16:57:35 +08:00
Servo test: Fix resource leak
This commit is contained in:
@@ -56,7 +56,8 @@
|
||||
|
||||
int test_servo(int argc, char *argv[])
|
||||
{
|
||||
int fd, result;
|
||||
int fd;
|
||||
int result = 0;
|
||||
servo_position_t data[PWM_OUTPUT_MAX_CHANNELS];
|
||||
servo_position_t pos;
|
||||
|
||||
@@ -81,7 +82,7 @@ int test_servo(int argc, char *argv[])
|
||||
|
||||
if (result != OK) {
|
||||
warnx("PWM_SERVO_GET_COUNT");
|
||||
return ERROR;
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < servo_count; i++) {
|
||||
@@ -101,6 +102,7 @@ int test_servo(int argc, char *argv[])
|
||||
|
||||
if (result != OK) {
|
||||
warnx("FAIL: PWM_SERVO_SET_ARM_OK");
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* tell output device that the system is armed (it will output values if safety is off) */
|
||||
@@ -108,6 +110,7 @@ int test_servo(int argc, char *argv[])
|
||||
|
||||
if (result != OK) {
|
||||
warnx("FAIL: PWM_SERVO_ARM");
|
||||
goto out;
|
||||
}
|
||||
|
||||
usleep(5000000);
|
||||
@@ -121,5 +124,5 @@ out:
|
||||
close(fd);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user