[libvirt] [PATCH 1/3] vsh: Mark cmdComplete arguments as unused

Michal Privoznik posted 3 patches 7 years, 4 months ago
[libvirt] [PATCH 1/3] vsh: Mark cmdComplete arguments as unused
Posted by Michal Privoznik 7 years, 4 months ago
When building without readline, this function does nothing but
return false. Without touching any of its arguments. Therefore,
we have to mark them as unused even though they might be used
when building with readline support.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 tools/vsh.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/vsh.c b/tools/vsh.c
index 4426c08d6..88561ef61 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -3500,7 +3500,8 @@ const vshCmdInfo info_complete[] = {
 };
 
 bool
-cmdComplete(vshControl *ctl, const vshCmd *cmd)
+cmdComplete(vshControl *ctl ATTRIBUTE_UNUSED,
+            const vshCmd *cmd ATTRIBUTE_UNUSED)
 {
     bool ret = false;
 #ifdef WITH_READLINE
-- 
2.13.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/3] vsh: Mark cmdComplete arguments as unused
Posted by Erik Skultety 7 years, 3 months ago
On Sun, Jan 14, 2018 at 02:46:43PM +0100, Michal Privoznik wrote:
> When building without readline, this function does nothing but
> return false. Without touching any of its arguments. Therefore,
> we have to mark them as unused even though they might be used
> when building with readline support.
>
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  tools/vsh.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/vsh.c b/tools/vsh.c
> index 4426c08d6..88561ef61 100644
> --- a/tools/vsh.c
> +++ b/tools/vsh.c
> @@ -3500,7 +3500,8 @@ const vshCmdInfo info_complete[] = {
>  };
>
>  bool
> -cmdComplete(vshControl *ctl, const vshCmd *cmd)
> +cmdComplete(vshControl *ctl ATTRIBUTE_UNUSED,
> +            const vshCmd *cmd ATTRIBUTE_UNUSED)
>  {
>      bool ret = false;
>  #ifdef WITH_READLINE

Hmm, I have no problem with this, although, I kinda find the usage of
ATTRIBUTE_UNUSED a bit obfuscated here, especially if compiled with readline,
since one might not see the connection at first glance - I think we might want
to go down the usual road and have a separate definition of the function in the
distinct preprocessor branches, I know, more lines, but IMHO it enhances the
readability.
Just my 2 cents.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Erik

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list