public inbox for linux-serial@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: xiaopeitux@foxmail.com
Cc: jirislaby@kernel.org, linux-serial@vger.kernel.org,
	linux-kernel@vger.kernel.org, Pei Xiao <xiaopei01@kylinos.cn>
Subject: Re: [PATCH] tty/sysrq: make sysrq_replay_logs_op const and refactor sysrq_mask()
Date: Thu, 3 Apr 2025 09:19:21 +0100	[thread overview]
Message-ID: <2025040313-gem-nephew-2327@gregkh> (raw)
In-Reply-To: <tencent_F413E4391B578208516E16AA0FC81F2FEC07@qq.com>

On Thu, Apr 03, 2025 at 03:15:35PM +0800, xiaopeitux@foxmail.com wrote:
> From: Pei Xiao <xiaopei01@kylinos.cn>
> 
> Mark sysrq_replay_logs_op as const and simplify sysrq_mask().
> 
> Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
> ---
>  drivers/tty/sysrq.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
> index f85ce02e4725..c2a26abcb8cd 100644
> --- a/drivers/tty/sysrq.c
> +++ b/drivers/tty/sysrq.c
> @@ -71,9 +71,7 @@ static bool sysrq_on(void)
>   */
>  int sysrq_mask(void)
>  {
> -	if (sysrq_always_enabled)
> -		return 1;
> -	return sysrq_enabled;
> +	return sysrq_always_enabled ? 1 : sysrq_enabled;

That's not simpler, it's now harder to read and parse.  Only use ?: in C
for places it has to be used, not for stuff like this where it's more
obvious if you use an if () line.

We write code for people first, compilers second.

Also, you can't do two different things in the same commit, sorry.

thanks,

greg k-h

      reply	other threads:[~2025-04-03  8:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-03  7:15 [PATCH] tty/sysrq: make sysrq_replay_logs_op const and refactor sysrq_mask() xiaopeitux
2025-04-03  8:19 ` Greg KH [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2025040313-gem-nephew-2327@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=xiaopei01@kylinos.cn \
    --cc=xiaopeitux@foxmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox