Message ID | 20240130055844.19811-1-caoqq@fujitsu.com |
---|---|
State | New, archived |
Headers | show |
Series | cxl/mbox: Code readability improvement | expand |
Quanquan Cao wrote: > "send_cmd->id == 0" indicates an invalid command, so replace 0 > to CXL_MEM_COMMAND_ID_INVALID to make it easy for reading/understanding. > > Signed-off-by: Quanquan Cao <caoqq@fujitsu.com> > --- > drivers/cxl/core/mbox.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c > index 27166a411705..2e5ee05011d6 100644 > --- a/drivers/cxl/core/mbox.c > +++ b/drivers/cxl/core/mbox.c > @@ -485,7 +485,8 @@ static int cxl_validate_cmd_from_user(struct cxl_mbox_cmd *mbox_cmd, > struct cxl_mem_command mem_cmd; > int rc; > > - if (send_cmd->id == 0 || send_cmd->id >= CXL_MEM_COMMAND_ID_MAX) "non-zero" is readable to me, and less characters to parse means current code is literally easier to read.
> Quanquan Cao wrote: >> "send_cmd->id == 0" indicates an invalid command, so replace 0 >> to CXL_MEM_COMMAND_ID_INVALID to make it easy for reading/understanding. >> >> Signed-off-by: Quanquan Cao <caoqq@fujitsu.com> >> --- >> drivers/cxl/core/mbox.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c >> index 27166a411705..2e5ee05011d6 100644 >> --- a/drivers/cxl/core/mbox.c >> +++ b/drivers/cxl/core/mbox.c >> @@ -485,7 +485,8 @@ static int cxl_validate_cmd_from_user(struct cxl_mbox_cmd *mbox_cmd, >> struct cxl_mem_command mem_cmd; >> int rc; >> >> - if (send_cmd->id == 0 || send_cmd->id >= CXL_MEM_COMMAND_ID_MAX) > > "non-zero" is readable to me, and less characters to parse means current > code is literally easier to read. Thanks, I got.
diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index 27166a411705..2e5ee05011d6 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -485,7 +485,8 @@ static int cxl_validate_cmd_from_user(struct cxl_mbox_cmd *mbox_cmd, struct cxl_mem_command mem_cmd; int rc; - if (send_cmd->id == 0 || send_cmd->id >= CXL_MEM_COMMAND_ID_MAX) + if (send_cmd->id == CXL_MEM_COMMAND_ID_INVALID || + send_cmd->id >= CXL_MEM_COMMAND_ID_MAX) return -ENOTTY; /*
"send_cmd->id == 0" indicates an invalid command, so replace 0 to CXL_MEM_COMMAND_ID_INVALID to make it easy for reading/understanding. Signed-off-by: Quanquan Cao <caoqq@fujitsu.com> --- drivers/cxl/core/mbox.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)