sim: Use NULL instead of None for testing filenames.
authorNilay Vaish <nilay@cs.wisc.edu>
Mon, 13 Apr 2015 22:33:57 +0000 (17:33 -0500)
committerNilay Vaish <nilay@cs.wisc.edu>
Mon, 13 Apr 2015 22:33:57 +0000 (17:33 -0500)
The filenames are initialized with NULL.  So the test should be
checking for them to be == NULL instead == None.

src/sim/process.cc
src/sim/process.hh

index 2e5f64497acdbe69dc642613a51bca3b5a706928..ea6308de6bedbbf883a7e472f6118622df30b9f3 100644 (file)
@@ -272,7 +272,8 @@ Process::dup_fd(int sim_fd, int tgt_fd)
 
 // generate new target fd for sim_fd
 int
-Process::alloc_fd(int sim_fd, string filename, int flags, int mode, bool pipe)
+Process::alloc_fd(int sim_fd, const string& filename, int flags, int mode,
+                  bool pipe)
 {
     // in case open() returns an error, don't allocate a new fd
     if (sim_fd == -1)
@@ -384,7 +385,7 @@ Process::fix_file_offsets()
 
     if (in == "stdin" || in == "cin")
         stdin_fd = STDIN_FILENO;
-    else if (in == "None")
+    else if (in == "NULL")
         stdin_fd = -1;
     else {
         // open standard in and seek to the right location
@@ -397,7 +398,7 @@ Process::fix_file_offsets()
         stdout_fd = STDOUT_FILENO;
     else if (out == "stderr" || out == "cerr")
         stdout_fd = STDERR_FILENO;
-    else if (out == "None")
+    else if (out == "NULL")
         stdout_fd = -1;
     else {
         stdout_fd = Process::openOutputFile(out);
@@ -409,7 +410,7 @@ Process::fix_file_offsets()
         stderr_fd = STDOUT_FILENO;
     else if (err == "stderr" || err == "cerr")
         stderr_fd = STDERR_FILENO;
-    else if (err == "None")
+    else if (err == "NULL")
         stderr_fd = -1;
     else if (err == out)
         stderr_fd = stdout_fd;
@@ -456,7 +457,7 @@ Process::fix_file_offsets()
                 fdo->fd = fd;
 
                 //Seek to correct location before checkpoint
-                if (lseek(fd,fdo->fileOffset, SEEK_SET) < 0)
+                if (lseek(fd, fdo->fileOffset, SEEK_SET) < 0)
                     panic("Unable to seek to correct location in file: %s",
                           fdo->filename);
             }
@@ -472,8 +473,8 @@ Process::find_file_offsets()
         if (fdo->fd != -1) {
             fdo->fileOffset = lseek(fdo->fd, 0, SEEK_CUR);
         } else {
-                fdo->filename = "NULL";
-                fdo->fileOffset = 0;
+            fdo->filename = "NULL";
+            fdo->fileOffset = 0;
         }
     }
 }
index 85ac8a1d5c29c89a9f8a05368d2f201e1da6ef97..04ce00f675a216582a3a6734ed488b9a79b4ccba 100644 (file)
@@ -189,7 +189,7 @@ class Process : public SimObject
     void dup_fd(int sim_fd, int tgt_fd);
 
     // generate new target fd for sim_fd
-    int alloc_fd(int sim_fd, std::string filename, int flags, int mode,
+    int alloc_fd(int sim_fd, const std::string& filename, int flags, int mode,
                  bool pipe);
 
     // free target fd (e.g., after close)