changeset 8ed230a0b28c in /z/repo/gem5 details: http://repo.gem5.org/gem5?cmd=changeset;node=8ed230a0b28c description: 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: src/sim/process.cc | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diffs (13 lines): diff -r 2c263c3426fa -r 8ed230a0b28c src/sim/process.cc --- a/src/sim/process.cc Tue Dec 08 14:30:31 2015 -0600 +++ b/src/sim/process.cc Wed Dec 09 14:47:43 2015 -0500 @@ -242,9 +242,6 @@ 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()) { _______________________________________________ gem5-dev mailing list gem5-dev@gem5.org http://m5sim.org/mailman/listinfo/gem5-dev