Commit 5b8e1019 authored by Harald Sitter's avatar Harald Sitter 🏳️‍🌈
Browse files

mtp: use fewer default switch cases

they hide unhandled enum values when we want and need to know that they
are missing! also the return explicitness was sometimes lost in the process
(when emitting finished or error we must return as otherwise assertions inside
the base class may fail)
parent 983069a0
......@@ -227,22 +227,21 @@ void MTPSlave::listDir(const QUrl &url)
switch (result) {
case 0:
break;
for (const KMTPFile &file : files) {
listEntry(getEntry(file));
}
qCDebug(LOG_KIO_MTP) << "[SUCCESS] :: Files:" << files.count();
finished();
return;
case 2:
error(ERR_IS_FILE, url.path());
return;
default:
// path not found
error(ERR_CANNOT_ENTER_DIRECTORY, url.path());
return;
}
for (const KMTPFile &file : files) {
listEntry(getEntry(file));
}
finished();
qCDebug(LOG_KIO_MTP) << "[SUCCESS] :: Files:" << files.count();
// path not found
error(ERR_CANNOT_ENTER_DIRECTORY, url.path());
return;
} else {
// storage not found
error(ERR_CANNOT_ENTER_DIRECTORY, url.path());
......@@ -493,17 +492,15 @@ void MTPSlave::put(const QUrl &url, int, JobFlags flags)
switch (result) {
case 0:
break;
qCDebug(LOG_KIO_MTP) << "data sent";
finished();
return;
case 2:
error(ERR_IS_FILE, urlDirectory(url));
return;
default:
error(KIO::ERR_CANNOT_WRITE, urlFileName(url));
return;
}
qCDebug(LOG_KIO_MTP) << "data sent";
finished();
error(KIO::ERR_CANNOT_WRITE, urlFileName(url));
return;
}
}
......
......@@ -149,7 +149,6 @@ static QString getMimetype(LIBMTP_filetype_t filetype)
switch (filetype) {
case LIBMTP_FILETYPE_FOLDER:
return QStringLiteral("inode/directory");
case LIBMTP_FILETYPE_WAV:
return QStringLiteral("audio/wav");
case LIBMTP_FILETYPE_MP3:
......@@ -233,9 +232,9 @@ static QString getMimetype(LIBMTP_filetype_t filetype)
case LIBMTP_FILETYPE_JPX:
return QStringLiteral("application/x-jbuilder-project");
case LIBMTP_FILETYPE_UNKNOWN:
default:
return QString();
return {};
}
return {};
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment