Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: core: Do not declare scsi_cmnd pointers const

This change allows removing multiple casts and hence improves type
checking by the compiler.

Cc: Hannes Reinecke <hare@suse.de>
Suggested-by: John Garry <john.g.garry@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Link: https://patch.msgid.link/20251014220426.3690007-1-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
ce085ecd 3d0d1c7a

+14 -15
+10 -11
drivers/scsi/scsi_logging.c
··· 26 26 kfree(bufptr); 27 27 } 28 28 29 - static inline const char *scmd_name(const struct scsi_cmnd *scmd) 29 + static inline const char *scmd_name(struct scsi_cmnd *scmd) 30 30 { 31 - struct request *rq = scsi_cmd_to_rq((struct scsi_cmnd *)scmd); 31 + const struct request *rq = scsi_cmd_to_rq(scmd); 32 32 33 33 if (!rq->q || !rq->q->disk) 34 34 return NULL; ··· 80 80 } 81 81 EXPORT_SYMBOL(sdev_prefix_printk); 82 82 83 - void scmd_printk(const char *level, const struct scsi_cmnd *scmd, 84 - const char *fmt, ...) 83 + void scmd_printk(const char *level, struct scsi_cmnd *scmd, const char *fmt, 84 + ...) 85 85 { 86 86 va_list args; 87 87 char *logbuf; ··· 94 94 if (!logbuf) 95 95 return; 96 96 off = sdev_format_header(logbuf, logbuf_len, scmd_name(scmd), 97 - scsi_cmd_to_rq((struct scsi_cmnd *)scmd)->tag); 97 + scsi_cmd_to_rq(scmd)->tag); 98 98 if (off < logbuf_len) { 99 99 va_start(args, fmt); 100 100 off += vscnprintf(logbuf + off, logbuf_len - off, fmt, args); ··· 371 371 EXPORT_SYMBOL(__scsi_print_sense); 372 372 373 373 /* Normalize and print sense buffer in SCSI command */ 374 - void scsi_print_sense(const struct scsi_cmnd *cmd) 374 + void scsi_print_sense(struct scsi_cmnd *cmd) 375 375 { 376 376 scsi_log_print_sense(cmd->device, scmd_name(cmd), 377 - scsi_cmd_to_rq((struct scsi_cmnd *)cmd)->tag, 378 - cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE); 377 + scsi_cmd_to_rq(cmd)->tag, cmd->sense_buffer, 378 + SCSI_SENSE_BUFFERSIZE); 379 379 } 380 380 EXPORT_SYMBOL(scsi_print_sense); 381 381 382 - void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg, 383 - int disposition) 382 + void scsi_print_result(struct scsi_cmnd *cmd, const char *msg, int disposition) 384 383 { 385 384 char *logbuf; 386 385 size_t off, logbuf_len; ··· 392 393 return; 393 394 394 395 off = sdev_format_header(logbuf, logbuf_len, scmd_name(cmd), 395 - scsi_cmd_to_rq((struct scsi_cmnd *)cmd)->tag); 396 + scsi_cmd_to_rq(cmd)->tag); 396 397 397 398 if (off >= logbuf_len) 398 399 goto out_printk;
+2 -2
include/scsi/scsi_dbg.h
··· 11 11 const unsigned char *, size_t); 12 12 extern void scsi_print_sense_hdr(const struct scsi_device *, const char *, 13 13 const struct scsi_sense_hdr *); 14 - extern void scsi_print_sense(const struct scsi_cmnd *); 14 + extern void scsi_print_sense(struct scsi_cmnd *); 15 15 extern void __scsi_print_sense(const struct scsi_device *, const char *name, 16 16 const unsigned char *sense_buffer, 17 17 int sense_len); 18 - extern void scsi_print_result(const struct scsi_cmnd *, const char *, int); 18 + extern void scsi_print_result(struct scsi_cmnd *, const char *, int); 19 19 20 20 #ifdef CONFIG_SCSI_CONSTANTS 21 21 extern bool scsi_opcode_sa_name(int, int, const char **, const char **);
+2 -2
include/scsi/scsi_device.h
··· 313 313 #define sdev_printk(l, sdev, fmt, a...) \ 314 314 sdev_prefix_printk(l, sdev, NULL, fmt, ##a) 315 315 316 - __printf(3, 4) void 317 - scmd_printk(const char *, const struct scsi_cmnd *, const char *, ...); 316 + __printf(3, 4) void scmd_printk(const char *, struct scsi_cmnd *, const char *, 317 + ...); 318 318 319 319 #define scmd_dbg(scmd, fmt, a...) \ 320 320 do { \