From 3294ce1893620aecf0d2a693c7177a0f84129422 Mon Sep 17 00:00:00 2001 From: Michael Tokarev Date: Sat, 2 Jun 2012 23:43:33 +0400 Subject: do not include needlessly or if it doesn't exist and on *BSD (some have one, some another) were #included just for openpty() declaration. The only file where this function is actually used is qemu-char.c. In vl.c and net/tap-bsd.c, none of functions declared in libutil.h (login logout logwtmp timdomain openpty forkpty uu_lock realhostname fparseln and a few others depending on version) are used. Initially the code which is currently in qemu-char.c was in vl.c, it has been removed into separate file in commit 0e82f34d077dc2542 Fri Oct 31 18:44:40 2008, but the #includes were left in vl.c. So with vl.c, we just remove includes - libutil.h, util.h and pty.h (which declares only openpty() and forkpty()) from there. The code in net/tap-bsd.c, which come from net/tap.c, had this commit 5281d757efa6e40d74ce124be048b08d43887555 Author: Mark McLoughlin Date: Thu Oct 22 17:49:07 2009 +0100 net: split all the tap code out into net/tap.c Note this commit not only moved stuff out of net.c to net/tap.c, but also rewrote large portions of the tap code, and added these completely unnecessary #includes -- as usual, I question why such a misleading commit messages are allowed. Again, no functions defined in libutil.h or util.h on *BSD are used by neither net/tap.c nor net/tap-bsd.c. Removing them. And finally, the only real user for these #includes, qemu-char.c, which actually uses openpty(). There, the #ifdef logic is wrong. A GLIBC-based system has , even if it is a variant of *BSD. So __GLIBC__ should be checked first, and instead of trying to include or , we include . If it is not GLIBC-based, we check for variations between <*util.h> as before. This patch fixes build of qemu 1.1 on Debian/kFreebsd (well, one of the two problems): it is a distribution with a FreeBSD kernel, so it #defines at least __FreeBSD_kernel__, but since it is based on GLIBC, it has , but current version does not have neither nor , which the code tries to include 3 times but uses only once. Signed-off-By: Michael Tokarev Cc: Aurelien Jarno Signed-off-by: Blue Swirl --- qemu-char.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'qemu-char.c') diff --git a/qemu-char.c b/qemu-char.c index 0bd903f58c..c2aaaeeb8f 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -56,19 +56,19 @@ #include #ifdef CONFIG_BSD #include -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -#include -#include -#include #if defined(__GLIBC__) #include +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +#include +#else +#include #endif +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#include +#include #elif defined(__DragonFly__) -#include #include #include -#else -#include #endif #else #ifdef __linux__ -- cgit v1.2.1