Skip to content

Commit 9a45714

Browse files
calebsanderaxboe
authored andcommitted
ublk: specify io_cmd_buf pointer type
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. Signed-off-by: Caleb Sander Mateos <[email protected]> Reviewed-by: Ming Lei <[email protected]> Acked-by: Shuah Khan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent ea91067 commit 9a45714

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/block/ublk_drv.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ struct ublk_queue {
158158

159159
unsigned long flags;
160160
struct task_struct *ubq_daemon;
161-
char *io_cmd_buf;
161+
struct ublksrv_io_desc *io_cmd_buf;
162162

163163
bool force_abort;
164164
bool timeout;
@@ -706,11 +706,11 @@ static inline bool ublk_rq_has_data(const struct request *rq)
706706
static inline struct ublksrv_io_desc *ublk_get_iod(struct ublk_queue *ubq,
707707
int tag)
708708
{
709-
return (struct ublksrv_io_desc *)
710-
&(ubq->io_cmd_buf[tag * sizeof(struct ublksrv_io_desc)]);
709+
return &ubq->io_cmd_buf[tag];
711710
}
712711

713-
static inline char *ublk_queue_cmd_buf(struct ublk_device *ub, int q_id)
712+
static inline struct ublksrv_io_desc *
713+
ublk_queue_cmd_buf(struct ublk_device *ub, int q_id)
714714
{
715715
return ublk_get_queue(ub, q_id)->io_cmd_buf;
716716
}

0 commit comments

Comments
 (0)