2022-04-19 13:42:40

by Junwen Wu

[permalink] [raw]
Subject: [PATCH v2] tty/sysrq: change the definition of sysrq_key_table's element to make it more readable

From: Junwen Wu <[email protected]>

The definition of sysrq_key_table's elements, like sysrq_thaw_op and
sysrq_showallcpus_op are not consistent with sysrq_ftrace_dump_op,
Consistency makes code more readable.

Signed-off-by: Junwen Wu <[email protected]>
---
V1 -> V2: Fix some commit message's error

drivers/tty/sysrq.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index bbfd004449b5..9485156bf48b 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -274,6 +274,8 @@ static const struct sysrq_key_op sysrq_showallcpus_op = {
.action_msg = "Show backtrace of all active CPUs",
.enable_mask = SYSRQ_ENABLE_DUMP,
};
+#else
+#define sysrq_showallcpus_op (*(const struct sysrq_key_op *)NULL)
#endif

static void sysrq_handle_showregs(int key)
@@ -405,6 +407,7 @@ static const struct sysrq_key_op sysrq_moom_op = {
.enable_mask = SYSRQ_ENABLE_SIGNAL,
};

+#ifdef CONFIG_BLOCK
static void sysrq_handle_thaw(int key)
{
emergency_thaw_all();
@@ -415,6 +418,9 @@ static const struct sysrq_key_op sysrq_thaw_op = {
.action_msg = "Emergency Thaw of all frozen filesystems",
.enable_mask = SYSRQ_ENABLE_SIGNAL,
};
+#else
+#define sysrq_thaw_op (*(const struct sysrq_key_op *)NULL)
+#endif

static void sysrq_handle_kill(int key)
{
@@ -468,17 +474,9 @@ static const struct sysrq_key_op *sysrq_key_table[62] = {
NULL, /* g */
NULL, /* h - reserved for help */
&sysrq_kill_op, /* i */
-#ifdef CONFIG_BLOCK
&sysrq_thaw_op, /* j */
-#else
- NULL, /* j */
-#endif
&sysrq_SAK_op, /* k */
-#ifdef CONFIG_SMP
&sysrq_showallcpus_op, /* l */
-#else
- NULL, /* l */
-#endif
&sysrq_showmem_op, /* m */
&sysrq_unrt_op, /* n */
/* o: This will often be registered as 'Off' at init time */
--
2.25.1


2022-04-22 20:27:56

by Jiri Slaby

[permalink] [raw]
Subject: Re: [PATCH v2] tty/sysrq: change the definition of sysrq_key_table's element to make it more readable

On 18. 04. 22, 17:37, Junwen Wu wrote:
> From: Junwen Wu <[email protected]>
>
> The definition of sysrq_key_table's elements, like sysrq_thaw_op and
> sysrq_showallcpus_op are not consistent with sysrq_ftrace_dump_op,
> Consistency makes code more readable.

Reviewed-by: Jiri Slaby <[email protected]>

> Signed-off-by: Junwen Wu <[email protected]>
> ---
> V1 -> V2: Fix some commit message's error
>
> drivers/tty/sysrq.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
> index bbfd004449b5..9485156bf48b 100644
> --- a/drivers/tty/sysrq.c
> +++ b/drivers/tty/sysrq.c
> @@ -274,6 +274,8 @@ static const struct sysrq_key_op sysrq_showallcpus_op = {
> .action_msg = "Show backtrace of all active CPUs",
> .enable_mask = SYSRQ_ENABLE_DUMP,
> };
> +#else
> +#define sysrq_showallcpus_op (*(const struct sysrq_key_op *)NULL)
> #endif
>
> static void sysrq_handle_showregs(int key)
> @@ -405,6 +407,7 @@ static const struct sysrq_key_op sysrq_moom_op = {
> .enable_mask = SYSRQ_ENABLE_SIGNAL,
> };
>
> +#ifdef CONFIG_BLOCK
> static void sysrq_handle_thaw(int key)
> {
> emergency_thaw_all();
> @@ -415,6 +418,9 @@ static const struct sysrq_key_op sysrq_thaw_op = {
> .action_msg = "Emergency Thaw of all frozen filesystems",
> .enable_mask = SYSRQ_ENABLE_SIGNAL,
> };
> +#else
> +#define sysrq_thaw_op (*(const struct sysrq_key_op *)NULL)
> +#endif
>
> static void sysrq_handle_kill(int key)
> {
> @@ -468,17 +474,9 @@ static const struct sysrq_key_op *sysrq_key_table[62] = {
> NULL, /* g */
> NULL, /* h - reserved for help */
> &sysrq_kill_op, /* i */
> -#ifdef CONFIG_BLOCK
> &sysrq_thaw_op, /* j */
> -#else
> - NULL, /* j */
> -#endif
> &sysrq_SAK_op, /* k */
> -#ifdef CONFIG_SMP
> &sysrq_showallcpus_op, /* l */
> -#else
> - NULL, /* l */
> -#endif
> &sysrq_showmem_op, /* m */
> &sysrq_unrt_op, /* n */
> /* o: This will often be registered as 'Off' at init time */


--
js
suse labs