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 switch issues, negative array indexes, operand indepen...
[palacios.git] / palacios / src / devices / generic.c
index ba2965f..1e06a80 100644 (file)
@@ -194,14 +194,19 @@ static int generic_read_port_print_and_passthrough(struct guest_info * core, uin
 
     rc=generic_read_port_passthrough(core,port,src,length,priv_data);
 
-    PrintDebug(core->vm_info, core, " done ... read 0x");
-
-    for (i = 0; i < rc; i++) { 
-       PrintDebug(core->vm_info, core, "%x", ((uint8_t *)src)[i]);
+    if (rc<0) { 
+       PrintError(core->vm_info, core, "FAILED\n");
+       return rc;
+    } else {
+       PrintDebug(core->vm_info, core, " done ... read 0x");
+       
+       for (i = 0; i < rc; i++) { 
+           PrintDebug(core->vm_info, core, "%x", ((uint8_t *)src)[i]);
+       }
+       
+       PrintDebug(core->vm_info, core, "\n");
     }
-
-    PrintDebug(core->vm_info, core, "\n");
-
+    
     return rc;
 }
 
@@ -691,6 +696,7 @@ static int generic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
     
     memset(state, 0, sizeof(struct generic_internal));
     strncpy(state->name,dev_id,MAX_NAME);
+    state->name[MAX_NAME-1] = 0;
 
     if (!forward) { 
        state->forward_type=GENERIC_PHYSICAL;
@@ -749,6 +755,10 @@ static int generic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
        uint16_t start = atox(v3_cfg_val(port_cfg, "start"));
        uint16_t end = atox(v3_cfg_val(port_cfg, "end"));
        char * mode_str = v3_cfg_val(port_cfg, "mode");
+    if (!mode_str) {
+        PrintError(vm, VCORE_NONE, "generic (%s): error getting port mode\n", state->name);
+        return -1;
+    }
        generic_mode_t mode = GENERIC_IGNORE;
        if (strcasecmp(mode_str, "print_and_ignore") == 0) {
            mode = GENERIC_PRINT_AND_IGNORE;