LinuxKPI: Use simple_read_from_buffer in simple_attr_read and seq_read
Reviewed by: bz Sponsored by: AFRL, DARPA Differential Revision: https://reviews.freebsd.org/D55879
This commit is contained in:
@@ -60,15 +60,8 @@ seq_read(struct linux_file *f, char *ubuf, size_t size, off_t *ppos)
|
||||
if (rc)
|
||||
return (rc);
|
||||
|
||||
rc = sbuf_len(sbuf);
|
||||
if (*ppos >= rc || size < 1)
|
||||
return (-EINVAL);
|
||||
|
||||
size = min(rc - *ppos, size);
|
||||
memcpy(ubuf, sbuf_data(sbuf) + *ppos, size);
|
||||
*ppos += size;
|
||||
|
||||
return (size);
|
||||
return (simple_read_from_buffer(ubuf, size, ppos, sbuf_data(sbuf),
|
||||
sbuf_len(sbuf)));
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -119,18 +119,9 @@ simple_attr_read(struct file *filp, char *buf, size_t read_size, loff_t *ppos)
|
||||
|
||||
scnprintf(prebuf, sizeof(prebuf), sattr->fmt, data);
|
||||
|
||||
ret = strlen(prebuf) + 1;
|
||||
if (*ppos >= ret || read_size < 1) {
|
||||
ret = -EINVAL;
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
read_size = min(ret - *ppos, read_size);
|
||||
ret = strscpy(buf, prebuf + *ppos, read_size);
|
||||
|
||||
/* add 1 for null terminator */
|
||||
if (ret > 0)
|
||||
ret += 1;
|
||||
ret = simple_read_from_buffer(buf, read_size, ppos, prebuf,
|
||||
strlen(prebuf) + 1);
|
||||
|
||||
unlock:
|
||||
mutex_unlock(&sattr->mutex);
|
||||
|
||||
Reference in New Issue
Block a user