mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-21 23:20:35 +08:00
orb: avoid unnecessary string duplication of objname
This commit is contained in:
@@ -673,18 +673,12 @@ uORB::DeviceMaster::ioctl(struct file *filp, int cmd, unsigned long arg)
|
|||||||
*(adv->instance) = group_tries;
|
*(adv->instance) = group_tries;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* driver wants a permanent copy of the node name, so make one here */
|
objname = meta->o_name; //no need for a copy, meta->o_name will never be freed or changed
|
||||||
objname = strdup(meta->o_name);
|
|
||||||
|
|
||||||
if (objname == nullptr) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* driver wants a permanent copy of the path, so make one here */
|
/* driver wants a permanent copy of the path, so make one here */
|
||||||
devpath = strdup(nodepath);
|
devpath = strdup(nodepath);
|
||||||
|
|
||||||
if (devpath == nullptr) {
|
if (devpath == nullptr) {
|
||||||
free((void *)objname);
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -693,7 +687,6 @@ uORB::DeviceMaster::ioctl(struct file *filp, int cmd, unsigned long arg)
|
|||||||
|
|
||||||
/* if we didn't get a device, that's bad */
|
/* if we didn't get a device, that's bad */
|
||||||
if (node == nullptr) {
|
if (node == nullptr) {
|
||||||
free((void *)objname);
|
|
||||||
free((void *)devpath);
|
free((void *)devpath);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
@@ -720,7 +713,6 @@ uORB::DeviceMaster::ioctl(struct file *filp, int cmd, unsigned long arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* also discard the name now */
|
/* also discard the name now */
|
||||||
free((void *)objname);
|
|
||||||
free((void *)devpath);
|
free((void *)devpath);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -679,18 +679,12 @@ uORB::DeviceMaster::ioctl(device::file_t *filp, int cmd, unsigned long arg)
|
|||||||
*(adv->instance) = group_tries;
|
*(adv->instance) = group_tries;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* driver wants a permanent copy of the node name, so make one here */
|
objname = meta->o_name; //no need for a copy, meta->o_name will never be freed or changed
|
||||||
objname = strdup(meta->o_name);
|
|
||||||
|
|
||||||
if (objname == nullptr) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* driver wants a permanent copy of the path, so make one here */
|
/* driver wants a permanent copy of the path, so make one here */
|
||||||
devpath = strdup(nodepath);
|
devpath = strdup(nodepath);
|
||||||
|
|
||||||
if (devpath == nullptr) {
|
if (devpath == nullptr) {
|
||||||
free((void *)objname);
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -699,7 +693,6 @@ uORB::DeviceMaster::ioctl(device::file_t *filp, int cmd, unsigned long arg)
|
|||||||
|
|
||||||
/* if we didn't get a device, that's bad */
|
/* if we didn't get a device, that's bad */
|
||||||
if (node == nullptr) {
|
if (node == nullptr) {
|
||||||
free((void *)objname);
|
|
||||||
free((void *)devpath);
|
free((void *)devpath);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
@@ -726,7 +719,6 @@ uORB::DeviceMaster::ioctl(device::file_t *filp, int cmd, unsigned long arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* also discard the name now */
|
/* also discard the name now */
|
||||||
free((void *)objname);
|
|
||||||
free((void *)devpath);
|
free((void *)devpath);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user