[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87wmlbfdl9.fsf@intel.com>
Date: Wed, 24 Jul 2024 10:34:10 +0300
From: Jani Nikula <jani.nikula@...ux.intel.com>
To: Philipp Stanner <pstanner@...hat.com>, Luben Tuikov
<ltuikov89@...il.com>, Matthew Brost <matthew.brost@...el.com>, Maarten
Lankhorst <maarten.lankhorst@...ux.intel.com>, Maxime Ripard
<mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>, David
Airlie <airlied@...il.com>, Daniel Vetter <daniel@...ll.ch>
Cc: dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org, Philipp
Stanner <pstanner@...hat.com>, Marco Pagani <marpagan@...hat.com>
Subject: Re: [PATCH] drm/scheduler: Use ternary operator in standardized manner
On Mon, 15 Jul 2024, Philipp Stanner <pstanner@...hat.com> wrote:
> drm_sched_init() omits the middle operand when using the ternary
> operator to set the timeout_wq if one has been passed.
>
> This is a non-standardized GNU extension to the C language [1].
>
> It decreases code readability and might be read as a bug. Furthermore,
> it is not consistent with all other places in drm/scheduler where the
> ternary operator is used.
>
> Replace the expression with the standard one.
The GCC extension is widely used in the kernel for brevity. Arguably
duplicating the first operand is more error prone than omitting it.
Consistency within scheduler may be a valid point, but I'd consider
removing the redundant middle operand instead.
BR,
Jani.
>
> [1] https://gcc.gnu.org/onlinedocs/gcc-14.1.0/gcc/Conditionals.html
>
> Suggested-by: Marco Pagani <marpagan@...hat.com>
> Signed-off-by: Philipp Stanner <pstanner@...hat.com>
> ---
> drivers/gpu/drm/scheduler/sched_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
> index 7e90c9f95611..02cf9c37a232 100644
> --- a/drivers/gpu/drm/scheduler/sched_main.c
> +++ b/drivers/gpu/drm/scheduler/sched_main.c
> @@ -1257,7 +1257,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched,
> sched->credit_limit = credit_limit;
> sched->name = name;
> sched->timeout = timeout;
> - sched->timeout_wq = timeout_wq ? : system_wq;
> + sched->timeout_wq = timeout_wq ? timeout_wq : system_wq;
> sched->hang_limit = hang_limit;
> sched->score = score ? score : &sched->_score;
> sched->dev = dev;
--
Jani Nikula, Intel
Powered by blists - more mailing lists