From: Bart Van Assche <bvanassche@acm.org>
To: Douglas Gilbert <dgilbert@interlog.com>, linux-scsi@vger.kernel.org
Cc: martin.petersen@oracle.com, jejb@linux.vnet.ibm.com,
hare@suse.de, hch@lst.de
Subject: Re: [PATCH 1/6] scsi_cmnd: reinstate support for cmd_len > 32
Date: Fri, 8 Apr 2022 07:55:37 -0700 [thread overview]
Message-ID: <78f9dc98-cca8-6ba2-9146-082f95c8d5ab@acm.org> (raw)
In-Reply-To: <20220408035651.6472-2-dgilbert@interlog.com>
On 4/7/22 20:56, Douglas Gilbert wrote:
> static int scsi_eh_tur(struct scsi_cmnd *scmd)
> {
> - static unsigned char tur_command[6] = {TEST_UNIT_READY, 0, 0, 0, 0, 0};
> + static const u8 tur_command[6] = {TEST_UNIT_READY, 0, 0, 0, 0, 0};
> int retry_cnt = 1;
> enum scsi_disposition rtn;
>
> retry_tur:
> - rtn = scsi_send_eh_cmnd(scmd, tur_command, 6,
> - scmd->device->eh_timeout, 0);
> + rtn = scsi_send_eh_cmnd(scmd, (u8 *)tur_command, 6, scmd->device->eh_timeout, 0);
Does the cast in the above function call cast away constness? There must
be a better solution than casting away constness.
> -bool scsi_cmd_allowed(unsigned char *cmd, fmode_t mode)
> +bool scsi_cmd_allowed(/* const */ unsigned char *cmd, fmode_t mode)
> {
Why has 'const' been commented out?
> @@ -1460,6 +1462,7 @@ static void scsi_complete(struct request *rq)
> static int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
> {
> struct Scsi_Host *host = cmd->device->host;
> + u8 *cdb = (u8 *)scsi_cmnd_get_cdb(cmd);
> int rtn = 0;
Casting away constness is ugly. Consider providing two versions of
scsi_cmnd_get_cdb(): one version that accepts a const pointer and
returns a const pointer and another version that accepts a non-const
pointer and returns a non-const pointer. Maybe _Generic() or
__same_type() can be used to combine both versions into a single macro?
> +/* This value is used to size a C array, see below if cdb length > 32 */
> +#define SCSI_MAX_COMPILE_TIME_CDB_LEN 32
Since CDBs longer than 16 bytes are rare, how about using 16 as the
maximum compile-time CDB size?
Thanks,
Bart.
next prev parent reply other threads:[~2022-04-08 14:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-08 3:56 [PATCH 0/6] scsi: fix scsi_cmd::cmd_len Douglas Gilbert
2022-04-08 3:56 ` [PATCH 1/6] scsi_cmnd: reinstate support for cmd_len > 32 Douglas Gilbert
2022-04-08 5:16 ` Christoph Hellwig
2022-04-08 7:59 ` kernel test robot
2022-04-08 14:55 ` Bart Van Assche [this message]
2022-04-09 4:42 ` Douglas Gilbert
2022-04-09 21:38 ` Bart Van Assche
2022-04-08 3:56 ` [PATCH 2/6] sd, sd_zbc: use scsi_cmnd cdb access functions Douglas Gilbert
2022-04-08 3:56 ` [PATCH 3/6] sg: reinstate cmd_len > 32 Douglas Gilbert
2022-04-08 3:56 ` [PATCH 4/6] bsg: allow " Douglas Gilbert
2022-04-08 3:56 ` [PATCH 5/6] scsi_debug: reinstate " Douglas Gilbert
2022-04-08 3:56 ` [PATCH 6/6] st,sr: use scsi_cmnd cdb access functions and dtor Douglas Gilbert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=78f9dc98-cca8-6ba2-9146-082f95c8d5ab@acm.org \
--to=bvanassche@acm.org \
--cc=dgilbert@interlog.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.