]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
lib/scatterlist: mark input buffer parameters as 'const'
authorDave Gordon <david.s.gordon@intel.com>
Tue, 30 Jun 2015 21:58:54 +0000 (14:58 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 1 Jul 2015 02:44:59 +0000 (19:44 -0700)
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>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/scatterlist.h
lib/scatterlist.c

index 50a8486c524bb29491bd4540afa4781596abdfdd..505d0481df1e95dac6bb07e004b6919bdac3565a 100644 (file)
@@ -266,12 +266,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);
 
index 965c36e7a5a46ae85cc3638c82d5d8fcd0c983ae..317b62c6da3c2ca871d2f0f236b198a47b984cba 100644 (file)
@@ -701,9 +701,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);
 
@@ -736,9 +736,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);