Commit f846619e authored by Rusty Russell's avatar Rusty Russell

lguest: clean up warnings in demonstration launcher.

These days the headers we use are in glibc.  If those are too old, you can
add the -I lines to get the kernel headers.

In file included from ../../include/linux/if_tun.h:19,
                 from lguest.c:33:
../../include/linux/types.h:13:2: warning: #warning "Attempt to use kernel headers from user space, see http://kernelnewbies.org/KernelHeaders"
lguest.c: In function ‘setup_tun_net’:
lguest.c:1456: warning: dereferencing pointer ‘sin’ does break strict-aliasing rules
lguest.c:1457: warning: dereferencing pointer ‘sin’ does break strict-aliasing rules
lguest.c:1450: note: initialized from here
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent d4348c67
# This creates the demonstration utility "lguest" which runs a Linux guest. # This creates the demonstration utility "lguest" which runs a Linux guest.
CFLAGS:=-m32 -Wall -Wmissing-declarations -Wmissing-prototypes -O3 -I../../include -I../../arch/x86/include -U_FORTIFY_SOURCE # Missing headers? Add "-I../../include -I../../arch/x86/include"
CFLAGS:=-m32 -Wall -Wmissing-declarations -Wmissing-prototypes -O3 -U_FORTIFY_SOURCE
all: lguest all: lguest
......
...@@ -39,14 +39,14 @@ ...@@ -39,14 +39,14 @@
#include <limits.h> #include <limits.h>
#include <stddef.h> #include <stddef.h>
#include <signal.h> #include <signal.h>
#include "linux/lguest_launcher.h" #include <linux/virtio_config.h>
#include "linux/virtio_config.h" #include <linux/virtio_net.h>
#include "linux/virtio_net.h" #include <linux/virtio_blk.h>
#include "linux/virtio_blk.h" #include <linux/virtio_console.h>
#include "linux/virtio_console.h" #include <linux/virtio_rng.h>
#include "linux/virtio_rng.h" #include <linux/virtio_ring.h>
#include "linux/virtio_ring.h" #include <asm/bootparam.h>
#include "asm/bootparam.h" #include "../../include/linux/lguest_launcher.h"
/*L:110 /*L:110
* We can ignore the 42 include files we need for this program, but I do want * We can ignore the 42 include files we need for this program, but I do want
* to draw attention to the use of kernel-style types. * to draw attention to the use of kernel-style types.
...@@ -1447,14 +1447,15 @@ static void add_to_bridge(int fd, const char *if_name, const char *br_name) ...@@ -1447,14 +1447,15 @@ static void add_to_bridge(int fd, const char *if_name, const char *br_name)
static void configure_device(int fd, const char *tapif, u32 ipaddr) static void configure_device(int fd, const char *tapif, u32 ipaddr)
{ {
struct ifreq ifr; struct ifreq ifr;
struct sockaddr_in *sin = (struct sockaddr_in *)&ifr.ifr_addr; struct sockaddr_in sin;
memset(&ifr, 0, sizeof(ifr)); memset(&ifr, 0, sizeof(ifr));
strcpy(ifr.ifr_name, tapif); strcpy(ifr.ifr_name, tapif);
/* Don't read these incantations. Just cut & paste them like I did! */ /* Don't read these incantations. Just cut & paste them like I did! */
sin->sin_family = AF_INET; sin.sin_family = AF_INET;
sin->sin_addr.s_addr = htonl(ipaddr); sin.sin_addr.s_addr = htonl(ipaddr);
memcpy(&ifr.ifr_addr, &sin, sizeof(sin));
if (ioctl(fd, SIOCSIFADDR, &ifr) != 0) if (ioctl(fd, SIOCSIFADDR, &ifr) != 0)
err(1, "Setting %s interface address", tapif); err(1, "Setting %s interface address", tapif);
ifr.ifr_flags = IFF_UP; ifr.ifr_flags = IFF_UP;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment