[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CADnq5_MDPZbDrrgCCdWVfSX47it0=JvTj3k_W8woK6=O=qzCnQ@mail.gmail.com>
Date: Thu, 7 May 2020 15:41:31 -0400
From: Alex Deucher <alexdeucher@...il.com>
To: ChenTao <chentao107@...wei.com>
Cc: Dave Airlie <airlied@...ux.ie>, Daniel Vetter <daniel@...ll.ch>,
"Cyr, Aric" <Aric.Cyr@....com>,
"Leo (Sunpeng) Li" <sunpeng.li@....com>,
Anthony Koo <Anthony.Koo@....com>,
"Siqueira, Rodrigo" <Rodrigo.Siqueira@....com>, murton.liu@....com,
amd-gfx list <amd-gfx@...ts.freedesktop.org>,
LKML <linux-kernel@...r.kernel.org>,
Maling list - DRI developers
<dri-devel@...ts.freedesktop.org>,
"Wentland, Harry" <harry.wentland@....com>,
Sam Ravnborg <sam@...nborg.org>,
Christian Koenig <christian.koenig@....com>,
Su Sung Chung <Su.Chung@....com>
Subject: Re: [PATCH -next] drm/amd/dc: Remove a useless comparison
On Thu, May 7, 2020 at 9:35 AM ChenTao <chentao107@...wei.com> wrote:
>
> Fix the following warning:
>
> 'en' is uint32_t and can never be negative.
>
> drivers/gpu/drm/amd/amdgpu/../display/dc/gpio/hw_hpd.c:132:10: warning:
> comparison of unsigned expression < 0 is always false [-Wtype-limits]
> if ((en < GPIO_DDC_LINE_MIN) || (en > GPIO_DDC_LINE_MAX)) {
> drivers/gpu/drm/amd/amdgpu/../display/dc/gpio/hw_generic.c:109:10: warning:
> comparison of unsigned expression < 0 is always false [-Wtype-limits]
> if ((en < GPIO_DDC_LINE_MIN) || (en > GPIO_DDC_LINE_MAX)) {
>
While it's not required, I think it improves readability and protects
if the enum has negative values. I think it would be better to change
the en var to signed.
Alex
> Reported-by: Hulk Robot <hulkci@...wei.com>
> Signed-off-by: ChenTao <chentao107@...wei.com>
> ---
> drivers/gpu/drm/amd/display/dc/gpio/hw_generic.c | 2 +-
> drivers/gpu/drm/amd/display/dc/gpio/hw_hpd.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/gpio/hw_generic.c b/drivers/gpu/drm/amd/display/dc/gpio/hw_generic.c
> index f9e847e6555d..6cd50232c432 100644
> --- a/drivers/gpu/drm/amd/display/dc/gpio/hw_generic.c
> +++ b/drivers/gpu/drm/amd/display/dc/gpio/hw_generic.c
> @@ -106,7 +106,7 @@ void dal_hw_generic_init(
> enum gpio_id id,
> uint32_t en)
> {
> - if ((en < GPIO_DDC_LINE_MIN) || (en > GPIO_DDC_LINE_MAX)) {
> + if (en > GPIO_DDC_LINE_MAX) {
> ASSERT_CRITICAL(false);
> *hw_generic = NULL;
> }
> diff --git a/drivers/gpu/drm/amd/display/dc/gpio/hw_hpd.c b/drivers/gpu/drm/amd/display/dc/gpio/hw_hpd.c
> index 692f29de7797..f91f426699c0 100644
> --- a/drivers/gpu/drm/amd/display/dc/gpio/hw_hpd.c
> +++ b/drivers/gpu/drm/amd/display/dc/gpio/hw_hpd.c
> @@ -129,7 +129,7 @@ void dal_hw_hpd_init(
> enum gpio_id id,
> uint32_t en)
> {
> - if ((en < GPIO_DDC_LINE_MIN) || (en > GPIO_DDC_LINE_MAX)) {
> + if (en > GPIO_DDC_LINE_MAX) {
> ASSERT_CRITICAL(false);
> *hw_hpd = NULL;
> }
> --
> 2.22.0
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@...ts.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Powered by blists - more mailing lists