ia64/xen-unstable

changeset 4866:f80fbc4d6526

bitkeeper revision 1.1389.19.5 (42833116hOft6cekTRSGqSIk2tNzGA)

[PATCH] [PATCH] libxc: mmap doesn't return NULL on error...

Hi, was reading libxc code, and noticed this. Patch is bigger than
strictly necessary due to indent adjust.

Against latest bk.
Rusty.
author rusty@rustcorp.com.au[kaf24]
date Thu May 12 10:33:58 2005 +0000 (2005-05-12)
parents b6186f6b202e
children a9b0f5ea7651
files BitKeeper/etc/logging_ok tools/libxc/xc.h tools/libxc/xc_private.c
line diff
     1.1 --- a/BitKeeper/etc/logging_ok	Thu May 12 10:31:31 2005 +0000
     1.2 +++ b/BitKeeper/etc/logging_ok	Thu May 12 10:33:58 2005 +0000
     1.3 @@ -80,6 +80,7 @@ rn@wyvis.camb.intel-research.net
     1.4  rn@wyvis.research.intel-research.net
     1.5  rneugeba@wyvis.research
     1.6  rneugeba@wyvis.research.intel-research.net
     1.7 +rusty@rustcorp.com.au
     1.8  ryanh@us.ibm.com
     1.9  sd386@font.cl.cam.ac.uk
    1.10  shand@spidean.research.intel-research.net
     2.1 --- a/tools/libxc/xc.h	Thu May 12 10:31:31 2005 +0000
     2.2 +++ b/tools/libxc/xc.h	Thu May 12 10:33:58 2005 +0000
     2.3 @@ -421,7 +421,7 @@ int xc_msr_write(int xc_handle, int cpu_
     2.4  /**
     2.5   * Memory maps a range within one domain to a local address range.  Mappings
     2.6   * should be unmapped with munmap and should follow the same rules as mmap
     2.7 - * regarding page alignment.
     2.8 + * regarding page alignment.  Returns NULL on failure.
     2.9   *
    2.10   * In Linux, the ring queue for the control channel is accessible by mapping
    2.11   * the shared_info_frame (from xc_domain_getinfo()) + 2048.  The structure
     3.1 --- a/tools/libxc/xc_private.c	Thu May 12 10:31:31 2005 +0000
     3.2 +++ b/tools/libxc/xc_private.c	Thu May 12 10:33:58 2005 +0000
     3.3 @@ -13,18 +13,18 @@ void *xc_map_foreign_batch(int xc_handle
     3.4      privcmd_mmapbatch_t ioctlx; 
     3.5      void *addr;
     3.6      addr = mmap(NULL, num*PAGE_SIZE, prot, MAP_SHARED, xc_handle, 0);
     3.7 -    if ( addr != NULL )
     3.8 +    if ( addr == MAP_FAILED )
     3.9 +	return NULL;
    3.10 +
    3.11 +    ioctlx.num=num;
    3.12 +    ioctlx.dom=dom;
    3.13 +    ioctlx.addr=(unsigned long)addr;
    3.14 +    ioctlx.arr=arr;
    3.15 +    if ( ioctl( xc_handle, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx ) < 0 )
    3.16      {
    3.17 -        ioctlx.num=num;
    3.18 -        ioctlx.dom=dom;
    3.19 -        ioctlx.addr=(unsigned long)addr;
    3.20 -        ioctlx.arr=arr;
    3.21 -        if ( ioctl( xc_handle, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx ) < 0 )
    3.22 -        {
    3.23 -            perror("XXXXXXXX");
    3.24 -            munmap(addr, num*PAGE_SIZE);
    3.25 -            return 0;
    3.26 -        }
    3.27 +	perror("XXXXXXXX");
    3.28 +	munmap(addr, num*PAGE_SIZE);
    3.29 +	return NULL;
    3.30      }
    3.31      return addr;
    3.32  
    3.33 @@ -40,19 +40,19 @@ void *xc_map_foreign_range(int xc_handle
    3.34      privcmd_mmap_entry_t entry; 
    3.35      void *addr;
    3.36      addr = mmap(NULL, size, prot, MAP_SHARED, xc_handle, 0);
    3.37 -    if ( addr != NULL )
    3.38 +    if ( addr == MAP_FAILED )
    3.39 +	return NULL;
    3.40 +
    3.41 +    ioctlx.num=1;
    3.42 +    ioctlx.dom=dom;
    3.43 +    ioctlx.entry=&entry;
    3.44 +    entry.va=(unsigned long) addr;
    3.45 +    entry.mfn=mfn;
    3.46 +    entry.npages=(size+PAGE_SIZE-1)>>PAGE_SHIFT;
    3.47 +    if ( ioctl( xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx ) < 0 )
    3.48      {
    3.49 -        ioctlx.num=1;
    3.50 -        ioctlx.dom=dom;
    3.51 -        ioctlx.entry=&entry;
    3.52 -        entry.va=(unsigned long) addr;
    3.53 -        entry.mfn=mfn;
    3.54 -        entry.npages=(size+PAGE_SIZE-1)>>PAGE_SHIFT;
    3.55 -        if ( ioctl( xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx ) < 0 )
    3.56 -        {
    3.57 -            munmap(addr, size);
    3.58 -            return 0;
    3.59 -        }
    3.60 +	munmap(addr, size);
    3.61 +	return NULL;
    3.62      }
    3.63      return addr;
    3.64  }