lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251208062100.3268777-8-chenxiaosong.chenxiaosong@linux.dev>
Date: Mon,  8 Dec 2025 14:20:37 +0800
From: chenxiaosong.chenxiaosong@...ux.dev
To: sfrench@...ba.org,
	smfrench@...il.com,
	linkinjeon@...nel.org,
	linkinjeon@...ba.org
Cc: linux-cifs@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	liuzhengyuan@...inos.cn,
	huhai@...inos.cn,
	liuyun01@...inos.cn,
	ChenXiaoSong <chenxiaosong@...inos.cn>
Subject: [PATCH 07/30] smb/client: introduce DEFINE_CMP_FUNC()

From: ChenXiaoSong <chenxiaosong@...inos.cn>

We are going to define 3 comparison functions, introduce this macro to
reduce duplicate code.

Signed-off-by: ChenXiaoSong <chenxiaosong@...inos.cn>
---
 fs/smb/client/netmisc.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/fs/smb/client/netmisc.c b/fs/smb/client/netmisc.c
index 9ec20601cee2..73c40ae91607 100644
--- a/fs/smb/client/netmisc.c
+++ b/fs/smb/client/netmisc.c
@@ -24,6 +24,19 @@
 #include "cifs_debug.h"
 #include "nterr.h"
 
+/* Define a comparison function for ascending order. */
+#define DEFINE_CMP_FUNC(__struct_name, __field)				\
+static int cmp_ ## __struct_name(const void *_a, const void *_b)	\
+{									\
+	const struct __struct_name *a = _a, *b = _b;			\
+									\
+	if (a->__field < b->__field)					\
+		return -1;						\
+	if (a->__field > b->__field)					\
+		return 1;						\
+	return 0;							\
+}
+
 struct smb_to_posix_error {
 	__u16 smb_err;
 	int posix_code;
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