summaryrefslogtreecommitdiff
path: root/src/sim/process.cc
diff options
context:
space:
mode:
authorSteve Reinhardt <steve.reinhardt@amd.com>2015-12-09 14:47:43 -0500
committerSteve Reinhardt <steve.reinhardt@amd.com>2015-12-09 14:47:43 -0500
commit28d7e261edc3e464c99593386b891d0974db886d (patch)
treea64e8b363412070a515c3cd35f92c1e04bd86ad1 /src/sim/process.cc
parent7c4a6604b95109f44bb5777a06df4091702cf77b (diff)
downloadgem5-28d7e261edc3e464c99593386b891d0974db886d.tar.xz
syscall_emul: don't check host fd when allocating target fd
There's a well-meaning check in Process::allocFD() to return an invalid target fd (-1) if the incoming host fd is -1. However, this means that emulated drivers, which want to allocate a target fd that doesn't correspond to a host fd, can't use -1 to indicate an intentionally invalid host fd. It turns out the allocFD() check is redundant, as callers always test the host fd for validity before calling. Also, callers never test the return value of allocFD() for validity, so even if the test failed, it would likely have the undesirable result of returning -1 to the target app as a file descriptor without setting errno. Thus the check is pointless and is now getting in the way, so it seems we should just get rid of it.
Diffstat (limited to 'src/sim/process.cc')
-rw-r--r--src/sim/process.cc3
1 files changed, 0 insertions, 3 deletions
diff --git a/src/sim/process.cc b/src/sim/process.cc
index def42c0b2..cbafb62fe 100644
--- a/src/sim/process.cc
+++ b/src/sim/process.cc
@@ -242,9 +242,6 @@ int
Process::allocFD(int sim_fd, const string& filename, int flags, int mode,
bool pipe)
{
- if (sim_fd == -1)
- return -1;
-
for (int free_fd = 0; free_fd < fd_array->size(); free_fd++) {
FDEntry *fde = getFDEntry(free_fd);
if (fde->isFree()) {