Skip to contentSkip to conversation

smb/client: clean up a type issue in cifs_xattr_get()

PATCH In review Dan Carpenter 2 participants 3 messages Jun 11 – Jun 12

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 smb/client: clean up a type issue in cifs_xattr_get()

The cifs_xattr_get() function returns type int, not ssize_t so declare "rc" as int as well. This has no effect on runtime.

---
 fs/smb/client/xattr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/client/xattr.c +2 -2
index 23227f2f9428..5091f6c0d7fe 100644
@@ -272,7 +272,7 @@ static int cifs_xattr_get(const struct xattr_handler *handler,
 			  struct dentry *dentry, struct inode *inode,
 			  const char *name, void *value, size_t size)
 {
-	ssize_t rc = -EOPNOTSUPP;
+	int rc = -EOPNOTSUPP;
 	unsigned int xid;
 	struct super_block *sb = dentry->d_sb;
 	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
@@ -354,7 +354,7 @@ static int cifs_xattr_get(const struct xattr_handler *handler,
 				inode, full_path, &acllen, extra_info);
 		if (IS_ERR(pacl)) {
 			rc = PTR_ERR(pacl);
-			cifs_dbg(VFS, "%s: error %zd getting sec desc\n",
+			cifs_dbg(VFS, "%s: error %d getting sec desc\n",
 				 __func__, rc);
 		} else {
 			if (value) {
Signature · 1 line
2.53.0
#1 lore raw

Doesn't your patch need a cast in the following code in xattr.c since it returns a ssize_t and you changed rc to int with your patch?

315 if (pTcon->ses->server->ops->query_all_EAs)
316 rc =
pTcon->ses->server->ops->query_all_EAs(xid, pTcon,
317 full_path, name, value, size, cifs_sb);

Quoted 35 lines · Dan Carpenter via samba-technical

The cifs_xattr_get() function returns type int, not ssize_t so declare "rc" as int as well. This has no effect on runtime.

---
 fs/smb/client/xattr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/client/xattr.c +2 -3
index 23227f2f9428..5091f6c0d7fe 100644
@@ -272,7 +272,7 @@ static int cifs_xattr_get(const struct xattr_handler *handler,
                          struct dentry *dentry, struct inode *inode,
                          const char *name, void *value, size_t size)
 {
-       ssize_t rc = -EOPNOTSUPP;
+       int rc = -EOPNOTSUPP;
        unsigned int xid;
        struct super_block *sb = dentry->d_sb;
        struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
@@ -354,7 +354,7 @@ static int cifs_xattr_get(const struct xattr_handler *handler,
                                inode, full_path, &acllen, extra_info);
                if (IS_ERR(pacl)) {
                        rc = PTR_ERR(pacl);
-                       cifs_dbg(VFS, "%s: error %zd getting sec desc\n",
+                       cifs_dbg(VFS, "%s: error %d getting sec desc\n",
                                 __func__, rc);
                } else {
                        if (value) {
--

2.53.0

Signature · 3 lines
Thanks,

Steve
#2 lore raw
Quoted 8 lines · Steve French

Doesn't your patch need a cast in the following code in xattr.c since it returns a ssize_t and you changed rc to int with your patch?

315 if (pTcon->ses->server->ops->query_all_EAs)
316 rc =
pTcon->ses->server->ops->query_all_EAs(xid, pTcon,
317 full_path, name, value, size, cifs_sb);

It's not required. The ->query_all_EAs() pointer returns ssize_t but the two functions which implement ->query_all_EAs(), CIFSSMBQAllEAs() and smb2_query_eas() return an rc variable which is an int.

I would tend to leave it out, but if you want I can add it if you would prefer.

My real motivation for making this change is that we have an "acllen = -ERANGE;" assignment where acllen is a u32. Then we store the -ERANGE in a signed long and Smatch triggers a warning at that point. But then we truncate away the upper 32 bits so it ends being fine.

regards,
dan carpenter