mbox series

[0/2] ublk: specify io_cmd_buf pointer type

Message ID 20250328194230.2726862-1-csander@purestorage.com (mailing list archive)
Headers show
Series ublk: specify io_cmd_buf pointer type | expand

Message

Caleb Sander Mateos March 28, 2025, 7:42 p.m. UTC
io_cmd_buf points to an array of ublksrv_io_desc structs but its type is
char *. Indexing the array requires an explicit multiplication and cast.
The compiler also can't check the pointer types.

Change io_cmd_buf's type to struct ublksrv_io_desc * so it can be
indexed directly and the compiler can type-check the code.

Make the same change to the ublk selftests.

Caleb Sander Mateos (2):
  ublk: specify io_cmd_buf pointer type
  selftests: ublk: specify io_cmd_buf pointer type

 drivers/block/ublk_drv.c             | 8 ++++----
 tools/testing/selftests/ublk/kublk.c | 2 +-
 tools/testing/selftests/ublk/kublk.h | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

Comments

Jens Axboe March 28, 2025, 11:04 p.m. UTC | #1
On 3/28/25 1:42 PM, Caleb Sander Mateos wrote:
> io_cmd_buf points to an array of ublksrv_io_desc structs but its type is
> char *. Indexing the array requires an explicit multiplication and cast.
> The compiler also can't check the pointer types.
> 
> Change io_cmd_buf's type to struct ublksrv_io_desc * so it can be
> indexed directly and the compiler can type-check the code.
> 
> Make the same change to the ublk selftests.

Looks good to me, nice cleanup, more readable now.
Shuah Khan March 28, 2025, 11:58 p.m. UTC | #2
On 3/28/25 13:42, Caleb Sander Mateos wrote:
> io_cmd_buf points to an array of ublksrv_io_desc structs but its type is
> char *. Indexing the array requires an explicit multiplication and cast.
> The compiler also can't check the pointer types.
> 
> Change io_cmd_buf's type to struct ublksrv_io_desc * so it can be
> indexed directly and the compiler can type-check the code.
> 
> Make the same change to the ublk selftests.
> 
> Caleb Sander Mateos (2):
>    ublk: specify io_cmd_buf pointer type
>    selftests: ublk: specify io_cmd_buf pointer type
> 
>   drivers/block/ublk_drv.c             | 8 ++++----
>   tools/testing/selftests/ublk/kublk.c | 2 +-
>   tools/testing/selftests/ublk/kublk.h | 4 ++--
>   3 files changed, 7 insertions(+), 7 deletions(-)
> 

For selftests changes:

Acked-by: Shuah Khan <skhan@linuxfoundation.org>

thanks,
-- Shuah
Ming Lei March 29, 2025, 12:24 a.m. UTC | #3
On Fri, Mar 28, 2025 at 01:42:28PM -0600, Caleb Sander Mateos wrote:
> io_cmd_buf points to an array of ublksrv_io_desc structs but its type is
> char *. Indexing the array requires an explicit multiplication and cast.
> The compiler also can't check the pointer types.
> 
> Change io_cmd_buf's type to struct ublksrv_io_desc * so it can be
> indexed directly and the compiler can type-check the code.
> 
> Make the same change to the ublk selftests.
> 
> Caleb Sander Mateos (2):
>   ublk: specify io_cmd_buf pointer type
>   selftests: ublk: specify io_cmd_buf pointer type
> 
>  drivers/block/ublk_drv.c             | 8 ++++----
>  tools/testing/selftests/ublk/kublk.c | 2 +-
>  tools/testing/selftests/ublk/kublk.h | 4 ++--
>  3 files changed, 7 insertions(+), 7 deletions(-)

Reviewed-by: Ming Lei <ming.lei@redhat.com>

Thanks,
Ming
Jens Axboe March 29, 2025, 11:57 a.m. UTC | #4
On Fri, 28 Mar 2025 13:42:28 -0600, Caleb Sander Mateos wrote:
> io_cmd_buf points to an array of ublksrv_io_desc structs but its type is
> char *. Indexing the array requires an explicit multiplication and cast.
> The compiler also can't check the pointer types.
> 
> Change io_cmd_buf's type to struct ublksrv_io_desc * so it can be
> indexed directly and the compiler can type-check the code.
> 
> [...]

Applied, thanks!

[1/2] ublk: specify io_cmd_buf pointer type
      commit: 9a45714fc51321ea8f5e5567f70e06753a848f62
[2/2] selftests: ublk: specify io_cmd_buf pointer type
      commit: 25aaa81371e7db34ddb42c69ed4f6c5bc8de2afa

Best regards,