diff mbox series

[06/11] btrfs-progs: remove the _on() related message helpers

Message ID e9c06678e0b87678c9b753358c5bfe9667c07008.1681938648.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: prep work for syncing files into kernel-shared | expand

Commit Message

Josef Bacik April 19, 2023, 9:13 p.m. UTC
We have different helpers for warning_on and error_on(), which take the
condition and then do the printf.  However we can just check the
condition in the macro and call the normal warning or error helper, so
clean this usage up and delete the unneeded message helpers.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 common/messages.c | 34 ----------------------------------
 common/messages.h | 20 ++++++--------------
 2 files changed, 6 insertions(+), 48 deletions(-)

Comments

David Sterba May 2, 2023, 8:35 p.m. UTC | #1
On Wed, Apr 19, 2023 at 05:13:48PM -0400, Josef Bacik wrote:
>  #define error_on(cond, fmt, ...)					\
>  	do {								\
> -		if ((cond))						\
> +		if ((cond)) {						\
>  			PRINT_TRACE_ON_ERROR;				\
> -		if ((cond))						\
>  			PRINT_VERBOSE_ERROR;				\
> -		__btrfs_error_on((cond), (fmt), ##__VA_ARGS__);		\
> -		if ((cond))						\
> -			DO_ABORT_ON_ERROR;				\

The DO_ABORT_ON_ERROR got accidentally dropped, it should be there as
it's how 'make D=abort' is implemented.

> +			__btrfs_error((fmt), ##__VA_ARGS__);		\
> +		}							\
>  	} while (0)
diff mbox series

Patch

diff --git a/common/messages.c b/common/messages.c
index 4ef7a34a..5e7f2dfa 100644
--- a/common/messages.c
+++ b/common/messages.c
@@ -52,40 +52,6 @@  void __btrfs_error(const char *fmt, ...)
 	fputc('\n', stderr);
 }
 
-__attribute__ ((format (printf, 2, 3)))
-int __btrfs_warning_on(int condition, const char *fmt, ...)
-{
-	va_list args;
-
-	if (!condition)
-		return 0;
-
-	fputs(PREFIX_WARNING, stderr);
-	va_start(args, fmt);
-	vfprintf(stderr, fmt, args);
-	va_end(args);
-	fputc('\n', stderr);
-
-	return 1;
-}
-
-__attribute__ ((format (printf, 2, 3)))
-int __btrfs_error_on(int condition, const char *fmt, ...)
-{
-	va_list args;
-
-	if (!condition)
-		return 0;
-
-	fputs(PREFIX_ERROR, stderr);
-	va_start(args, fmt);
-	vfprintf(stderr, fmt, args);
-	va_end(args);
-	fputc('\n', stderr);
-
-	return 1;
-}
-
 __attribute__ ((format (printf, 1, 2)))
 void internal_error(const char *fmt, ...)
 {
diff --git a/common/messages.h b/common/messages.h
index b512544f..6a105484 100644
--- a/common/messages.h
+++ b/common/messages.h
@@ -50,13 +50,11 @@ 
 
 #define error_on(cond, fmt, ...)					\
 	do {								\
-		if ((cond))						\
+		if ((cond)) {						\
 			PRINT_TRACE_ON_ERROR;				\
-		if ((cond))						\
 			PRINT_VERBOSE_ERROR;				\
-		__btrfs_error_on((cond), (fmt), ##__VA_ARGS__);		\
-		if ((cond))						\
-			DO_ABORT_ON_ERROR;				\
+			__btrfs_error((fmt), ##__VA_ARGS__);		\
+		}							\
 	} while (0)
 
 #define error_btrfs_util(err)						\
@@ -81,11 +79,11 @@ 
 
 #define warning_on(cond, fmt, ...)					\
 	do {								\
-		if ((cond))						\
+		if ((cond)) {						\
 			PRINT_TRACE_ON_ERROR;				\
-		if ((cond))						\
 			PRINT_VERBOSE_ERROR;				\
-		__btrfs_warning_on((cond), (fmt), ##__VA_ARGS__);	\
+			__btrfs_warning((fmt), ##__VA_ARGS__);		\
+		}							\
 	} while (0)
 
 __attribute__ ((format (printf, 1, 2)))
@@ -94,12 +92,6 @@  void __btrfs_warning(const char *fmt, ...);
 __attribute__ ((format (printf, 1, 2)))
 void __btrfs_error(const char *fmt, ...);
 
-__attribute__ ((format (printf, 2, 3)))
-int __btrfs_warning_on(int condition, const char *fmt, ...);
-
-__attribute__ ((format (printf, 2, 3)))
-int __btrfs_error_on(int condition, const char *fmt, ...);
-
 __attribute__ ((format (printf, 1, 2)))
 void internal_error(const char *fmt, ...);