[PATCH] configure: Silence shift warning in version_ge()

Philippe Mathieu-Daudé posted 1 patch 3 years, 8 months ago
Test docker-quick@centos7 failed
Test docker-mingw@fedora failed
Test FreeBSD failed
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200821151416.1240494-1-philmd@redhat.com
configure | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] configure: Silence shift warning in version_ge()
Posted by Philippe Mathieu-Daudé 3 years, 8 months ago
As we might expect less than 2 argument, only shift again
if there is arguments to shift.

This fixes:

    ../configure: line 232: shift: shift count out of range

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 4e5fe332110..cf044ad2d25 100755
--- a/configure
+++ b/configure
@@ -229,7 +229,7 @@ version_ge () {
         set x $local_ver1
         local_first=${2-0}
         # shift 2 does nothing if there are less than 2 arguments
-        shift; shift
+        shift || shift
         local_ver1=$*
         set x $local_ver2
         # the second argument finished, the first must be greater or equal
-- 
2.26.2


Re: [PATCH] configure: Silence shift warning in version_ge()
Posted by Philippe Mathieu-Daudé 3 years, 8 months ago
On 8/21/20 5:14 PM, Philippe Mathieu-Daudé wrote:
> As we might expect less than 2 argument, only shift again
> if there is arguments to shift.
> 
> This fixes:
> 
>     ../configure: line 232: shift: shift count out of range
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  configure | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index 4e5fe332110..cf044ad2d25 100755
> --- a/configure
> +++ b/configure
> @@ -229,7 +229,7 @@ version_ge () {
>          set x $local_ver1
>          local_first=${2-0}
>          # shift 2 does nothing if there are less than 2 arguments
> -        shift; shift
> +        shift || shift

As Stefano noted, this does not work as intended, so please discard
this invalid patch.

>          local_ver1=$*
>          set x $local_ver2
>          # the second argument finished, the first must be greater or equal
>