summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Gordon <david.s.gordon@intel.com>2015-05-14 10:55:19 +1000
committerStephen Rothwell <sfr@canb.auug.org.au>2015-05-14 10:55:19 +1000
commit52503264595b2a4b21d81d23f3645ef52006a676 (patch)
tree3701ccbaa524b726f11d9c181369dfcaa8a891ab
parente83b1efe464b9e68184f27042003754d9dad7407 (diff)
downloadlinux-52503264595b2a4b21d81d23f3645ef52006a676.tar.gz
linux-52503264595b2a4b21d81d23f3645ef52006a676.tar.xz
lib/scatterlist: mark input buffer parameters as 'const'
The 'buf' parameter of sg(p)copy_from_buffer() can and should be const-qualified, although because of the shared implementation of _to_buffer() and _from_buffer(), we have to cast this away internally. This means that callers who have a 'const' buffer containing the data to be copied to the sg-list no longer have to cast away the const-ness themselves. It also enables improved coverage by code analysis tools. Signed-off-by: Dave Gordon <david.s.gordon@intel.com> Cc: Akinobu Mita <akinobu.mita@gmail.com> Cc: "Martin K. Petersen" <martin.petersen@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r--include/linux/scatterlist.h4
-rw-r--r--lib/scatterlist.c8
2 files changed, 6 insertions, 6 deletions
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index ed8f9e70df9b..c90038bba69d 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -240,12 +240,12 @@ int sg_alloc_table_from_pages(struct sg_table *sgt,
gfp_t gfp_mask);
size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents,
- void *buf, size_t buflen);
+ const void *buf, size_t buflen);
size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
void *buf, size_t buflen);
size_t sg_pcopy_from_buffer(struct scatterlist *sgl, unsigned int nents,
- void *buf, size_t buflen, off_t skip);
+ const void *buf, size_t buflen, off_t skip);
size_t sg_pcopy_to_buffer(struct scatterlist *sgl, unsigned int nents,
void *buf, size_t buflen, off_t skip);
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index 233ebe70e6be..e2374ec4e6a3 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -669,9 +669,9 @@ static size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents,
*
**/
size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents,
- void *buf, size_t buflen)
+ const void *buf, size_t buflen)
{
- return sg_copy_buffer(sgl, nents, buf, buflen, 0, false);
+ return sg_copy_buffer(sgl, nents, (void *)buf, buflen, 0, false);
}
EXPORT_SYMBOL(sg_copy_from_buffer);
@@ -704,9 +704,9 @@ EXPORT_SYMBOL(sg_copy_to_buffer);
*
**/
size_t sg_pcopy_from_buffer(struct scatterlist *sgl, unsigned int nents,
- void *buf, size_t buflen, off_t skip)
+ const void *buf, size_t buflen, off_t skip)
{
- return sg_copy_buffer(sgl, nents, buf, buflen, skip, false);
+ return sg_copy_buffer(sgl, nents, (void *)buf, buflen, skip, false);
}
EXPORT_SYMBOL(sg_pcopy_from_buffer);