public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Namjae Jeon <linkinjeon@kernel.org>
Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, hch@lst.de,
	tytso@mit.edu, willy@infradead.org, jack@suse.cz,
	djwong@kernel.org, josef@toxicpanda.com, sandeen@sandeen.net,
	rgoldwyn@suse.com, xiang@kernel.org, dsterba@suse.com,
	pali@kernel.org, ebiggers@kernel.org, neil@brown.name,
	amir73il@gmail.com, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, iamjoonsoo.kim@lge.com,
	cheol.lee@lge.com, jay.sim@lge.com, gunho.lee@lge.com
Subject: Re: [PATCH v5 11/14] ntfs: update misc operations
Date: Fri, 16 Jan 2026 10:28:33 +0100	[thread overview]
Message-ID: <20260116092833.GB21396@lst.de> (raw)
In-Reply-To: <20260111140345.3866-12-linkinjeon@kernel.org>

On Sun, Jan 11, 2026 at 11:03:41PM +0900, Namjae Jeon wrote:
> +	if ((data1_len != data2_len) || (data1_len <= 0) || (data1_len & 3)) {

Nit: all the inner braces are superfluous.

Also why allow passing negative values at all and not pass unsigned
length values?

> +		ntfs_error(vol->sb, "data1_len or data2_len not valid\n");
> +		return -1;
> +	}
> +
> +	p1 = (const __le32 *)data1;
> +	p2 = (const __le32 *)data2;
> +	len = data1_len;

I don't think any of these casts is needed.  Also the variables could
easily be initialized at declaration time.

> +	do {
> +		d1 = le32_to_cpup(p1);
> +		p1++;
> +		d2 = le32_to_cpup(p2);
> +		p2++;
> +	} while ((d1 == d2) && ((len -= 4) > 0));

More superfluous races.

> +	if (d1 < d2)
> +		rc = -1;
>
> +	else {
> +		if (d1 == d2)
> +			rc = 0;
> +		else
> +			rc = 1;
> +	}
> +	ntfs_debug("Done, returning %i.", rc);
> +	return rc;

Just return directly using cmp_int() and skip the very verbose debugging?

	return cmp_int(d1, d2);

> +/**
> + * ntfs_collate_file_name - Which of two filenames should be listed first
> + */
> +static int ntfs_collate_file_name(struct ntfs_volume *vol,
> +		const void *data1, const int __always_unused data1_len,
> +		const void *data2, const int __always_unused data2_len)

Do we need these annotations for indirectly called callbacks now?

> +	if (cr != COLLATION_BINARY && cr != COLLATION_NTOFS_ULONG &&
> +	    cr != COLLATION_FILE_NAME && cr != COLLATION_NTOFS_ULONGS)
> +		return -EINVAL;

Turn this into a switch to make it more obvious?

> +
>  	i = le32_to_cpu(cr);
> -	BUG_ON(i < 0);
> +	if (i < 0)
> +		return -1;
>  	if (i <= 0x02)
>  		return ntfs_do_collate0x0[i](vol, data1, data1_len,
>  				data2, data2_len);
> -	BUG_ON(i < 0x10);
> +	if (i < 0x10)
> +		return -1;
>  	i -= 0x10;
>  	if (likely(i <= 3))
>  		return ntfs_do_collate0x1[i](vol, data1, data1_len,
>  				data2, data2_len);
> -	BUG();

.. and then maybe use the switch to untangle this as well, which
smells like just a bit too much deep magic..

