Skip to contentSkip to conversation

sparse: Skip TCID and TST_TOTAL

PATCH In review Cyril Hrubis 3 participants 7 messages Nov 30, 2021 – Dec 7, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sparse: Skip TCID and TST_TOTAL

Since these are part of the old library API.

---
 tools/sparse/sparse-ltp.c | 3 +++
 1 file changed, 3 insertions(+)
tools/sparse/sparse-ltp.c +3 -0
index b1677d336..1a3b4089a 100644
@@ -98,6 +98,9 @@ static void check_symbol_visibility(const struct symbol *const sym)
 	if (!(mod & MOD_TOPLEVEL))
 		return;
 
+	if (!strcmp(name, "TCID") || !strcmp(name, "TST_TOTAL"))
+		return;
+
 	if (has_lib_prefix && (mod & MOD_STATIC) && !(mod & MOD_INLINE)) {
 		warning(sym->pos,
 			"LTP-003: Symbol '%s' has the LTP public library prefix, but is static (private).",
Signature · 5 lines
2.32.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hello,

Quoted 12 lines · Cyril Hrubis

Since these are part of the old library API.

---
 tools/sparse/sparse-ltp.c | 3 +++
 1 file changed, 3 insertions(+)
tools/sparse/sparse-ltp.c +0 -0
index b1677d336..1a3b4089a 100644

tools/sparse/sparse-ltp.c static void check_symbol_visibility(const struct symbol *const sym) · line 102

Quoted 5 lines
tools/sparse/sparse-ltp.c +2 -0
@@ -98,6 +98,9 @@ static void check_symbol_visibility(const struct symbol *const sym)
 	if (!(mod & MOD_TOPLEVEL))
 		return;
 
+	if (!strcmp(name, "TCID") || !strcmp(name, "TST_TOTAL"))
+		return;

Would it be better to print a warning that old library crap has been detected?

My expectation is that 'make check' will produce a lot of noise if ran on tests which haven't even been converted to the new library. Also it's possible someone may forget to remove TCID etc.

Quoted 6 lines
tools/sparse/sparse-ltp.c +1 -0
+
 	if (has_lib_prefix && (mod & MOD_STATIC) && !(mod & MOD_INLINE)) {
 		warning(sym->pos,
 			"LTP-003: Symbol '%s' has the LTP public library prefix, but is static (private).",
Signature · 1 line
2.32.0
Signature · 5 lines
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Hi!

Quoted 15 lines
Quoted 15 lines

Since these are part of the old library API.

---
 tools/sparse/sparse-ltp.c | 3 +++
 1 file changed, 3 insertions(+)
tools/sparse/sparse-ltp.c +0 -0
index b1677d336..1a3b4089a 100644
@@ -98,6 +98,9 @@ static void check_symbol_visibility(const struct symbol *const sym)
 	if (!(mod & MOD_TOPLEVEL))
 		return;
 
Quoted 5 lines

tools/sparse/sparse-ltp.c static void check_symbol_visibility(const struct symbol *const sym) · line 102

Quoted 2 lines
tools/sparse/sparse-ltp.c +2 -0
+	if (!strcmp(name, "TCID") || !strcmp(name, "TST_TOTAL"))
+		return;

Would it be better to print a warning that old library crap has been detected?

I guess so.

Quoted 3 lines

My expectation is that 'make check' will produce a lot of noise if ran on tests which haven't even been converted to the new library. Also it's possible someone may forget to remove TCID etc.

Well we may as well print the warnings only if new library test is detected. But I guess that is not an easy task since we would have to look at the include directives even before we attempt to parse the file..

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

Hello,

Quoted 24 lines · Cyril Hrubis

Hi!

Quoted 15 lines
Quoted 15 lines

Since these are part of the old library API.

---
 tools/sparse/sparse-ltp.c | 3 +++
 1 file changed, 3 insertions(+)
tools/sparse/sparse-ltp.c +0 -0
index b1677d336..1a3b4089a 100644
@@ -98,6 +98,9 @@ static void check_symbol_visibility(const struct symbol *const sym)
 	if (!(mod & MOD_TOPLEVEL))
 		return;
 
Quoted 5 lines

tools/sparse/sparse-ltp.c static void check_symbol_visibility(const struct symbol *const sym) · line 102

Quoted 2 lines
tools/sparse/sparse-ltp.c +2 -0
+	if (!strcmp(name, "TCID") || !strcmp(name, "TST_TOTAL"))
+		return;

Would it be better to print a warning that old library crap has been detected?

I guess so.

Quoted 8 lines
Quoted 3 lines

My expectation is that 'make check' will produce a lot of noise if ran on tests which haven't even been converted to the new library. Also it's possible someone may forget to remove TCID etc.

Well we may as well print the warnings only if new library test is detected. But I guess that is not an easy task since we would have to look at the include directives even before we attempt to parse the file..

Some checks may require detecting the type of translation unit in an initial pass. At which point we will probably get this for free.

Signature · 5 lines
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

PATCH 1/1 check: Deprecated API symbols

In reply to Cyril Hrubis

The old API represents a big source of complication. It invalidates a lot of assumptions we can make when writing checks specifically for the new API.

Cyril proposed ignoring these symbols altogether in a previous patch. This is a counter proposal to print a warning, but then abandon checking the symbol any further.

The reasoning is that ignoring them altogether might hide errors. Also the existence of the old API may be a surprise to new developers. This change will alert them that a test needs updating and that it is not to be used as a reference.

---
 tools/sparse/sparse-ltp.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
tools/sparse/sparse-ltp.c +29 -0
index 3a38229f1..513033518 100644
@@ -81,6 +81,32 @@ static void do_entrypoint_checks(struct entrypoint *ep)
 		do_basicblock_checks(bb);
 	} END_FOR_EACH_PTR(bb);
 }
+/* The old API can not comply with the rules. So when we see one of
+ * these symbols we know that it will result in further
+ * warnings. Probably these will suggest inappropriate things. Usually
+ * these symbols should be removed and the new API used
+ * instead. Otherwise they can be ignored until all tests have been
+ * converted to the new API.
+ */
+static bool check_symbol_deprecated(const struct symbol *const sym)
+{
+	static struct ident *TCID_id, *TST_TOTAL_id;
+	const struct ident *id = sym->ident;
+
+	if (!TCID_id) {
+		TCID_id = built_in_ident("TCID");
+		TST_TOTAL_id = built_in_ident("TST_TOTAL");
+	}
+
+	if (id != TCID_id && id != TST_TOTAL_id)
+		return false;
+
+	warning(sym->pos,
+		"Ignoring deprecated API symbol: '%s'. Should this code be converted to the new API?",
+		show_ident(id));
+
+	return true;
+}
 
 /* Check for LTP-003 and LTP-004
  *
@@ -212,6 +238,9 @@ static void check_test_struct(const struct symbol *const sym)
 /* AST level checks */
 static void do_symbol_checks(struct symbol *sym)
 {
+	if (check_symbol_deprecated(sym))
+		return;
+
 	check_symbol_visibility(sym);
 	check_test_struct(sym);
 }
Signature · 5 lines
2.34.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author Reviewed-by on v1 1/1
#5 lore raw

Re: [LTP] [PATCH] check: Deprecated API symbols

Hi!

Quoted 8 lines

The old API represents a big source of complication. It invalidates a lot of assumptions we can make when writing checks specifically for the new API.

Cyril proposed ignoring these symbols altogether in a previous patch. This is a counter proposal to print a warning, but then abandon checking the symbol any further.

Quoted 6 lines

The reasoning is that ignoring them altogether might hide errors. Also the existence of the old API may be a surprise to new developers. This change will alert them that a test needs updating and that it is not to be used as a reference.

Sounds good to me:

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

Re: [LTP] [PATCH] check: Deprecated API symbols

Hello,

Quoted 14 lines · Cyril Hrubis

Hi!

Quoted 13 lines

The old API represents a big source of complication. It invalidates a lot of assumptions we can make when writing checks specifically for the new API.

Cyril proposed ignoring these symbols altogether in a previous patch. This is a counter proposal to print a warning, but then abandon checking the symbol any further.

The reasoning is that ignoring them altogether might hide errors. Also the existence of the old API may be a surprise to new developers. This change will alert them that a test needs updating and that it is not to be used as a reference.

Quoted 5 lines
Quoted 1 line

Sounds good to me:

Thanks, pushed!

Signature · 5 lines
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp