Powered by Linux
[PATCH 6/9] check_kernel_printf.c: support %pC — Semantic Matching Tool

[PATCH 6/9] check_kernel_printf.c: support %pC

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

 



The kernel now has %pC which expects a "struct clk *". Check for that.

Signed-off-by: Rasmus Villemoes <rv@xxxxxxxxxxxxxxxxxx>
---
 check_kernel_printf.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/check_kernel_printf.c b/check_kernel_printf.c
index 6b2b96f..652da69 100644
--- a/check_kernel_printf.c
+++ b/check_kernel_printf.c
@@ -521,6 +521,20 @@ static void dentry_file(const char *fmt, struct symbol *type, struct symbol *bas
 			fmt[0], tag, vaidx, type_to_str(type));
 }
 
+static void clock(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx)
+{
+	assert(fmt[0] == 'C');
+	if (isalnum(fmt[1])) {
+		if (!strchr("nr", fmt[1]))
+			sm_msg("warn: '%%pC' can only be followed by one of [nr]");
+		if (isalnum(fmt[2]))
+			sm_msg("warn: '%%pC%c' cannot be followed by '%c'", fmt[1], fmt[2]);
+	}
+	if (!is_struct_tag(basetype, "clk"))
+		sm_msg("error: '%%pC' expects argument of type 'struct clk*', argument %d has type '%s'",
+		       vaidx, type_to_str(type));
+}
+
 static void va_format(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx)
 {
 	assert(fmt[0] == 'V');
@@ -689,6 +703,9 @@ pointer(const char *fmt, struct expression *arg, int vaidx)
 	case 'd':
 		dentry_file(fmt, type, basetype, vaidx);
 		break;
+	case 'C':
+		clock(fmt, type, basetype, vaidx);
+		break;
 	default:
 		sm_msg("error: unrecognized %%p extension '%c', treated as normal %%p", *fmt);
 	}
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe smatch" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux