[PATCH] staging: lustre: Fix sparse warning on address-space

From: Jia He
Date: Mon Dec 29 2014 - 07:49:37 EST


This patch is to fix the below warnings generated by sparse:
warning: incorrect type in argument 1 (different address spaces)
expected void const volatile [noderef] <asn:1>*<noident>
got int *<noident>
Adding the macro "__user" can suppress the warnings, and aslo some lines
are adjusted for 80 chars line limitation.
Already checked by sparse "C=2"

Signed-off-by: Jia He <hejianet@xxxxxxxxx>
Cc: Oleg Drokin <oleg.drokin@xxxxxxxxx>
Cc: Andreas Dilger <andreas.dilger@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
.../staging/lustre/lustre/include/lprocfs_status.h | 18 ++++-----
.../lustre/lustre/obdclass/lprocfs_status.c | 6 +--
drivers/staging/lustre/lustre/osc/lproc_osc.c | 44 +++++++++++-----------
drivers/staging/lustre/lustre/osc/osc_request.c | 6 +--
.../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 6 +--
5 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h
index cfe503b..ed4932f 100644
--- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
+++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
@@ -631,13 +631,13 @@ extern int lprocfs_wr_timeouts(struct file *file, const char *buffer,
unsigned long count, void *data);
extern int lprocfs_wr_evict_client(struct file *file, const char *buffer,
size_t count, loff_t *off);
-extern int lprocfs_wr_ping(struct file *file, const char *buffer,
+extern int lprocfs_wr_ping(struct file *file, const char __user *buffer,
size_t count, loff_t *off);
-extern int lprocfs_wr_import(struct file *file, const char *buffer,
+extern int lprocfs_wr_import(struct file *file, const char __user *buffer,
size_t count, loff_t *off);
extern int lprocfs_rd_pinger_recov(struct seq_file *m, void *n);
-extern int lprocfs_wr_pinger_recov(struct file *file, const char *buffer,
- size_t count, loff_t *off);
+extern int lprocfs_wr_pinger_recov(struct file *file,
+ const char __user *buffer, size_t count, loff_t *off);

/* Statfs helpers */
extern int lprocfs_rd_blksize(struct seq_file *m, void *data);
@@ -650,9 +650,9 @@ extern int lprocfs_rd_filesfree(struct seq_file *m, void *data);
extern int lprocfs_write_helper(const char __user *buffer, unsigned long count,
int *val);
extern int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult);
-extern int lprocfs_write_u64_helper(const char *buffer, unsigned long count,
- __u64 *val);
-extern int lprocfs_write_frac_u64_helper(const char *buffer,
+extern int lprocfs_write_u64_helper(const char __user *buffer,
+ unsigned long count, __u64 *val);
+extern int lprocfs_write_frac_u64_helper(const char __user *buffer,
unsigned long count,
__u64 *val, int mult);
extern char *lprocfs_find_named_value(const char *buffer, const char *name,
@@ -716,7 +716,7 @@ static struct file_operations name##_fops = { \
return lprocfs_rd_##type(m, m->private); \
} \
static ssize_t name##_##type##_seq_write(struct file *file, \
- const char *buffer, size_t count, loff_t *off) \
+ const char __user *buffer, size_t count, loff_t *off) \
{ \
struct seq_file *seq = file->private_data; \
return lprocfs_wr_##type(file, buffer, \
@@ -726,7 +726,7 @@ static struct file_operations name##_fops = { \

#define LPROC_SEQ_FOPS_WR_ONLY(name, type) \
static ssize_t name##_##type##_write(struct file *file, \
- const char *buffer, size_t count, loff_t *off) \
+ const char __user *buffer, size_t count, loff_t *off) \
{ \
return lprocfs_wr_##type(file, buffer, count, off); \
} \
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index 3b7dfc3..9a84b52 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -1849,15 +1849,15 @@ int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult)
}
EXPORT_SYMBOL(lprocfs_seq_read_frac_helper);

-int lprocfs_write_u64_helper(const char *buffer, unsigned long count,
+int lprocfs_write_u64_helper(const char __user *buffer, unsigned long count,
__u64 *val)
{
return lprocfs_write_frac_u64_helper(buffer, count, val, 1);
}
EXPORT_SYMBOL(lprocfs_write_u64_helper);

-int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count,
- __u64 *val, int mult)
+int lprocfs_write_frac_u64_helper(const char __user *buffer,
+ unsigned long count, __u64 *val, int mult)
{
char kernbuf[22], *end, *pbuf;
__u64 whole, frac = 0, units;
diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c
index 9f719bc..507592c 100644
--- a/drivers/staging/lustre/lustre/osc/lproc_osc.c
+++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c
@@ -53,8 +53,8 @@ static int osc_active_seq_show(struct seq_file *m, void *v)
return rc;
}

-static ssize_t osc_active_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t osc_active_seq_write(struct file *file,
+ const char __user *buffer, size_t count, loff_t *off)
{
struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
int val, rc;
@@ -88,7 +88,7 @@ static int osc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
}

static ssize_t osc_max_rpcs_in_flight_seq_write(struct file *file,
- const char *buffer, size_t count, loff_t *off)
+ const char __user *buffer, size_t count, loff_t *off)
{
struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
struct client_obd *cli = &dev->u.cli;
@@ -130,8 +130,8 @@ static int osc_max_dirty_mb_seq_show(struct seq_file *m, void *v)
return lprocfs_seq_read_frac_helper(m, val, mult);
}

-static ssize_t osc_max_dirty_mb_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t osc_max_dirty_mb_seq_write(struct file *file,
+ const char __user *buffer, size_t count, loff_t *off)
{
struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
struct client_obd *cli = &dev->u.cli;
@@ -233,8 +233,8 @@ static int osc_cur_grant_bytes_seq_show(struct seq_file *m, void *v)
return rc;
}