> -void __ntfs_error(const char *function, const struct super_block *sb,
> +void __ntfs_error(const char *function, struct super_block *sb,

Why does this drop the const?

> +#ifndef DEBUG
> +	if (sb)
> +		pr_err_ratelimited("(device %s): %s(): %pV\n",
> +		       sb->s_id, flen ? function : "", &vaf);
> +	else
> +		pr_err_ratelimited("%s(): %pV\n", flen ? function : "", &vaf);
> +#else
>  	if (sb)
>  		pr_err("(device %s): %s(): %pV\n",
>  		       sb->s_id, flen ? function : "", &vaf);
>  	else
>  		pr_err("%s(): %pV\n", flen ? function : "", &vaf);
> +#endif

Usually if you have cpp conditions with an else, I'd use ifdef instead
of the negated version.


  reply	other threads:[~2026-01-16  9:28 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-11 14:03 [PATCH v5 00/14] ntfs filesystem remake Namjae Jeon
2026-01-11 14:03 ` [PATCH v5 01/14] Revert "fs: Remove NTFS classic" Namjae Jeon
2026-01-16  8:00   ` Christoph Hellwig
2026-01-11 14:03 ` [PATCH v5 02/14] ntfs: update in-memory, on-disk structures and headers Namjae Jeon
2026-01-16  8:23   ` Christoph Hellwig
2026-01-18  4:54     ` Namjae Jeon
2026-01-19  7:05       ` Christoph Hellwig
2026-01-20  4:27         ` Namjae Jeon
2026-01-20  6:40           ` Christoph Hellwig
2026-01-20  7:03             ` Namjae Jeon
2026-01-11 14:03 ` [PATCH v5 03/14] ntfs: update super block operations Namjae Jeon
2026-01-11 14:03 ` [PATCH v5 04/14] ntfs: update inode operations Namjae Jeon
2026-01-16  8:30   ` Christoph Hellwig
2026-01-18  4:54     ` Namjae Jeon
2026-01-11 14:03 ` [PATCH v5 05/14] ntfs: update directory operations Namjae Jeon
2026-01-11 14:03 ` [PATCH v5 06/14] ntfs: update file operations Namjae Jeon
2026-01-16  8:53   ` Christoph Hellwig
2026-01-18  4:56     ` Namjae Jeon
2026-01-19  7:10       ` Christoph Hellwig
2026-01-20  5:11         ` Namjae Jeon
2026-01-20  6:42           ` Christoph Hellwig
2026-01-20  7:02             ` Namjae Jeon
2026-01-11 14:03 ` [PATCH v5 07/14] ntfs: update iomap and address space operations Namjae Jeon
2026-01-16  9:14   ` Christoph Hellwig
2026-01-18  5:00     ` Namjae Jeon
2026-01-19  7:17       ` Christoph Hellwig
2026-01-20  4:28         ` Namjae Jeon
2026-01-11 14:03 ` [PATCH v5 08/14] ntfs: update attrib operations Namjae Jeon
2026-01-16  9:18   ` Christoph Hellwig
2026-01-18  5:00     ` Namjae Jeon
2026-01-11 14:03 ` [PATCH v5 09/14] ntfs: update runlist handling and cluster allocator Namjae Jeon
2026-01-16  9:21   ` Christoph Hellwig
2026-01-18  5:00     ` Namjae Jeon
2026-01-11 14:03 ` [PATCH v5 10/14] ntfs: add reparse and ea operations Namjae Jeon
2026-01-11 14:03 ` [PATCH v5 11/14] ntfs: update misc operations Namjae Jeon
2026-01-16  9:28   ` Christoph Hellwig [this message]
2026-01-18  5:00     ` Namjae Jeon
2026-01-11 14:03 ` [PATCH v5 12/14] ntfs3: remove legacy ntfs driver support Namjae Jeon
2026-01-16  9:28   ` Christoph Hellwig
2026-01-11 14:03 ` [PATCH v5 13/14] ntfs: add Kconfig and Makefile Namjae Jeon
2026-01-16  9:30   ` Christoph Hellwig
2026-01-18  5:08     ` Namjae Jeon
2026-01-19  7:19       ` Christoph Hellwig
2026-01-20  4:27         ` Namjae Jeon
2026-01-11 14:03 ` [PATCH v5 14/14] MAINTAINERS: update ntfs filesystem entry Namjae Jeon
2026-01-16  9:30   ` Christoph Hellwig
2026-01-16  9:33 ` [PATCH v5 00/14] ntfs filesystem remake Christoph Hellwig
2026-01-18  5:19   ` Namjae Jeon
2026-01-19  7:02     ` Christoph Hellwig
2026-01-20  4:26       ` Namjae Jeon

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=20260116092833.GB21396@lst.de \
    --to=hch@lst.de \
    --cc=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=cheol.lee@lge.com \
    --cc=djwong@kernel.org \
    --cc=dsterba@suse.com \
    --cc=ebiggers@kernel.org \
    --cc=gunho.lee@lge.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=jack@suse.cz \
    --cc=jay.sim@lge.com \
    --cc=josef@toxicpanda.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=pali@kernel.org \
    --cc=rgoldwyn@suse.com \
    --cc=sandeen@sandeen.net \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    --cc=xiang@kernel.org \
    /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