[PATCH 2/2] fix: missing evaluate with '-include'

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

 



Symbols declared or defined in files directly or indirectly
given in the command line and thus processed via sparse()
are always automatically evaluated.
Symbols processed via sparse_initialize(), thus the predefined
ones, are not systematically evaluated, which is normaly fine
as they are just declarations and will be evaluated when needed.

However, if the command line include a file via '-include <file>',
the symbols of this file will also not be evaluated, which is still
fine as long as it's only definitions. But, in the rare and odd cases
where the file should contains a function definition, this function
will not be evaluated and it's expansion and linearization won't happen
as it should have.

Fix this by evaluating the symbols issued from sparse_intialize()
like it is done for sparse().

Reported-by: Jason A. Donenfeld <Jason@xxxxxxxxx>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 lib.c                     | 14 ++++++++++++++
 validation/include-eval.c |  1 -
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/lib.c b/lib.c
index 4602cf85d..b255fec14 100644
--- a/lib.c
+++ b/lib.c
@@ -1351,6 +1351,20 @@ struct symbol_list *sparse_initialize(int argc, char **argv, struct string_list
 		 */
 		protect_token_alloc();
 	}
+	/*
+	 * Evaluate the complete symbol list
+	 * Note: This is not needed for normal cases.
+	 *	 These symbols should only be predefined defines and
+	 *	 declaratons which will be evaluated later, when needed.
+	 *	 This is also the case when a file is directly included via
+	 *	 '-include <file>' on the command line *AND* the file only
+	 *	 contains defines, declarations and inline definitions.
+	 *	 However, in the rare cases where the given file should
+	 *	 contain some definitions, these will never be evaluated
+	 *	 and thus won't be able to be linearized correctly.
+	 *	 Hence the evaluate_symbol_list() here under.
+	 */
+	evaluate_symbol_list(list);
 	return list;
 }
 
diff --git a/validation/include-eval.c b/validation/include-eval.c
index bf9bf63fe..1a91dab84 100644
--- a/validation/include-eval.c
+++ b/validation/include-eval.c
@@ -3,5 +3,4 @@
 /*
  * check-name: include-eval.c
  * check-command: sparse -include ./include-eval.inc $file
- * check-known-to-fail
  */
-- 
2.14.0

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



[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