smb: smbdirect: introduce SMBDIRECT_DEBUG_ERR_PTR() helper

This can be used like this:

  int err = somefunc();
  pr_warn("err=%1pe\n", SMBDIRECT_DEBUG_ERR_PTR(err));

This will be used in the following fixes in order
to be prepared to identify real world problems
more easily.

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Paulo Alcantara <pc@manguebit.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
Stefan Metzmacher
2025-11-25 09:55:54 +01:00
committed by Steve French
parent 991f8a79db
commit 1f3fd108c5

View File

@@ -74,6 +74,19 @@ const char *smbdirect_socket_status_string(enum smbdirect_socket_status status)
return "<unknown>";
}
/*
* This can be used with %1pe to print errors as strings or '0'
* And it avoids warnings like: warn: passing zero to 'ERR_PTR'
* from smatch -p=kernel --pedantic
*/
static __always_inline
const void * __must_check SMBDIRECT_DEBUG_ERR_PTR(long error)
{
if (error == 0)
return NULL;
return ERR_PTR(error);
}
enum smbdirect_keepalive_status {
SMBDIRECT_KEEPALIVE_NONE,
SMBDIRECT_KEEPALIVE_PENDING,