[libvirt PATCH v2 01/12] nodedev: don't log error in nodeDeviceFindAddressByName()

Jonathon Jongsma posted 12 patches 4 years, 10 months ago
[libvirt PATCH v2 01/12] nodedev: don't log error in nodeDeviceFindAddressByName()
Posted by Jonathon Jongsma 4 years, 10 months ago
The calling function will log the error. Just return NULL if a device
cannot be found.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
---
 src/node_device/node_device_driver.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 5f8995172d..4cf4e4214f 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -630,11 +630,8 @@ nodeDeviceFindAddressByName(const char *name)
     char *addr = NULL;
     virNodeDeviceObj *dev = virNodeDeviceObjListFindByName(driver->devs, name);
 
-    if (!dev) {
-        virReportError(VIR_ERR_NO_NODE_DEVICE,
-                       _("could not find device '%s'"), name);
+    if (!dev)
         return NULL;
-    }
 
     def = virNodeDeviceObjGetDef(dev);
     for (caps = def->caps; caps != NULL; caps = caps->next) {
-- 
2.26.3

Re: [libvirt PATCH v2 01/12] nodedev: don't log error in nodeDeviceFindAddressByName()
Posted by Laine Stump 4 years, 10 months ago
On 4/13/21 4:39 PM, Jonathon Jongsma wrote:
> The calling function will log the error. Just return NULL if a device
> cannot be found.
> 
> Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>

Reviewed-by: Laine Stump <laine@redhat.com>

> ---
>   src/node_device/node_device_driver.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
> index 5f8995172d..4cf4e4214f 100644
> --- a/src/node_device/node_device_driver.c
> +++ b/src/node_device/node_device_driver.c
> @@ -630,11 +630,8 @@ nodeDeviceFindAddressByName(const char *name)
>       char *addr = NULL;
>       virNodeDeviceObj *dev = virNodeDeviceObjListFindByName(driver->devs, name);
>   
> -    if (!dev) {
> -        virReportError(VIR_ERR_NO_NODE_DEVICE,
> -                       _("could not find device '%s'"), name);
> +    if (!dev)
>           return NULL;
> -    }
>   
>       def = virNodeDeviceObjGetDef(dev);
>       for (caps = def->caps; caps != NULL; caps = caps->next) {
>