All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH linu-next V2] mm/fault: fix comparing pointer to 0
@ 2022-09-18 15:29 cgel.zte
  2022-09-18 21:57 ` Eric W. Biederman
  0 siblings, 1 reply; 2+ messages in thread
From: cgel.zte @ 2022-09-18 15:29 UTC (permalink / raw)
  To: richard.henderson
  Cc: ink, mattst88, akpm, zhengqi.arch, ebiederm, hannes,
	catalin.marinas, peterx, linux-alpha, linux-kernel, Xu Panda,
	Zeal Robot

From: Xu Panda <xu.panda@zte.com.cn>

Do not use assignment in if condition,
and comparing pointer whith NULL instead of comparing pointer to 0.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
---
 arch/alpha/mm/fault.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
index ef427a6bdd1a..bb3fe2949313 100644
--- a/arch/alpha/mm/fault.c
+++ b/arch/alpha/mm/fault.c
@@ -194,7 +194,8 @@ do_page_fault(unsigned long address, unsigned long
mmcsr,

  no_context:
        /* Are we prepared to handle this fault as an exception?  */
-       if ((fixup = search_exception_tables(regs->pc)) != 0) {
+       fixup = search_exception_tables(regs->pc);
+       if (fixup != NULL) {
                unsigned long newpc;
                newpc = fixup_exception(dpf_reg, fixup, regs->pc);
                regs->pc = newpc;
-- 
2.15.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH linu-next V2] mm/fault: fix comparing pointer to 0
  2022-09-18 15:29 [PATCH linu-next V2] mm/fault: fix comparing pointer to 0 cgel.zte
@ 2022-09-18 21:57 ` Eric W. Biederman
  0 siblings, 0 replies; 2+ messages in thread
From: Eric W. Biederman @ 2022-09-18 21:57 UTC (permalink / raw)
  To: cgel.zte
  Cc: richard.henderson, ink, mattst88, akpm, zhengqi.arch, hannes,
	catalin.marinas, peterx, linux-alpha, linux-kernel, Xu Panda,
	Zeal Robot

cgel.zte@gmail.com writes:

> From: Xu Panda <xu.panda@zte.com.cn>
>
> Do not use assignment in if condition,
> and comparing pointer whith NULL instead of comparing pointer to 0.

Then sensible thing to do if fixup is a pointer value is to just say:

"if (fixup) {"

That will be clearer and not match the pattern you are trying to avoid.

Eric

>
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
> ---
>  arch/alpha/mm/fault.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
> index ef427a6bdd1a..bb3fe2949313 100644
> --- a/arch/alpha/mm/fault.c
> +++ b/arch/alpha/mm/fault.c
> @@ -194,7 +194,8 @@ do_page_fault(unsigned long address, unsigned long
> mmcsr,
>
>   no_context:
>         /* Are we prepared to handle this fault as an exception?  */
> -       if ((fixup = search_exception_tables(regs->pc)) != 0) {
> +       fixup = search_exception_tables(regs->pc);
> +       if (fixup != NULL) {
>                 unsigned long newpc;
>                 newpc = fixup_exception(dpf_reg, fixup, regs->pc);
>                 regs->pc = newpc;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-18 21:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-18 15:29 [PATCH linu-next V2] mm/fault: fix comparing pointer to 0 cgel.zte
2022-09-18 21:57 ` Eric W. Biederman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.