mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-27 04:10:47 +00:00
system/uorb: Solve the problem of wrong use of return value
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
963d0680bd
commit
718fcfac1e
1 changed files with 4 additions and 2 deletions
|
|
@ -58,6 +58,7 @@ static int orb_advsub_open(FAR const struct orb_metadata *meta, int flags,
|
|||
char path[ORB_PATH_MAX];
|
||||
int fd;
|
||||
int ret;
|
||||
int err;
|
||||
|
||||
snprintf(path, ORB_PATH_MAX, ORB_SENSOR_PATH"%s%d", meta->o_name,
|
||||
instance);
|
||||
|
|
@ -83,8 +84,9 @@ static int orb_advsub_open(FAR const struct orb_metadata *meta, int flags,
|
|||
/* Register new device node */
|
||||
|
||||
ret = ioctl(fd, SNIOC_REGISTER, (unsigned long)(uintptr_t)®info);
|
||||
err = errno;
|
||||
close(fd);
|
||||
if (ret < 0 && ret != -EEXIST)
|
||||
if (ret < 0 && err != EEXIST)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -95,7 +97,7 @@ static int orb_advsub_open(FAR const struct orb_metadata *meta, int flags,
|
|||
return fd;
|
||||
}
|
||||
|
||||
if (ret != -EEXIST)
|
||||
if (err != EEXIST)
|
||||
{
|
||||
ioctl(fd, SNIOC_SET_USERPRIV, (unsigned long)(uintptr_t)meta);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue