[2/3] xfs: constify the buffer pointer arguments to error functions
diff mbox series

Message ID 157281983593.4150947.13692433066759624464.stgit@magnolia
State Superseded
Headers show
Series
  • xfs: tidy up corruption reporting
Related show

Commit Message

Darrick J. Wong Nov. 3, 2019, 10:23 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Some of the xfs error message functions take a pointer to a buffer that
will be dumped to the system log.  The logging functions don't change
the contents, so constify all the parameters.  This enables the next
patch to ensure that we log bad metadata when we encounter it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/xfs_error.c   |    6 +++---
 fs/xfs/xfs_error.h   |    6 +++---
 fs/xfs/xfs_message.c |    2 +-
 fs/xfs/xfs_message.h |    2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

Comments

Carlos Maiolino Nov. 4, 2019, 3:44 p.m. UTC | #1
On Sun, Nov 03, 2019 at 02:23:55PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Some of the xfs error message functions take a pointer to a buffer that
> will be dumped to the system log.  The logging functions don't change
> the contents, so constify all the parameters.  This enables the next
> patch to ensure that we log bad metadata when we encounter it.
> 

Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>

> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  fs/xfs/xfs_error.c   |    6 +++---
>  fs/xfs/xfs_error.h   |    6 +++---
>  fs/xfs/xfs_message.c |    2 +-
>  fs/xfs/xfs_message.h |    2 +-
>  4 files changed, 8 insertions(+), 8 deletions(-)
> 
> 
> diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
> index 849fd4476950..0b156cc88108 100644
> --- a/fs/xfs/xfs_error.c
> +++ b/fs/xfs/xfs_error.c
> @@ -329,7 +329,7 @@ xfs_corruption_error(
>  	const char		*tag,
>  	int			level,
>  	struct xfs_mount	*mp,
> -	void			*buf,
> +	const void		*buf,
>  	size_t			bufsize,
>  	const char		*filename,
>  	int			linenum,
> @@ -350,7 +350,7 @@ xfs_buf_verifier_error(
>  	struct xfs_buf		*bp,
>  	int			error,
>  	const char		*name,
> -	void			*buf,
> +	const void		*buf,
>  	size_t			bufsz,
>  	xfs_failaddr_t		failaddr)
>  {
> @@ -402,7 +402,7 @@ xfs_inode_verifier_error(
>  	struct xfs_inode	*ip,
>  	int			error,
>  	const char		*name,
> -	void			*buf,
> +	const void		*buf,
>  	size_t			bufsz,
>  	xfs_failaddr_t		failaddr)
>  {
> diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
> index 602aa7d62b66..e6a22cfb542f 100644
> --- a/fs/xfs/xfs_error.h
> +++ b/fs/xfs/xfs_error.h
> @@ -12,16 +12,16 @@ extern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp,
>  			const char *filename, int linenum,
>  			xfs_failaddr_t failaddr);
>  extern void xfs_corruption_error(const char *tag, int level,
> -			struct xfs_mount *mp, void *buf, size_t bufsize,
> +			struct xfs_mount *mp, const void *buf, size_t bufsize,
>  			const char *filename, int linenum,
>  			xfs_failaddr_t failaddr);
>  extern void xfs_buf_verifier_error(struct xfs_buf *bp, int error,
> -			const char *name, void *buf, size_t bufsz,
> +			const char *name, const void *buf, size_t bufsz,
>  			xfs_failaddr_t failaddr);
>  extern void xfs_verifier_error(struct xfs_buf *bp, int error,
>  			xfs_failaddr_t failaddr);
>  extern void xfs_inode_verifier_error(struct xfs_inode *ip, int error,
> -			const char *name, void *buf, size_t bufsz,
> +			const char *name, const void *buf, size_t bufsz,
>  			xfs_failaddr_t failaddr);
>  
>  #define	XFS_ERROR_REPORT(e, lvl, mp)	\
> diff --git a/fs/xfs/xfs_message.c b/fs/xfs/xfs_message.c
> index 9804efe525a9..c57e8ad39712 100644
> --- a/fs/xfs/xfs_message.c
> +++ b/fs/xfs/xfs_message.c
> @@ -105,7 +105,7 @@ assfail(char *expr, char *file, int line)
>  }
>  
>  void
> -xfs_hex_dump(void *p, int length)
> +xfs_hex_dump(const void *p, int length)
>  {
>  	print_hex_dump(KERN_ALERT, "", DUMP_PREFIX_OFFSET, 16, 1, p, length, 1);
>  }
> diff --git a/fs/xfs/xfs_message.h b/fs/xfs/xfs_message.h
> index 34447dca97d1..7f040b04b739 100644
> --- a/fs/xfs/xfs_message.h
> +++ b/fs/xfs/xfs_message.h
> @@ -60,6 +60,6 @@ do {									\
>  extern void assfail(char *expr, char *f, int l);
>  extern void asswarn(char *expr, char *f, int l);
>  
> -extern void xfs_hex_dump(void *p, int length);
> +extern void xfs_hex_dump(const void *p, int length);
>  
>  #endif	/* __XFS_MESSAGE_H */
>
Christoph Hellwig Nov. 4, 2019, 7:25 p.m. UTC | #2
On Sun, Nov 03, 2019 at 02:23:55PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Some of the xfs error message functions take a pointer to a buffer that
> will be dumped to the system log.  The logging functions don't change
> the contents, so constify all the parameters.  This enables the next
> patch to ensure that we log bad metadata when we encounter it.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

Patch
diff mbox series

diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index 849fd4476950..0b156cc88108 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -329,7 +329,7 @@  xfs_corruption_error(
 	const char		*tag,
 	int			level,
 	struct xfs_mount	*mp,
-	void			*buf,
+	const void		*buf,
 	size_t			bufsize,
 	const char		*filename,
 	int			linenum,
@@ -350,7 +350,7 @@  xfs_buf_verifier_error(
 	struct xfs_buf		*bp,
 	int			error,
 	const char		*name,
-	void			*buf,
+	const void		*buf,
 	size_t			bufsz,
 	xfs_failaddr_t		failaddr)
 {
@@ -402,7 +402,7 @@  xfs_inode_verifier_error(
 	struct xfs_inode	*ip,
 	int			error,
 	const char		*name,
-	void			*buf,
+	const void		*buf,
 	size_t			bufsz,
 	xfs_failaddr_t		failaddr)
 {
diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
index 602aa7d62b66..e6a22cfb542f 100644
--- a/fs/xfs/xfs_error.h
+++ b/fs/xfs/xfs_error.h
@@ -12,16 +12,16 @@  extern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp,
 			const char *filename, int linenum,
 			xfs_failaddr_t failaddr);
 extern void xfs_corruption_error(const char *tag, int level,
-			struct xfs_mount *mp, void *buf, size_t bufsize,
+			struct xfs_mount *mp, const void *buf, size_t bufsize,
 			const char *filename, int linenum,
 			xfs_failaddr_t failaddr);
 extern void xfs_buf_verifier_error(struct xfs_buf *bp, int error,
-			const char *name, void *buf, size_t bufsz,
+			const char *name, const void *buf, size_t bufsz,
 			xfs_failaddr_t failaddr);
 extern void xfs_verifier_error(struct xfs_buf *bp, int error,
 			xfs_failaddr_t failaddr);
 extern void xfs_inode_verifier_error(struct xfs_inode *ip, int error,
-			const char *name, void *buf, size_t bufsz,
+			const char *name, const void *buf, size_t bufsz,
 			xfs_failaddr_t failaddr);
 
 #define	XFS_ERROR_REPORT(e, lvl, mp)	\
diff --git a/fs/xfs/xfs_message.c b/fs/xfs/xfs_message.c
index 9804efe525a9..c57e8ad39712 100644
--- a/fs/xfs/xfs_message.c
+++ b/fs/xfs/xfs_message.c
@@ -105,7 +105,7 @@  assfail(char *expr, char *file, int line)
 }
 
 void
-xfs_hex_dump(void *p, int length)
+xfs_hex_dump(const void *p, int length)
 {
 	print_hex_dump(KERN_ALERT, "", DUMP_PREFIX_OFFSET, 16, 1, p, length, 1);
 }
diff --git a/fs/xfs/xfs_message.h b/fs/xfs/xfs_message.h
index 34447dca97d1..7f040b04b739 100644
--- a/fs/xfs/xfs_message.h
+++ b/fs/xfs/xfs_message.h
@@ -60,6 +60,6 @@  do {									\
 extern void assfail(char *expr, char *f, int l);
 extern void asswarn(char *expr, char *f, int l);
 
-extern void xfs_hex_dump(void *p, int length);
+extern void xfs_hex_dump(const void *p, int length);
 
 #endif	/* __XFS_MESSAGE_H */