Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Cleanup and sanity-checking of integer overflow, null comparisons, dead code (Coverit...
[palacios.git] / palacios / src / palacios / vmm_swapping.c
index a24ef42..a5e806b 100644 (file)
@@ -31,8 +31,6 @@
 
 #include <palacios/vmm_xml.h>
 
-#include <stdio.h>
-#include <stdlib.h>
 
 /*
 
@@ -103,7 +101,7 @@ static int read_all(v3_file_t fd, void *buf, uint64_t len, uint64_t offset)
 
 #define CEIL_DIV(x,y) (((x)/(y)) + !!((x)%(y)))
 
-int v3_init_swapping_vm(struct v3_vm_info *vm, v3_cfg_tree_t *config)
+int v3_init_swapping_vm(struct v3_vm_info *vm, struct v3_xml *config)
 {
     v3_cfg_tree_t *swap_config;
     char *enable;
@@ -165,7 +163,7 @@ int v3_init_swapping_vm(struct v3_vm_info *vm, v3_cfg_tree_t *config)
 
     // Can we allocate the file?
 
-    if ((vm->swap_state.swapfd = v3_file_open(vm,file, FILE_OPEN_MODE_READ | FILE_OPEN_MODE_WRITE | FILE_OPEN_MODE_CREATE))<0) {
+    if (!(vm->swap_state.swapfd = v3_file_open(vm,file, FILE_OPEN_MODE_READ | FILE_OPEN_MODE_WRITE | FILE_OPEN_MODE_CREATE))) {
        PrintError(vm,VCORE_NONE,"swapper: cannot open or create swap file\n");
        return -1;
     } else {
@@ -198,7 +196,7 @@ int v3_init_swapping_vm(struct v3_vm_info *vm, v3_cfg_tree_t *config)
        !strcasecmp(strategy,"next_fit") ? V3_SWAP_NEXT_FIT :
        !strcasecmp(strategy,"random") ? V3_SWAP_RANDOM :
        !strcasecmp(strategy,"lru") ? V3_SWAP_LRU :
-       !strcasecmp(strategy,"default") ? V3_SWAP_RANDOM :
+       !strcasecmp(strategy,"default") ? V3_SWAP_RANDOM :  // identical branches for clarity
        V3_SWAP_RANDOM;
 
     vm->swap_state.host_mem_size=alloc;
@@ -471,7 +469,7 @@ static int swap_out_region_internal(struct v3_vm_info *vm, struct v3_mem_region
     
     for (i=0, fail=0; i<vm->num_cores;i++ ) {
        struct guest_info * core = &(vm->cores[i]);
-       int rc;
+       int rc=0;
 
        if (core->shdw_pg_mode == SHADOW_PAGING) {
            v3_mem_mode_t mem_mode = v3_get_vm_mem_mode(core);