linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lib: crc8: Pointer to data block should be const
@ 2021-01-29 16:41 Richard Fitzgerald
  2021-01-29 22:43 ` Randy Dunlap
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Fitzgerald @ 2021-01-29 16:41 UTC (permalink / raw)
  To: rdunlap, arend; +Cc: patches, linux-kernel, Richard Fitzgerald

crc8() does not change the data passed to it, so the pointer argument
should be declared const. This avoids callers that receive const data
having to cast it to a non-const pointer to call crc8().

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
 include/linux/crc8.h | 2 +-
 lib/crc8.c           | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/crc8.h b/include/linux/crc8.h
index 13c8dabb0441..674045c59a04 100644
--- a/include/linux/crc8.h
+++ b/include/linux/crc8.h
@@ -96,6 +96,6 @@ void crc8_populate_msb(u8 table[CRC8_TABLE_SIZE], u8 polynomial);
  * Williams, Ross N., ross<at>ross.net
  * (see URL http://www.ross.net/crc/download/crc_v3.txt).
  */
-u8 crc8(const u8 table[CRC8_TABLE_SIZE], u8 *pdata, size_t nbytes, u8 crc);
+u8 crc8(const u8 table[CRC8_TABLE_SIZE], const u8 *pdata, size_t nbytes, u8 crc);
 
 #endif /* __CRC8_H_ */
diff --git a/lib/crc8.c b/lib/crc8.c
index 595a5a75e3cd..1ad8e501d9b6 100644
--- a/lib/crc8.c
+++ b/lib/crc8.c
@@ -71,7 +71,7 @@ EXPORT_SYMBOL(crc8_populate_lsb);
  * @nbytes: number of bytes in data buffer.
  * @crc: previous returned crc8 value.
  */
-u8 crc8(const u8 table[CRC8_TABLE_SIZE], u8 *pdata, size_t nbytes, u8 crc)
+u8 crc8(const u8 table[CRC8_TABLE_SIZE], const u8 *pdata, size_t nbytes, u8 crc)
 {
 	/* loop over the buffer data */
 	while (nbytes-- > 0)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] lib: crc8: Pointer to data block should be const
  2021-01-29 16:41 [PATCH] lib: crc8: Pointer to data block should be const Richard Fitzgerald
@ 2021-01-29 22:43 ` Randy Dunlap
  0 siblings, 0 replies; 2+ messages in thread
From: Randy Dunlap @ 2021-01-29 22:43 UTC (permalink / raw)
  To: Richard Fitzgerald, arend; +Cc: patches, linux-kernel

On 1/29/21 8:41 AM, Richard Fitzgerald wrote:
> crc8() does not change the data passed to it, so the pointer argument
> should be declared const. This avoids callers that receive const data
> having to cast it to a non-const pointer to call crc8().
> 
> Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
> ---
>  include/linux/crc8.h | 2 +-
>  lib/crc8.c           | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested

You need to Cc: someone to merge it, like Andrew Morton
or whoever scripts/get_maintainer.pl tells you.

Thanks.
-- 
~Randy


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-29 22:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-29 16:41 [PATCH] lib: crc8: Pointer to data block should be const Richard Fitzgerald
2021-01-29 22:43 ` Randy Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).