Skip to contentSkip to conversation

cxl : fix cxlctl_validate_hw_command() warn: always true condition

PATCH In review [email protected] 2 participants 2 messages Apr 7, 2025 CXL

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cxl : fix cxlctl_validate_hw_command() warn: always true condition

From: Pei Xiao <[email protected]>

smatch warnings:

    drivers/cxl/core/features.c:441 cxlctl_validate_hw_command()
    warn: always true condition '(scope >= 0) => (0-u32max >= 0)'

remove always true condition.

---
 drivers/cxl/core/features.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/cxl/core/features.c +1 -2
index f4daefe3180e..fdca93c984ce 100644
@@ -616,9 +616,8 @@ static bool cxlctl_validate_hw_command(struct cxl_features_state *cxlfs,
 	case CXL_MBOX_OP_GET_FEATURE:
 		if (cxl_mbox->feat_cap < CXL_FEATURES_RO)
 			return false;
-		if (scope >= FWCTL_RPC_CONFIGURATION)
+		else
 			return true;
-		return false;
 	case CXL_MBOX_OP_SET_FEATURE:
 		if (cxl_mbox->feat_cap < CXL_FEATURES_RW)
 			return false;
Signature · 1 line
2.25.1
reviewer
#1 lore raw
Quoted 18 lines · On 4/7/2025 11:41 AM, [email protected] wrote:

From: Pei Xiao <[email protected]>

smatch warnings:

    drivers/cxl/core/features.c:441 cxlctl_validate_hw_command()
    warn: always true condition '(scope >= 0) => (0-u32max >= 0)'

remove always true condition.

---
 drivers/cxl/core/features.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/cxl/core/features.c +0 -0
index f4daefe3180e..fdca93c984ce 100644

drivers/cxl/core/features.c static bool cxlctl_validate_hw_command(struct cxl_features_state *cxlfs, · line 623

Quoted 10 lines
drivers/cxl/core/features.c +1 -2
@@ -616,9 +616,8 @@ static bool cxlctl_validate_hw_command(struct cxl_features_state *cxlfs,
 	case CXL_MBOX_OP_GET_FEATURE:
 		if (cxl_mbox->feat_cap < CXL_FEATURES_RO)
 			return false;
-		if (scope >= FWCTL_RPC_CONFIGURATION)
+		else
 			return true;
-		return false;
 	case CXL_MBOX_OP_SET_FEATURE:
 		if (cxl_mbox->feat_cap < CXL_FEATURES_RW)
 			return false;

Already have a patch posted for this issue.

https://lore.kernel.org/linux-cxl/[email protected]/T/#m84c3093032b5eb167bbb1d0a787019d0387f4ae8