solid: remove redundant file existence check in audio interface helper method

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-07-05 03:08:54 +03:00
parent 7f5c2abfe8
commit 2a13a7aa8c

View file

@ -309,23 +309,17 @@ QString UdevAudioInterfacePrivate::deviceName(char type)
QByteArray UdevAudioInterfacePrivate::grepHelper(const QString& path, const QByteArray& grepValue)
{
QFile file(path);
if (file.exists()) {
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QByteArray line = file.readLine();
while(!line.isNull()) {
if (line.startsWith(grepValue)) {
line.remove(0, grepValue.length());
return line.trimmed();
}
line = file.readLine();
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QByteArray line = file.readLine();
while(!line.isNull()) {
if (line.startsWith(grepValue)) {
line.remove(0, grepValue.length());
return line.trimmed();
}
} else {
qDebug() << "grepHelper: Cannot open file: " << path;
line = file.readLine();
}
} else {
qDebug() << "grepHelper: File does not exists: " << path;
qDebug() << "grepHelper: Cannot open file: " << path;
}
return QByteArray();
}