Skip to content

Commit 1f3fd10

Browse files
metze-sambasmfrench
authored andcommitted
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>
1 parent 991f8a7 commit 1f3fd10

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

fs/smb/common/smbdirect/smbdirect_socket.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,19 @@ const char *smbdirect_socket_status_string(enum smbdirect_socket_status status)
7474
return "<unknown>";
7575
}
7676

77+
/*
78+
* This can be used with %1pe to print errors as strings or '0'
79+
* And it avoids warnings like: warn: passing zero to 'ERR_PTR'
80+
* from smatch -p=kernel --pedantic
81+
*/
82+
static __always_inline
83+
const void * __must_check SMBDIRECT_DEBUG_ERR_PTR(long error)
84+
{
85+
if (error == 0)
86+
return NULL;
87+
return ERR_PTR(error);
88+
}
89+
7790
enum smbdirect_keepalive_status {
7891
SMBDIRECT_KEEPALIVE_NONE,
7992
SMBDIRECT_KEEPALIVE_PENDING,

0 commit comments

Comments
 (0)