testing/sensor: fix bug about -h

MIRTOS-334

Change-Id: I1803ad1c769189f42d223111c7eb898e091eeccc
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
Jiuzhu Dong 2021-02-02 11:55:43 +08:00 committed by Abdelatif Guettouche
parent d838666844
commit 993693d5f4

View File

@ -224,8 +224,7 @@ int main(int argc, FAR char *argv[])
case 'h': case 'h':
default: default:
usage(); usage();
optind = 0; goto name_err;
return 0;
} }
} }
@ -247,18 +246,21 @@ int main(int argc, FAR char *argv[])
{ {
printf("The sensor node name:%s is invaild\n", name); printf("The sensor node name:%s is invaild\n", name);
usage(); usage();
return -EINVAL; ret = -EINVAL;
goto name_err;
} }
if (!buffer) if (!buffer)
{ {
return -ENOMEM; ret = -ENOMEM;
goto name_err;
} }
} }
else else
{ {
usage(); usage();
return -EINVAL; ret = -EINVAL;
goto name_err;
} }
snprintf(devname, PATH_MAX, DEVNAME_FMT, name); snprintf(devname, PATH_MAX, DEVNAME_FMT, name);
@ -341,5 +343,7 @@ ctl_err:
close(fd); close(fd);
open_err: open_err:
free(buffer); free(buffer);
name_err:
optind = 0;
return ret; return ret;
} }