cxl: remove assignment from if condition in cxl_mem_get_poison
PATCH 1/1 cxl: remove assignment from if condition in cxl_mem_get_poison
From: Darshan Rathod <[email protected]>
Refactor cxl_mem_get_poison() to assign the return value of ACQUIRE_ERR() before the conditional check, instead of performing the assignment inside the if condition. This resolves a checkpatch.pl warning ("do not use assignment in if condition") and improves readability.
--- drivers/cxl/core/mbox.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/cxl/core/mbox.c +3 -1
@@ -1426,7 +1426,9 @@ int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len,int rc;ACQUIRE (mutex_intr, lock)(&mds->poison.mutex); -if ((rc =ACQUIRE_ERR (mutex_intr, &lock))) + + rc =ACQUIRE_ERR (mutex_intr, &lock); +if (rc)return rc; po = mds->poison.list_out;
Signature · 1 line
2.25.1
Quoted 9 lines · On Wed, 13 Aug 2025 17:25:54 +0530 [email protected] wrote:
From: Darshan Rathod <[email protected]>
Refactor
cxl_mem_get_poison()to assign the return value ofACQUIRE_ERR()before the conditional check, instead of performing the assignment inside the if condition. This resolves a checkpatch.pl warning ("do not use assignment in if condition") and improves readability.Signed-off-by Darshan Rathod <[email protected]>
See:
https://lore.kernel.org/all/[email protected]/
Which stops checkpatch complaining about this.
Let's see where that discussion ends up before considering 'fixing' this.
Jonathan
Quoted 19 lines
--- drivers/cxl/core/mbox.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/cxl/core/mbox.c +3
-1@@ -1426,7 +1426,9 @@ int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len,int rc;ACQUIRE (mutex_intr, lock)(&mds->poison.mutex); -if ((rc =ACQUIRE_ERR (mutex_intr, &lock))) + + rc =ACQUIRE_ERR (mutex_intr, &lock); +if (rc)return rc; po = mds->poison.list_out;
Hi Jonathan,
Thanks for pointing that out.
I’ll hold off on this change and wait for the outcome of Alison’s patch discussion before proceeding further.
Regards,
Darshan
Quoted 41 lines · Jonathan Cameron
Quoted 9 lines · On Wed, 13 Aug 2025 17:25:54 +0530 [email protected] wrote:
From: Darshan Rathod <[email protected]>
Refactor
cxl_mem_get_poison()to assign the return value ofACQUIRE_ERR()before the conditional check, instead of performing the assignment inside the if condition. This resolves a checkpatch.pl warning ("do not use assignment in if condition") and improves readability.Signed-off-by Darshan Rathod <[email protected]>See:
https://lore.kernel.org/all/[email protected]/Which stops checkpatch complaining about this.
Let's see where that discussion ends up before considering 'fixing' this.Jonathan
Quoted 19 lines
--- drivers/cxl/core/mbox.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/cxl/core/mbox.c +3
-1@@ -1426,7 +1426,9 @@ int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len,int rc;ACQUIRE (mutex_intr, lock)(&mds->poison.mutex); -if ((rc =ACQUIRE_ERR (mutex_intr, &lock))) + + rc =ACQUIRE_ERR (mutex_intr, &lock); +if (rc)return rc; po = mds->poison.list_out;