-static ssize_t osc_cur_grant_bytes_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t osc_cur_grant_bytes_seq_write(struct file *file,
+ const char __user *buffer, size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
struct client_obd *cli = &obd->u.cli;
@@ -290,7 +290,7 @@ static int osc_grant_shrink_interval_seq_show(struct seq_file *m, void *v)
}

static ssize_t osc_grant_shrink_interval_seq_write(struct file *file,
- const char *buffer, size_t count, loff_t *off)
+ const char __user *buffer, size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
int val, rc;
@@ -322,8 +322,8 @@ static int osc_checksum_seq_show(struct seq_file *m, void *v)
obd->u.cli.cl_checksum ? 1 : 0);
}

-static ssize_t osc_checksum_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t osc_checksum_seq_write(struct file *file,
+ const char __user *buffer, size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
int val, rc;
@@ -362,8 +362,8 @@ static int osc_checksum_type_seq_show(struct seq_file *m, void *v)
return 0;
}

-static ssize_t osc_checksum_type_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t osc_checksum_type_seq_write(struct file *file,
+ const char __user *buffer, size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
int i;
@@ -401,8 +401,8 @@ static int osc_resend_count_seq_show(struct seq_file *m, void *v)
return seq_printf(m, "%u\n", atomic_read(&obd->u.cli.cl_resends));
}

-static ssize_t osc_resend_count_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t osc_resend_count_seq_write(struct file *file,
+ const char __user *buffer, size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
int val, rc;
@@ -428,8 +428,8 @@ static int osc_contention_seconds_seq_show(struct seq_file *m, void *v)
return seq_printf(m, "%u\n", od->od_contention_time);
}

-static ssize_t osc_contention_seconds_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t osc_contention_seconds_seq_write(struct file *file,
+ const char __user *buffer, size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
struct osc_device *od = obd2osc_dev(obd);
@@ -447,8 +447,8 @@ static int osc_lockless_truncate_seq_show(struct seq_file *m, void *v)
return seq_printf(m, "%u\n", od->od_lockless_truncate);
}

-static ssize_t osc_lockless_truncate_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t osc_lockless_truncate_seq_write(struct file *file,
+ const char __user *buffer, size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
struct osc_device *od = obd2osc_dev(obd);
@@ -472,7 +472,7 @@ static int osc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v)
}

static ssize_t osc_obd_max_pages_per_rpc_seq_write(struct file *file,
- const char *buffer, size_t count, loff_t *off)
+ const char __user *buffer, size_t count, loff_t *off)
{
struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
struct client_obd *cli = &dev->u.cli;
@@ -664,8 +664,8 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
}
#undef pct

-static ssize_t osc_rpc_stats_seq_write(struct file *file, const char *buf,
- size_t len, loff_t *off)
+static ssize_t osc_rpc_stats_seq_write(struct file *file,
+ const char __user *buf, size_t len, loff_t *off)
{
struct seq_file *seq = file->private_data;
struct obd_device *dev = seq->private;
@@ -702,7 +702,7 @@ static int osc_stats_seq_show(struct seq_file *seq, void *v)
return 0;
}

-static ssize_t osc_stats_seq_write(struct file *file, const char *buf,
+static ssize_t osc_stats_seq_write(struct file *file, const char __user *buf,
size_t len, loff_t *off)
{
struct seq_file *seq = file->private_data;
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
index b9450b9..ca65d92 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -2598,7 +2598,7 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump)
/* we only need the header part from user space to get lmm_magic and
* lmm_stripe_count, (the header part is common to v1 and v3) */
lum_size = sizeof(struct lov_user_md_v1);
- if (copy_from_user(&lum, lump, lum_size))
+ if (copy_from_user(&lum, (void __user *)lump, lum_size))
return -EFAULT;

if ((lum.lmm_magic != LOV_USER_MAGIC_V1) &&
@@ -2632,7 +2632,7 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump)
lumk->lmm_oi = lsm->lsm_oi;
lumk->lmm_stripe_count = 1;

- if (copy_to_user(lump, lumk, lum_size))
+ if (copy_to_user((void __user *)lump, lumk, lum_size))
rc = -EFAULT;

if (lumk != &lum)
@@ -2691,7 +2691,7 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,

memcpy(data->ioc_inlbuf2, &obd->obd_uuid, sizeof(uuid));

- err = copy_to_user((void *)uarg, buf, len);
+ err = copy_to_user((void __user *)uarg, buf, len);
if (err)
err = -EFAULT;
obd_ioctl_freedata(buf, len);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
index 4011e00..0fb32e8 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
@@ -1223,7 +1223,7 @@ EXPORT_SYMBOL(lprocfs_wr_evict_client);

#undef BUFLEN

-int lprocfs_wr_ping(struct file *file, const char *buffer,
+int lprocfs_wr_ping(struct file *file, const char __user *buffer,
size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
@@ -1251,7 +1251,7 @@ EXPORT_SYMBOL(lprocfs_wr_ping);
* The connection UUID is a node's primary NID. For example,
* "echo connection=192.168.0.1@tcp0::instance > .../import".
*/
-int lprocfs_wr_import(struct file *file, const char *buffer,
+int lprocfs_wr_import(struct file *file, const char __user *buffer,
size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
@@ -1329,7 +1329,7 @@ int lprocfs_rd_pinger_recov(struct seq_file *m, void *n)
}
EXPORT_SYMBOL(lprocfs_rd_pinger_recov);

-int lprocfs_wr_pinger_recov(struct file *file, const char *buffer,
+int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer,
size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
--
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/