[PATCH 13/18] sparse: prefix output with progname

John Levon <[email protected]>
Newsgroups org.kernel.vger.smatch
Message-ID <[email protected]>
Signed-off-by: John Levon <[email protected]>
---
 lib.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib.c b/lib.c
index 8924c2eb..a82408e8 100644
--- a/lib.c
+++ b/lib.c
@@ -45,6 +45,8 @@
 #include "target.h"
 #include "version.h"
 
+static const char *progname;
+
 int verbose, optimize, optimize_size, preprocessing;
 int die_if_error = 0;
 int parse_error;
@@ -111,8 +113,8 @@ static void do_warn(const char *type, struct position pos, const char * fmt, va_
 	vsprintf(buffer, fmt, args);	
 	name = stream_name(pos.stream);
 		
-	fprintf(stderr, "%s:%d:%d: %s%s\n",
-		name, pos.line, pos.pos, type, buffer);
+	fprintf(stderr, "%s: %s:%d:%d: %s%s\n",
+		progname, name, pos.line, pos.pos, type, buffer);
 }
 
 static int max_warnings = 100;
@@ -214,7 +216,7 @@ void die(const char *fmt, ...)
 	vsnprintf(buffer, sizeof(buffer), fmt, args);
 	va_end(args);
 
-	fprintf(stderr, "%s\n", buffer);
+	fprintf(stderr, "%s: %s\n", progname, buffer);
 	exit(1);
 }
 
@@ -1363,6 +1365,8 @@ struct symbol_list *sparse_initialize(int argc, char **argv, struct string_list
 	init_symbols();
 	init_include_path();
 
+	progname = argv[0];
+
 	args = argv;
 	for (;;) {
 		char *arg = *++args;
-- 
2.14.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.