[PATCH] node_device: fix missing return from function nodedevRegister

jcfaracco@gmail.com posted 1 patch 1 year, 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20221024230727.91405-1-jcfaracco@gmail.com
src/node_device/node_device_driver.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] node_device: fix missing return from function nodedevRegister
Posted by jcfaracco@gmail.com 1 year, 5 months ago
From: Julio Faracco <jcfaracco@gmail.com>

The function nodedevRegister() (or all register functions) requires an
integer as a return. That function is not returning a value when UDEV is
not set. This commit just adds a generic return for that specific case.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
---
 src/node_device/node_device_driver.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 8e93b0dd6f..4d51851cfd 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -1584,6 +1584,8 @@ nodedevRegister(void)
 {
 #ifdef WITH_UDEV
     return udevNodeRegister();
+#else
+    return 0;
 #endif
 }
 
-- 
2.37.3
Re: [PATCH] node_device: fix missing return from function nodedevRegister
Posted by Michal Prívozník 1 year, 5 months ago
On 10/25/22 01:07, jcfaracco@gmail.com wrote:
> From: Julio Faracco <jcfaracco@gmail.com>
> 
> The function nodedevRegister() (or all register functions) requires an
> integer as a return. That function is not returning a value when UDEV is
> not set. This commit just adds a generic return for that specific case.
> 
> Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
> ---
>  src/node_device/node_device_driver.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
> index 8e93b0dd6f..4d51851cfd 100644
> --- a/src/node_device/node_device_driver.c
> +++ b/src/node_device/node_device_driver.c
> @@ -1584,6 +1584,8 @@ nodedevRegister(void)
>  {
>  #ifdef WITH_UDEV
>      return udevNodeRegister();
> +#else
> +    return 0;
>  #endif

Technically, this patch is correct. Because if WITH_UDEV is undefined
then this is an empty body function. But in that case this source file
shouldn't be compiled at all, because src/node_device/meson.build has:

if conf.has('WITH_NODE_DEVICES')
  node_device_driver_impl = static_library(
    'virt_driver_nodedev_impl',
    [
      node_device_driver_sources,
    ],
  ...
endif

and toplevel meson.build has:

if udev_dep.found() and conf.has('WITH_LIBVIRTD')
  conf.set('WITH_NODE_DEVICES', 1)
endif


Therefore, I'm failing to see how the driver is even attempted to be
compiled without udev, at which point the function is not empty bodied.

If anything, we should remove WITH_UDEV because that's the only backend
we support anyway.

Michal
Re: [PATCH] node_device: fix missing return from function nodedevRegister
Posted by Julio Faracco 1 year, 5 months ago
Em seg., 24 de out. de 2022 às 20:09, <jcfaracco@gmail.com> escreveu:
>
> From: Julio Faracco <jcfaracco@gmail.com>

My apologies folks. I simply configured a new machine today and I
forgot to remove some predefined settings I have.
If someone could suppress this section I would be glad. :-)

>
> The function nodedevRegister() (or all register functions) requires an
> integer as a return. That function is not returning a value when UDEV is
> not set. This commit just adds a generic return for that specific case.
>
> Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
> ---
>  src/node_device/node_device_driver.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
> index 8e93b0dd6f..4d51851cfd 100644
> --- a/src/node_device/node_device_driver.c
> +++ b/src/node_device/node_device_driver.c
> @@ -1584,6 +1584,8 @@ nodedevRegister(void)
>  {
>  #ifdef WITH_UDEV
>      return udevNodeRegister();
> +#else
> +    return 0;
>  #endif
>  }
>
> --
> 2.37.3
>