You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ag...@apache.org on 2021/06/17 08:22:48 UTC
[incubator-nuttx-apps] 02/02: testing/sensor: fix bug about -h
This is an automated email from the ASF dual-hosted git repository.
aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
commit 993693d5f4162961766830b5af53c777ca9482d3
Author: Jiuzhu Dong <do...@xiaomi.com>
AuthorDate: Tue Feb 2 11:55:43 2021 +0800
testing/sensor: fix bug about -h
MIRTOS-334
Change-Id: I1803ad1c769189f42d223111c7eb898e091eeccc
Signed-off-by: Jiuzhu Dong <do...@xiaomi.com>
---
testing/sensortest/sensortest.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/testing/sensortest/sensortest.c b/testing/sensortest/sensortest.c
index cc67629..110a4d9 100644
--- a/testing/sensortest/sensortest.c
+++ b/testing/sensortest/sensortest.c
@@ -224,8 +224,7 @@ int main(int argc, FAR char *argv[])
case 'h':
default:
usage();
- optind = 0;
- return 0;
+ goto name_err;
}
}
@@ -247,18 +246,21 @@ int main(int argc, FAR char *argv[])
{
printf("The sensor node name:%s is invaild\n", name);
usage();
- return -EINVAL;
+ ret = -EINVAL;
+ goto name_err;
}
if (!buffer)
{
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto name_err;
}
}
else
{
usage();
- return -EINVAL;
+ ret = -EINVAL;
+ goto name_err;
}
snprintf(devname, PATH_MAX, DEVNAME_FMT, name);
@@ -341,5 +343,7 @@ ctl_err:
close(fd);
open_err:
free(buffer);
+name_err:
+ optind = 0;
return ret;
}