* [Qemu-devel] [Patch] Fix compiler warnings
@ 2007-10-01 20:24 Stefan Weil
2007-11-01 15:06 ` Stefan Weil
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Weil @ 2007-10-01 20:24 UTC (permalink / raw)
To: QEMU Developers
[-- Attachment #1: Type: text/plain, Size: 312 bytes --]
Hello,
this patch fixes some compiler warnings in two QEMU source files:
* missing include unistd.h for syscall
* comparision of unsigned value with -1
(mmap returns pointer with error value MAP_FAILED)
I also replaced leading tabs in mmap.c by blanks.
Please add this patch to CVS head.
Regards
Stefan
[-- Attachment #2: qemu.patch --]
[-- Type: text/x-diff, Size: 3561 bytes --]
Index: linux-user/mmap.c
===================================================================
RCS file: /sources/qemu/qemu/linux-user/mmap.c,v
retrieving revision 1.16
diff -u -b -B -w -u -r1.16 mmap.c
--- linux-user/mmap.c 30 Sep 2007 14:32:45 -0000 1.16
+++ linux-user/mmap.c 1 Oct 2007 20:15:22 -0000
@@ -100,7 +100,7 @@
target_ulong start, target_ulong end,
int prot, int flags, int fd, target_ulong offset)
{
- target_ulong real_end, ret, addr;
+ target_ulong real_end, addr;
void *host_start;
int prot1, prot_new;
@@ -116,10 +116,10 @@
if (prot1 == 0) {
/* no page was there, so we allocate one */
- ret = (long)mmap(host_start, qemu_host_page_size, prot,
+ void *p = mmap(host_start, qemu_host_page_size, prot,
flags | MAP_ANONYMOUS, -1, 0);
- if (ret == -1)
- return ret;
+ if (p == MAP_FAILED)
+ return -1;
prot1 = prot;
}
prot1 &= PAGE_BITS;
@@ -230,16 +230,16 @@
*/
target_ulong host_end;
unsigned long host_aligned_start;
+ void *p;
host_len = HOST_PAGE_ALIGN(host_len + qemu_host_page_size
- qemu_real_host_page_size);
- host_start = (unsigned long) mmap(real_start ?
- g2h(real_start) : NULL,
- host_len, prot, flags,
- fd, host_offset);
- if (host_start == -1)
+ p = mmap(real_start ? g2h(real_start) : NULL,
+ host_len, prot, flags, fd, host_offset);
+ if (p == MAP_FAILED)
return -1;
+ host_start = (unsigned long)p;
host_end = host_start + host_len;
/* Find start and end, aligned to the targets pagesize with-in the
@@ -260,11 +260,12 @@
goto the_end1;
} else {
/* if not fixed, no need to do anything */
- host_start = (long)mmap(real_start ? g2h(real_start) : NULL,
+ void *p = mmap(real_start ? g2h(real_start) : NULL,
host_len, prot, flags, fd, host_offset);
- if (host_start == -1)
+ if (p == MAP_FAILED)
return -1;
/* update start so that it points to the file position at 'offset' */
+ host_start = (unsigned long)p;
if (!(flags & MAP_ANONYMOUS))
host_start += offset - host_offset;
start = h2g(host_start);
@@ -333,14 +334,15 @@
/* map the middle (easier) */
if (real_start < real_end) {
+ void *p;
unsigned long offset1;
if (flags & MAP_ANONYMOUS)
offset1 = 0;
else
offset1 = offset + real_start - start;
- ret = (long)mmap(g2h(real_start), real_end - real_start,
+ p = mmap(g2h(real_start), real_end - real_start,
prot, flags, fd, offset1);
- if (ret == -1)
+ if (p == MAP_FAILED)
return -1;
}
the_end1:
Index: target-i386/helper2.c
===================================================================
RCS file: /sources/qemu/qemu/target-i386/helper2.c,v
retrieving revision 1.52
diff -u -b -B -w -u -r1.52 helper2.c
--- target-i386/helper2.c 23 Sep 2007 15:28:04 -0000 1.52
+++ target-i386/helper2.c 1 Oct 2007 20:15:22 -0000
@@ -32,6 +32,7 @@
//#define DEBUG_MMU
#ifdef USE_CODE_COPY
+#include <unistd.h>
#include <asm/ldt.h>
#include <linux/unistd.h>
#include <linux/version.h>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [Patch] Fix compiler warnings
2007-10-01 20:24 [Qemu-devel] [Patch] " Stefan Weil
@ 2007-11-01 15:06 ` Stefan Weil
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Weil @ 2007-11-01 15:06 UTC (permalink / raw)
To: QEMU Developers
[-- Attachment #1: Type: text/plain, Size: 468 bytes --]
I send an update of the patch for current QEMU CVS HEAD
in the hope that it will be integrated in CVS...
Stefan
Stefan Weil schrieb:
> Hello,
>
> this patch fixes some compiler warnings in two QEMU source files:
>
> * missing include unistd.h for syscall
>
> * comparision of unsigned value with -1
> (mmap returns pointer with error value MAP_FAILED)
>
> I also replaced leading tabs in mmap.c by blanks.
>
> Please add this patch to CVS head.
>
> Regards
> Stefan
[-- Attachment #2: qemu.patch --]
[-- Type: text/x-diff, Size: 4414 bytes --]
Index: linux-user/mmap.c
===================================================================
RCS file: /sources/qemu/qemu/linux-user/mmap.c,v
retrieving revision 1.17
diff -u -r1.17 mmap.c
--- linux-user/mmap.c 14 Oct 2007 16:27:29 -0000 1.17
+++ linux-user/mmap.c 1 Nov 2007 10:22:57 -0000
@@ -37,7 +37,7 @@
#ifdef DEBUG_MMAP
printf("mprotect: start=0x" TARGET_FMT_lx
- "len=0x" TARGET_FMT_lx " prot=%c%c%c\n", start, len,
+ "len=0x" TARGET_FMT_lx " prot=%c%c%c\n", start, len,
prot & PROT_READ ? 'r' : '-',
prot & PROT_WRITE ? 'w' : '-',
prot & PROT_EXEC ? 'x' : '-');
@@ -100,7 +100,7 @@
abi_ulong start, abi_ulong end,
int prot, int flags, int fd, abi_ulong offset)
{
- abi_ulong real_end, ret, addr;
+ abi_ulong real_end, addr;
void *host_start;
int prot1, prot_new;
@@ -116,10 +116,10 @@
if (prot1 == 0) {
/* no page was there, so we allocate one */
- ret = (long)mmap(host_start, qemu_host_page_size, prot,
- flags | MAP_ANONYMOUS, -1, 0);
- if (ret == -1)
- return ret;
+ void *p = mmap(host_start, qemu_host_page_size, prot,
+ flags | MAP_ANONYMOUS, -1, 0);
+ if (p == MAP_FAILED)
+ return -1;
prot1 = prot;
}
prot1 &= PAGE_BITS;
@@ -168,7 +168,7 @@
#ifdef DEBUG_MMAP
{
printf("mmap: start=0x" TARGET_FMT_lx
- " len=0x" TARGET_FMT_lx " prot=%c%c%c flags=",
+ " len=0x" TARGET_FMT_lx " prot=%c%c%c flags=",
start, len,
prot & PROT_READ ? 'r' : '-',
prot & PROT_WRITE ? 'w' : '-',
@@ -230,16 +230,16 @@
*/
abi_ulong host_end;
unsigned long host_aligned_start;
+ void *p;
host_len = HOST_PAGE_ALIGN(host_len + qemu_host_page_size
- qemu_real_host_page_size);
- host_start = (unsigned long) mmap(real_start ?
- g2h(real_start) : NULL,
- host_len, prot, flags,
- fd, host_offset);
- if (host_start == -1)
+ p = mmap(real_start ? g2h(real_start) : NULL,
+ host_len, prot, flags, fd, host_offset);
+ if (p == MAP_FAILED)
return -1;
+ host_start = (unsigned long)p;
host_end = host_start + host_len;
/* Find start and end, aligned to the targets pagesize with-in the
@@ -260,11 +260,12 @@
goto the_end1;
} else {
/* if not fixed, no need to do anything */
- host_start = (long)mmap(real_start ? g2h(real_start) : NULL,
+ void *p = mmap(real_start ? g2h(real_start) : NULL,
host_len, prot, flags, fd, host_offset);
- if (host_start == -1)
+ if (p == MAP_FAILED)
return -1;
/* update start so that it points to the file position at 'offset' */
+ host_start = (unsigned long)p;
if (!(flags & MAP_ANONYMOUS))
host_start += offset - host_offset;
start = h2g(host_start);
@@ -333,14 +334,15 @@
/* map the middle (easier) */
if (real_start < real_end) {
+ void *p;
unsigned long offset1;
- if (flags & MAP_ANONYMOUS)
- offset1 = 0;
- else
- offset1 = offset + real_start - start;
- ret = (long)mmap(g2h(real_start), real_end - real_start,
- prot, flags, fd, offset1);
- if (ret == -1)
+ if (flags & MAP_ANONYMOUS)
+ offset1 = 0;
+ else
+ offset1 = offset + real_start - start;
+ p = mmap(g2h(real_start), real_end - real_start,
+ prot, flags, fd, offset1);
+ if (p == MAP_FAILED)
return -1;
}
the_end1:
Index: target-i386/helper2.c
===================================================================
RCS file: /sources/qemu/qemu/target-i386/helper2.c,v
retrieving revision 1.53
diff -u -r1.53 helper2.c
--- target-i386/helper2.c 14 Oct 2007 07:07:06 -0000 1.53
+++ target-i386/helper2.c 1 Nov 2007 10:22:58 -0000
@@ -32,6 +32,7 @@
//#define DEBUG_MMU
#ifdef USE_CODE_COPY
+#include <unistd.h>
#include <asm/ldt.h>
#include <linux/unistd.h>
#include <linux/version.h>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] [PATCH] Fix compiler warnings
@ 2009-08-31 14:29 Stefan Weil
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Weil @ 2009-08-31 14:29 UTC (permalink / raw)
To: QEMU Developers
Starting with commit df7a86ed735eafefbd046c8cad7134652fe3f600,
mingw32 builds result in a compiler warning for dns_addr:
CC slirp/slirp.o
/home/stefan/src/qemu/savannah/qemu/slirp/slirp.c:50: warning: missing braces around initializer
/home/stefan/src/qemu/savannah/qemu/slirp/slirp.c:50: warning: (near initialization for ‘dns_addr.S_un’)
Removing the assignment fixes the warning without the need of special code
for mingw32 (and also saves some bytes in the resulting binary).
To fix another potential compiler warning, the missing 'static'
attribute was added.
The same changes were applied to dns_addr_time.
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
slirp/slirp.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/slirp/slirp.c b/slirp/slirp.c
index b5335a5..691420e 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -47,8 +47,8 @@ static int do_slowtimo;
static TAILQ_HEAD(slirp_instances, Slirp) slirp_instances =
TAILQ_HEAD_INITIALIZER(slirp_instances);
-struct in_addr dns_addr = { 0 };
-u_int dns_addr_time = 0;
+static struct in_addr dns_addr;
+static u_int dns_addr_time;
#ifdef _WIN32
--
1.5.6.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-08-31 14:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-31 14:29 [Qemu-devel] [PATCH] Fix compiler warnings Stefan Weil
-- strict thread matches above, loose matches on Subject: below --
2007-10-01 20:24 [Qemu-devel] [Patch] " Stefan Weil
2007-11-01 15:06 ` Stefan Weil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).