Servo test: Fix resource leak

This commit is contained in:
Lorenz Meier 2017-01-14 14:18:28 +01:00
parent a905babe95
commit 26625b3a5d
1 changed files with 6 additions and 3 deletions

View File

@ -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;
}