IPC: don't check for the file's existence before ftok()
It's documented to return -1 when the file doesn't exist, so we gain nothing by saying a file we ourselves must have created doesn't exist. Change-Id: I12a088d1ae424825abd3fffd171dfa1de6705787 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
950e9dad0e
commit
3653ca72b1
@ -72,19 +72,9 @@ key_t QSharedMemorySystemV::handle(QSharedMemoryPrivate *self)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ftok requires that an actual file exists somewhere
|
|
||||||
if (!QFile::exists(QFile::decodeName(nativeKeyFile))) {
|
|
||||||
self->setError(QSharedMemory::NotFound,
|
|
||||||
QSharedMemory::tr("%1: UNIX key file doesn't exist")
|
|
||||||
.arg("QSharedMemory::handle:"_L1));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
unix_key = ftok(nativeKeyFile, int(self->nativeKey.type()));
|
unix_key = ftok(nativeKeyFile, int(self->nativeKey.type()));
|
||||||
if (-1 == unix_key) {
|
if (unix_key < 0) {
|
||||||
self->setError(QSharedMemory::KeyError,
|
self->setUnixErrorString("QSharedMemory::handle"_L1);
|
||||||
QSharedMemory::tr("%1: ftok failed")
|
|
||||||
.arg("QSharedMemory::handle:"_L1));
|
|
||||||
unix_key = 0;
|
unix_key = 0;
|
||||||
}
|
}
|
||||||
return unix_key;
|
return unix_key;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user