Linux block layer
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Anuj Gupta <anuj20.g@samsung.com>
Cc: vincent.fu@samsung.com, anuj1072538@gmail.com, axboe@kernel.dk,
	hch@infradead.org, martin.petersen@oracle.com,
	linux-block@vger.kernel.org, joshi.k@samsung.com
Subject: Re: [PATCH] block: fix lbmd_guard_tag_type assignment in FS_IOC_GETLBMD_CAP
Date: Tue, 22 Jul 2025 01:47:16 -0700	[thread overview]
Message-ID: <aH9QFHFjMG3fSEgL@infradead.org> (raw)
In-Reply-To: <aH9PwbpvMhTMUNl4@infradead.org>

On Tue, Jul 22, 2025 at 01:45:53AM -0700, Christoph Hellwig wrote:
> On Tue, Jul 22, 2025 at 01:49:11PM +0530, Anuj Gupta wrote:
> > +	switch (bi->csum_type) {
> > +	case BLK_INTEGRITY_CSUM_NONE:
> > +		meta_cap.lbmd_guard_tag_type = LBMD_PI_CSUM_NONE;
> > +		break;
> > +	case BLK_INTEGRITY_CSUM_IP:
> > +		meta_cap.lbmd_guard_tag_type = LBMD_PI_CSUM_IP;
> > +		break;
> > +	case BLK_INTEGRITY_CSUM_CRC:
> > +		meta_cap.lbmd_guard_tag_type = LBMD_PI_CSUM_CRC16_T10DIF;
> > +		break;
> > +	case BLK_INTEGRITY_CSUM_CRC64:
> > +		meta_cap.lbmd_guard_tag_type = LBMD_PI_CSUM_CRC64_NVME;
> > +		break;
> > +	default:
> > +		break;
> 
> This should catch and reject invalid values.  Otherwise the patch looks
> fine.

I guess reject is wrong, as the kernel is the source, but I think
a bit of validation here still makes sense.  I think if you just leave
the default out, the compiler would complain if we added a new value
to the union without handling it here, which should be enough.


      reply	other threads:[~2025-07-22  8:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20250722081938epcas5p12a1ee45419754afa2f1c1c9040d519d6@epcas5p1.samsung.com>
2025-07-22  8:19 ` [PATCH] block: fix lbmd_guard_tag_type assignment in FS_IOC_GETLBMD_CAP Anuj Gupta
2025-07-22  8:45   ` Christoph Hellwig
2025-07-22  8:47     ` Christoph Hellwig [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=aH9QFHFjMG3fSEgL@infradead.org \
    --to=hch@infradead.org \
    --cc=anuj1072538@gmail.com \
    --cc=anuj20.g@samsung.com \
    --cc=axboe@kernel.dk \
    --cc=joshi.k@samsung.com \
    --cc=linux-block@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=vincent.fu@samsung.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