[PATCH 05/13] format-check: remove unneeded member: target

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The signature of the checking method allow to return the target
type. But this is never needed as it is always statically known.

So, remove this argument.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 verify-format.c | 33 +++++++++++++--------------------
 1 file changed, 13 insertions(+), 20 deletions(-)

diff --git a/verify-format.c b/verify-format.c
index 99a36c8eef5f..0ef2cb863ae9 100644
--- a/verify-format.c
+++ b/verify-format.c
@@ -57,7 +57,6 @@ struct format_type {
 	int		(*test)(struct format_type *fmt,
 				struct expression **expr,
 				struct symbol *ctype,
-				struct symbol **target,
 				const char **typediff);
 	struct symbol	*type;
 };
@@ -102,41 +101,35 @@ static inline int type_class(struct symbol *type, struct symbol **base)
 static int printf_fmt_numtype(struct format_type *fmt,
 			      struct expression **expr,
 			      struct symbol *ctype,
-			      struct symbol **target, const char **typediff)
+			      const char **typediff)
 {
-	struct symbol *type = fmt->type;
-	*target = type;
-	return check_assignment_types(*target, expr, typediff);
+	return check_assignment_types(fmt->type, expr, typediff);
 }
 
 static int printf_fmt_string(struct format_type *fmt,
 			     struct expression **expr,
 			     struct symbol *ctype,
-			     struct symbol **target, const char **typediff)
+			     const char **typediff)
 {
-	*target = fmt->type;
-	return check_assignment_types(*target, expr, typediff);
+	return check_assignment_types(fmt->type, expr, typediff);
 }
 
 static int printf_fmt_pointer(struct format_type *fmt,
 			      struct expression **expr,
 			      struct symbol *ctype,
-			      struct symbol **target, const char **typediff)
+			      const char **typediff)
 {
-	*target = &const_ptr_ctype;
-	return check_assignment_types(*target, expr, typediff);
+	return check_assignment_types(fmt->type, expr, typediff);
 }
 
 static int printf_fmt_print_pointer(struct format_type *fmt,
 				    struct expression **expr,
 				    struct symbol *ctype,
-				    struct symbol **target,
 				    const char **typediff)
 {
 	// TODO TODO: fix this here!!!
 	int ret;
-	*target = &const_ptr_ctype;
-	ret = check_assignment_types(*target, expr, typediff);
+	ret = check_assignment_types(fmt->type, expr, typediff);
 	if (ret == 0) {
 		/* if just printing, ignore address-space mismatches */
 		if (strcmp(*typediff, "different address spaces") == 0)
@@ -148,6 +141,7 @@ static int printf_fmt_print_pointer(struct format_type *fmt,
 static struct format_type printf_fmt_ptr_ref = {
 	.format = "p",
 	.test = printf_fmt_pointer,
+	.type = &const_ptr_ctype,
 };
 
 static struct format_type *parse_printf_get_fmt(struct format_type *type,
@@ -295,6 +289,7 @@ static struct format_type *parse_printf_get_fmt(struct format_type *type,
 		break;
 	case 'p':
 		type->test = printf_fmt_print_pointer;
+		type->type = &const_ptr_ctype;
 		/* check for pointer being printed as hex explicitly */
 		if (*ptr == 'x' || *ptr == 'X') {
 			ptr++;
@@ -309,6 +304,7 @@ static struct format_type *parse_printf_get_fmt(struct format_type *type,
 		// todo - we should construct pointer to int/etc //
 		// also should not have any flags or widths for this
 		type->test = printf_fmt_pointer;
+		type->type = &const_ptr_ctype;
 		break;
 	default:
 		// anything else here?
@@ -474,7 +470,7 @@ static int parse_format_printf(const char **fmtstring,
 		type = &printf_fmt_ptr_ref;	/* probably some extension */
 
 	if (type) {
-		struct symbol *ctype, *target = NULL;
+		struct symbol *ctype;
 		const char *typediff = "different types";
 		int ret;
 
@@ -490,13 +486,10 @@ static int parse_format_printf(const char **fmtstring,
 		if (!ctype)
 			return -3;
 
-		ret = type->test(type, &expr, ctype, &target, &typediff);
-		if (!target)	/* shouldn't happen, but catch anyway */
-			return -4;
-
+		ret = type->test(type, &expr, ctype, &typediff);
 		if (ret == 0) {
 			warning(expr->pos, "incorrect type in argument %d (%s)", pos, typediff);
-			info(expr->pos, "   expected %s", show_typename(target));
+			info(expr->pos, "   expected %s", show_typename(type->type));
 			info(expr->pos, "   got %s", show_typename(ctype));
 		}
 	} else {
-- 
2.28.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux