[PATCH] helpers: remove unnecessary `>= 0' checks on guint value

Aleksander Morgado aleksander at aleksander.es
Wed Jun 7 07:18:53 UTC 2017


On 07/06/17 00:10, Ben Chan wrote:
> This CL removes the unnecessary `>= 0' check on `mode_val' and
> `ind_val', which are both guint values extracted from a GArray with
> guint values, in mm_3gpp_parse_cmer_test_response to address the
> following compiler warnings:
> 
> mm-modem-helpers.c:2933:22: error: comparison of unsigned expression >=
> 0 is always true [-Werror,-Wtautological-compare]
>         if (mode_val >= 0 && mode_val <= 3)
>             ~~~~~~~~ ^  ~
> mm-modem-helpers.c:2943:21: error: comparison of unsigned expression >=
> 0 is always true [-Werror,-Wtautological-compare]
>         if (ind_val >= 0 && ind_val <= 2)
>             ~~~~~~~ ^  ~
> ---

Pushed to git master, thanks!

>  src/mm-modem-helpers.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c
> index ddf69406..73822e14 100644
> --- a/src/mm-modem-helpers.c
> +++ b/src/mm-modem-helpers.c
> @@ -2930,7 +2930,7 @@ mm_3gpp_parse_cmer_test_response (const gchar     *response,
>          guint mode_val;
>  
>          mode_val = g_array_index (array_supported_modes, guint, i);
> -        if (mode_val >= 0 && mode_val <= 3)
> +        if (mode_val <= 3)
>              supported_modes |= (MM3gppCmerMode) (1 << mode_val);
>          else
>              mm_dbg ("Unknown +CMER mode reported: %u", mode_val);
> @@ -2940,7 +2940,7 @@ mm_3gpp_parse_cmer_test_response (const gchar     *response,
>          guint ind_val;
>  
>          ind_val = g_array_index (array_supported_inds, guint, i);
> -        if (ind_val >= 0 && ind_val <= 2)
> +        if (ind_val <= 2)
>              supported_inds |= (MM3gppCmerInd) (1 << ind_val);
>          else
>              mm_dbg ("Unknown +CMER ind reported: %u", ind_val);
> 


-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list