Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: James Bottomley <James.Bottomley@HansenPartnership.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, Damien Le Moal <dlemoal@kernel.org>,
	John Garry <john.g.garry@oracle.com>
Subject: Re: [PATCH] scsi: Change the return type of the .queuecommand() callback
Date: Wed, 7 Jan 2026 09:09:51 -0800	[thread overview]
Message-ID: <0a831985-a52d-4b93-8aa1-ad67b99af88c@acm.org> (raw)
In-Reply-To: <f9f4833e9667e9e0a0e94d656fe8138c06705e93.camel@HansenPartnership.com>

On 1/7/26 5:36 AM, James Bottomley wrote:
> On Tue, 2026-01-06 at 11:52 -0700, Bart Van Assche wrote:
>> Let the compiler verify whether a valid value is returned by the
>> .queuecommand() implementations by changing their return type from
>> 'int' into 'enum scsi_qc_status'.
> 
> What makes you think the C compiler checks enum values?  Traditionally
> the opposite has been true: enum is just a fancy #define, which is how
> we use it in a lot of the kernel code.  Even if the compiler people
> came up with a switch to turn on this behaviour, we'd likely have
> trouble turning it on without eliminating all the fancy #define use.

If I revert commit e414748b7e83 ("scsi: aacraid: Improve code 
readability") and build the kernel with the git HEAD of clang with this
patch applied then following error message appears:

drivers/scsi/aacraid/linit.c:245:29: error: implicit conversion from 
enumeration
       type 'enum scsi_disposition' to different enumeration type
       'enum scsi_qc_status' [-Werror,-Wimplicit-enum-enum-cast]
   245 |         return aac_scsi_cmd(cmd) ? FAILED : 0;
       |         ~~~~~~                     ^~~~~~

This patch also helps those who build the kernel with gcc because the
zero-day infrastructure builds the kernel with both gcc and clang and
hence will spot it if an incorrect value is returned from a queuecommand
function.

I will improve the patch description when I repost this patch and will
change "compiler" into "clang 21.1 or later".

Thanks,

Bart.

      reply	other threads:[~2026-01-07 17:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-06 18:52 [PATCH] scsi: Change the return type of the .queuecommand() callback Bart Van Assche
2026-01-07  8:58 ` John Garry
2026-01-07 12:36 ` James Bottomley
2026-01-07 17:09   ` Bart Van Assche [this message]

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=0a831985-a52d-4b93-8aa1-ad67b99af88c@acm.org \
    --to=bvanassche@acm.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=dlemoal@kernel.org \
    --cc=john.g.garry@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox