Skip to content

Commit c087eab

Browse files
Alexander Aringteigland
authored andcommitted
dlm: remove __user conversion warnings
This patch avoids the following sparse warning: fs/dlm/user.c:111:38: warning: incorrect type in assignment (different address spaces) fs/dlm/user.c:111:38: expected void [noderef] __user *castparam fs/dlm/user.c:111:38: got void * fs/dlm/user.c:112:37: warning: incorrect type in assignment (different address spaces) fs/dlm/user.c:112:37: expected void [noderef] __user *castaddr fs/dlm/user.c:112:37: got void * fs/dlm/user.c:113:38: warning: incorrect type in assignment (different address spaces) fs/dlm/user.c:113:38: expected void [noderef] __user *bastparam fs/dlm/user.c:113:38: got void * fs/dlm/user.c:114:37: warning: incorrect type in assignment (different address spaces) fs/dlm/user.c:114:37: expected void [noderef] __user *bastaddr fs/dlm/user.c:114:37: got void * fs/dlm/user.c:115:33: warning: incorrect type in assignment (different address spaces) fs/dlm/user.c:115:33: expected struct dlm_lksb [noderef] __user *lksb fs/dlm/user.c:115:33: got void * fs/dlm/user.c:130:39: warning: cast removes address space '__user' of expression fs/dlm/user.c:131:40: warning: cast removes address space '__user' of expression fs/dlm/user.c:132:36: warning: cast removes address space '__user' of expression So far I see there is no direct handling of copying a pointer value to another pointer value. The handling only copies the actual pointer address to a scalar type or vice versa. This should be okay because it never handles dereferencing anything of those addresses in the kernel space. To get rid of those warnings we doing some different casting which results in no warnings in sparse or compiler. Signed-off-by: Alexander Aring <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent 14a92fd commit c087eab

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

fs/dlm/user.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ static void compat_input(struct dlm_write_request *kb,
108108
kb->i.lock.parent = kb32->i.lock.parent;
109109
kb->i.lock.xid = kb32->i.lock.xid;
110110
kb->i.lock.timeout = kb32->i.lock.timeout;
111-
kb->i.lock.castparam = (void *)(long)kb32->i.lock.castparam;
112-
kb->i.lock.castaddr = (void *)(long)kb32->i.lock.castaddr;
113-
kb->i.lock.bastparam = (void *)(long)kb32->i.lock.bastparam;
114-
kb->i.lock.bastaddr = (void *)(long)kb32->i.lock.bastaddr;
115-
kb->i.lock.lksb = (void *)(long)kb32->i.lock.lksb;
111+
kb->i.lock.castparam = (__user void *)(long)kb32->i.lock.castparam;
112+
kb->i.lock.castaddr = (__user void *)(long)kb32->i.lock.castaddr;
113+
kb->i.lock.bastparam = (__user void *)(long)kb32->i.lock.bastparam;
114+
kb->i.lock.bastaddr = (__user void *)(long)kb32->i.lock.bastaddr;
115+
kb->i.lock.lksb = (__user void *)(long)kb32->i.lock.lksb;
116116
memcpy(kb->i.lock.lvb, kb32->i.lock.lvb, DLM_USER_LVB_LEN);
117117
memcpy(kb->i.lock.name, kb32->i.lock.name, namelen);
118118
}
@@ -127,9 +127,9 @@ static void compat_output(struct dlm_lock_result *res,
127127
res32->version[1] = res->version[1];
128128
res32->version[2] = res->version[2];
129129

130-
res32->user_astaddr = (__u32)(long)res->user_astaddr;
131-
res32->user_astparam = (__u32)(long)res->user_astparam;
132-
res32->user_lksb = (__u32)(long)res->user_lksb;
130+
res32->user_astaddr = (__u32)(__force long)res->user_astaddr;
131+
res32->user_astparam = (__u32)(__force long)res->user_astparam;
132+
res32->user_lksb = (__u32)(__force long)res->user_lksb;
133133
res32->bast_mode = res->bast_mode;
134134

135135
res32->lvb_offset = res->lvb_offset;

0 commit comments

Comments
 (0)