All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: ChenXiaoSong <chenxiaosong@kylinos.cn>
Cc: dhowells@redhat.com, Steve French <sfrench@samba.org>,
	ChenXiaoSong <chenxiaosong.chenxiaosong@linux.dev>,
	liuzhengyuan@kylinos.cn, huhai@kylinos.cn, liuyun01@kylinos.cn,
	Paulo Alcantara <pc@manguebit.org>,
	linux-cifs@vger.kernel.org
Subject: Can we autogenerate smb2_error_map_table[]?
Date: Wed, 10 Dec 2025 23:03:19 +0000	[thread overview]
Message-ID: <650896.1765407799@warthog.procyon.org.uk> (raw)

Hi Chenxiaosong,

Can I suggest that rather than doing your "[PATCH v4 05/10] smb/client: sort
smb2_error_map_table array", we autogenerate the table from the header file,
putting all the info there?

One problem that we have is that we have multiple copies of the error table -
and keeping them up to date and strictly ordered is problematic (hence your
kunit test).  Further, each error number is mapped to an error string with the
name of the symbol (I think they're all exactly equivalent).

So, for example, I do this for the ASN.1 Object Identifier (OID) registry.  I
have a perl script:

	lib/build_OID_registry

that parses the enum here:

	include/linux/oid_registry.h

including the comments and generating tables for looking up OIDs:

	enum OID {
		OID_id_dsa_with_sha1,		/* 1.2.840.10030.4.3 */
		OID_id_dsa,			/* 1.2.840.10040.4.1 */

This is built by rules in lib/Makefile:

	#
	# Build a fast OID lookip registry from include/linux/oid_registry.h
	#
	obj-$(CONFIG_OID_REGISTRY) += oid_registry.o

	$(obj)/oid_registry.o: $(obj)/oid_registry_data.c

	$(obj)/oid_registry_data.c: $(srctree)/include/linux/oid_registry.h \
				    $(src)/build_OID_registry
		$(call cmd,build_OID_registry)

	quiet_cmd_build_OID_registry = GEN     $@
	      cmd_build_OID_registry = perl $(src)/build_OID_registry $< $@

	clean-files	+= oid_registry_data.c

Now, looking at smb2status.h, for example, we have a lot of:

	#define STATUS_SUCCESS cpu_to_le32(0x00000000)
	#define STATUS_WAIT_0 cpu_to_le32(0x00000000)
	#define STATUS_WAIT_1 cpu_to_le32(0x00000001)
	...

and we could generate two parts of the table from this.  The third part could
be placed in the header as well:

	#define STATUS_SUCCESS	cpu_to_le32(0x00000000)	// 0
	#define STATUS_WAIT_0	cpu_to_le32(0x00000000)	// -EIO
	#define STATUS_WAIT_1	cpu_to_le32(0x00000001)	// -EIO
	...

(There's also the possibility that we don't necessarily want to list all
statuses in the table.)

David


             reply	other threads:[~2025-12-10 23:03 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-10 23:03 David Howells [this message]
2025-12-10 23:40 ` Can we autogenerate smb2_error_map_table[]? ChenXiaoSong
     [not found]   ` <CAH2r5msTSRvKRwQYjuVP62KB5beoS99e4eYKYHQ9ZPTYejykRA@mail.gmail.com>
2025-12-11  0:11     ` ChenXiaoSong
2025-12-11 15:03       ` [PATCH 1/2] cifs: Label SMB2 statuses with errors David Howells
2025-12-12  0:19         ` ChenXiaoSong
2025-12-12  0:29           ` ChenXiaoSong
2025-12-12  9:35           ` David Howells
2025-12-11 15:04       ` [PATCH 2/2] cifs: Autogenerate SMB2 error mapping table David Howells
2025-12-11 15:33         ` ChenXiaoSong
2025-12-11 15:43           ` David Howells
2025-12-12  2:09         ` ChenXiaoSong
2025-12-12  9:41           ` David Howells
2025-12-12 10:19             ` ChenXiaoSong
2025-12-15  3:11             ` ChenXiaoSong
     [not found]               ` <CAH2r5mvpz4BWM4Uua17Cg+vw-PrVpZOQLHmU8xi6XDmY8vuA=w@mail.gmail.com>
2025-12-15  4:33                 ` ChenXiaoSong
2025-12-12  9:48           ` David Howells
2025-12-11 15:11       ` Can we autogenerate smb2_error_map_table[]? David Howells

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=650896.1765407799@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=chenxiaosong.chenxiaosong@linux.dev \
    --cc=chenxiaosong@kylinos.cn \
    --cc=huhai@kylinos.cn \
    --cc=linux-cifs@vger.kernel.org \
    --cc=liuyun01@kylinos.cn \
    --cc=liuzhengyuan@kylinos.cn \
    --cc=pc@manguebit.org \
    --cc=sfrench@samba.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 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.