tools: portability fixes
PATCH 1/1 tools: portability fixes
Hi!
Attached patch makes gtraceview compile on NetBSD.
@Guanqun.Lu:
1. Why do you hardcode -lncurses, when there is a CURSES_LIBS variable ? The existence of it should have ring an alarm bell that your code isn't portable, i.e. that you can't blindly include <ncurses.h>.
2. The string operations look dangerous in respect to security. Please fix them.
Christoph
Signature · 6 lines
---to satisfy European Law for business letters: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
tools/misc/Makefile +1 -1
@@ -57,6 +57,6 @@ xenperf xenpm gtracestat: %: %.o Makefil $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDFLAGS_libxenctrl) gtraceview: %: %.o Makefile - $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) -lncurses + $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(CURSES_LIBS) -include $(DEPS)
tools/misc/gtraceview.c +6 -0
@@ -19,6 +19,7 @@#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <stdarg.h> #include <unistd.h> #include <fcntl.h> #include <inttypes.h>
@@ -29,7 +30,12 @@#include <xenctrl.h> #include <xen/trace.h> +#ifdef __Linux__#include <ncurses.h> +#endif +#ifdef __NetBSD__ +#include <curses.h> +#endif /********** MACROS **********/ #define MAX_CPU_NR 32
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 10 lines
-----Original Message-----
From: Christoph Egger [mailto:[email protected]]
Sent: Thursday, July 02, 2009 6:03 PM
To: [email protected]
Cc: Lu, Guanqun
Subject: [PATCH] tools: portability fixesHi!
Quoted 8 lines
Attached patch makes gtraceview compile on NetBSD.
Signed-off-by Christoph Egger <[email protected]>@Guanqun.Lu:
1. Why do you hardcode -lncurses, when there is aCURSES_LIBSvariable ? The existence of it should have ring an alarm bell that your code isn't portable, i.e. that you can't blindly include <ncurses.h>.
It seems I'm still missing something when I try not to. Thanks for your finding.
Quoted 2 lines
2. The string operations look dangerous in respect to security. Please fix them.
It uses the fixed length currently for the ease of programming at first. It will be fixed. Thanks for the reminder.
Quoted 11 lines
Christoph
--
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632