Skip to content

Commit

Permalink
tidy: Put braces around the bodies of if/for/do/while statements.
Browse files Browse the repository at this point in the history
The clang-tidy "braces around statements" checker pointed many places
where adding braces around the body of an if/then/else statement or a
for/do/while loop would make the code easier to read.  Almost all
changes made by the clang-tidy program.  White space cleanup by hand.

https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
  • Loading branch information
linuxdude42 committed Dec 25, 2019
1 parent e38b188 commit 82d775d
Show file tree
Hide file tree
Showing 228 changed files with 1,803 additions and 163 deletions.
12 changes: 12 additions & 0 deletions mythplugins/mytharchive/mytharchive/archiveutil.cpp
Expand Up @@ -73,9 +73,11 @@ QString getTempDirectory(bool showError)
QString tempDir = gCoreContext->GetSetting("MythArchiveTempDir", "");

if (tempDir == "" && showError)
{
ShowOkPopup(QCoreApplication::translate("(ArchiveUtils)",
"Cannot find the MythArchive work directory.\n"
"Have you set the correct path in the settings?"));
}

if (tempDir == "")
return "";
Expand Down Expand Up @@ -112,28 +114,34 @@ void checkTempDirectory()
{
dir.mkdir(workDir);
if( chmod(qPrintable(workDir), 0777) != 0 )
{
LOG(VB_GENERAL, LOG_ERR,
"Failed to change permissions on archive work directory: " +
ENO);
}
}

dir = QDir(logDir);
if (!dir.exists())
{
dir.mkdir(logDir);
if( chmod(qPrintable(logDir), 0777) != 0 )
{
LOG(VB_GENERAL, LOG_ERR,
"Failed to change permissions on archive log directory: " +
ENO);
}
}
dir = QDir(configDir);
if (!dir.exists())
{
dir.mkdir(configDir);
if( chmod(qPrintable(configDir), 0777) != 0 )
{
LOG(VB_GENERAL, LOG_ERR,
"Failed to change permissions on archive config directory: " +
ENO);
}
}
}

Expand Down Expand Up @@ -304,10 +312,14 @@ void recalcItemSize(ArchiveItem *item)
if (profile->name == "NONE")
{
if (item->hasCutlist && item->useCutlist)
{
item->newsize = (int64_t) (item->size /
((float)item->duration / (float)item->cutDuration));
}
else
{
item->newsize = item->size;
}
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions mythplugins/mytharchive/mytharchive/main.cpp
Expand Up @@ -95,9 +95,11 @@ static bool checkLockFile(const QString &lockFile)
"Found a lock file but the owning process isn't running!\n"
"Removing stale lock file."));
if (!file.remove())
{
LOG(VB_GENERAL, LOG_ERR,
QString("Failed to remove stale lock file - %1")
.arg(lockFile));
}
}
else
{
Expand Down
4 changes: 4 additions & 0 deletions mythplugins/mytharchive/mytharchive/mythburn.cpp
Expand Up @@ -779,11 +779,15 @@ void MythBurn::ShowMenu()
if (curItem->hasCutlist)
{
if (curItem->useCutlist)
{
menuPopup->AddButton(tr("Don't Use Cut List"),
SLOT(toggleUseCutlist()));
}
else
{
menuPopup->AddButton(tr("Use Cut List"),
SLOT(toggleUseCutlist()));
}
}

menuPopup->AddButton(tr("Remove Item"), SLOT(removeItem()));
Expand Down
2 changes: 2 additions & 0 deletions mythplugins/mytharchive/mytharchive/videoselector.cpp
Expand Up @@ -231,9 +231,11 @@ void VideoSelector::titleChanged(MythUIButtonListItem *item)
v->size = (uint64_t)fileinfo.st_size;

if (!bExists)
{
LOG(VB_GENERAL, LOG_ERR,
QString("VideoSelector: Cannot find file: %1")
.arg(v->filename));
}
}

m_filesizeText->SetText(formatSize(v->size / 1024));
Expand Down
6 changes: 6 additions & 0 deletions mythplugins/mytharchive/mytharchivehelper/main.cpp
Expand Up @@ -204,10 +204,14 @@ static int burnISOImage(int mediaType, bool bEraseDVDRW, bool nativeFormat)

uint res = myth_system(command);
if (res != GENERIC_EXIT_OK)
{
LOG(VB_JOBQUEUE, LOG_ERR,
QString("Failed while running growisofs. Result: %1") .arg(res));
}
else
{
LOG(VB_JOBQUEUE, LOG_INFO, "Finished burning ISO image");
}

return res;
}
Expand Down Expand Up @@ -1229,8 +1233,10 @@ int NativeArchive::importVideo(const QDomElement &itemNode, const QString &xmlFi
query.bindValue(":CATEGORY", 0);

if (query.exec())
{
LOG(VB_JOBQUEUE, LOG_INFO,
"Inserted videometadata details into database");
}
else
{
MythDB::DBError("videometadata insert", query);
Expand Down
10 changes: 10 additions & 0 deletions mythplugins/mythbrowser/mythbrowser/bookmarkmanager.cpp
Expand Up @@ -107,21 +107,31 @@ void BrowserConfig::slotFocusChanged(void)

QString msg = "";
if (GetFocusWidget() == m_commandEdit)
{
msg = tr("This is the command that will be used to show the web browser. "
"Use 'Internal' to use the built in web browser'. "
"%ZOOM% and %URL% will be replaced with the zoom level and URL list.");
}
else if (GetFocusWidget() == m_zoomEdit)
{
msg = tr("This is the default text size that will be used. Valid values "
"for the Internal browser are from 0.3 to 5.0 with 1.0 being "
"normal size less than 1 is smaller and greater than 1 is "
"larger than normal size.");
}
else if (GetFocusWidget() == m_enablePluginsCheck)
{
msg = tr("If checked this will enable browser plugins if the 'Internal' "
"browser is being used.");
}
else if (GetFocusWidget() == m_cancelButton)
{
msg = tr("Exit without saving settings");
}
else if (GetFocusWidget() == m_okButton)
{
msg = tr("Save settings and Exit");
}

m_descriptionText->SetText(msg);
}
Expand Down
2 changes: 2 additions & 0 deletions mythplugins/mythgame/mythgame/dbcheck.cpp
Expand Up @@ -196,9 +196,11 @@ bool UpgradeGameDatabaseSchema(void)
{

if (!gCoreContext->GetSetting("GameAllTreeLevels").isEmpty())
{
if (!query.exec("UPDATE settings SET data = 'system gamename' "
"WHERE value = 'GameAllTreeLevels'; "))
MythDB::DBError("update GameAllTreeLevels", query);
}

QString updates[] = {
"ALTER TABLE gamemetadata ADD COLUMN country varchar(128) NOT NULL default ''; ",
Expand Down
4 changes: 4 additions & 0 deletions mythplugins/mythgame/mythgame/gamehandler.cpp
Expand Up @@ -126,11 +126,15 @@ void GameHandler::InitMetaDataMap(const QString& GameType)
}

if (m_romDB.count() == 0)
{
LOG(VB_GENERAL, LOG_ERR, LOC + QString("No romDB data read from "
"database for gametype %1 . Not imported?").arg(GameType));
}
else
{
LOG(VB_GENERAL, LOG_INFO, LOC +
QString("Loaded %1 items from romDB Database") .arg(m_romDB.count()));
}
}

void GameHandler::GetMetadata(GameHandler *handler, const QString& rom, QString* Genre, QString* Year,
Expand Down
19 changes: 12 additions & 7 deletions mythplugins/mythgame/mythgame/gamesettings.cpp
Expand Up @@ -381,15 +381,18 @@ void GamePlayersList::Load()
{
MythDB::DBError("GamePlayersSetting::Load", query);
}
else while (query.next())
else
{
int id = query.value(0).toInt();
QString name = query.value(1).toString();
QString type = query.value(2).toString();
while (query.next())
{
int id = query.value(0).toInt();
QString name = query.value(1).toString();
QString type = query.value(2).toString();

auto child = new GamePlayerSetting(name, id);
addChild(child);
child->setLabel(playerDisp.arg(name, GetGameTypeName(type)));
auto child = new GamePlayerSetting(name, id);
addChild(child);
child->setLabel(playerDisp.arg(name, GetGameTypeName(type)));
}
}

GroupSetting::Load();
Expand Down Expand Up @@ -417,12 +420,14 @@ void GamePlayersList::CreateNewPlayer(const QString& name)

// Database name must be unique
for (StandardSetting* child : *getSubSettings())
{
if (child->getName() == name)
{
LOG(VB_GENERAL, LOG_ERR,
QString("Player name %1 is already used").arg(name));
return;
}
}

addChild(new GamePlayerSetting(name));

Expand Down
2 changes: 2 additions & 0 deletions mythplugins/mythmusic/mythmusic/avfdecoder.cpp
Expand Up @@ -118,9 +118,11 @@ void ShoutCastMetaParser::setMetaFormat(const QString &metaformat)
assign_index++;
}
else
{
LOG(VB_GENERAL, LOG_ERR,
QString("ShoutCastMetaParser: malformed metaformat '%1'")
.arg(m_metaFormat));
}

pos = m_metaFormat.indexOf("%", pos);
}
Expand Down
4 changes: 4 additions & 0 deletions mythplugins/mythmusic/mythmusic/cdrip.cpp
Expand Up @@ -427,10 +427,14 @@ int CDRipperThread::ripTrack(QString &cddevice, Encoder *encoder, int tracknum)

cdrom_paranoia *paranoia = paranoia_init(device);
if (gCoreContext->GetSetting("ParanoiaLevel") == "full")
{
paranoia_modeset(paranoia, PARANOIA_MODE_FULL |
PARANOIA_MODE_NEVERSKIP);
}
else
{
paranoia_modeset(paranoia, PARANOIA_MODE_OVERLAP);
}

paranoia_seek(paranoia, start, SEEK_SET);

Expand Down
2 changes: 2 additions & 0 deletions mythplugins/mythmusic/mythmusic/generalsettings.cpp
Expand Up @@ -81,10 +81,12 @@ bool GeneralSettings::Create()
"accordingly. Features such as ID3 playcounts "
"and ratings depend on this being enabled."));
if (m_resetDBButton)
{
m_resetDBButton->SetHelpText(tr("This will clear all the MythMusic database tables allowing "
"for a fresh start. NOTE: You may lose any manual or automatic changes made to "
"a tracks metadata like rating or playcount unless you told MythMusic to "
"write those to the tag."));
}
m_cancelButton->SetHelpText(tr("Exit without saving settings"));
m_saveButton->SetHelpText(tr("Save settings and Exit"));

Expand Down
2 changes: 2 additions & 0 deletions mythplugins/mythmusic/mythmusic/importmusic.cpp
Expand Up @@ -1084,11 +1084,13 @@ void ImportCoverArtDialog::updateStatus()
if (!m_filelist.empty())
{
if (m_currentText)
{
//: %1 is the current position of the file being copied,
//: %2 is the total number of files
m_currentText->SetText(tr("%1 of %2", "Current file copied")
.arg(m_currentFile + 1)
.arg(m_filelist.size()));
}
m_filenameText->SetText(m_filelist[m_currentFile]);
m_coverartImage->SetFilename(m_filelist[m_currentFile]);
m_coverartImage->Load();
Expand Down
7 changes: 5 additions & 2 deletions mythplugins/mythmusic/mythmusic/musiccommon.cpp
Expand Up @@ -2173,11 +2173,14 @@ QString MusicCommon::getTimeString(int exTime, int maxTime)
else
{
if (maxh > 0)
{
time_string.sprintf("%d:%02d:%02d / %02d:%02d:%02d", eh, em,
es, maxh, maxm, maxs);
}
else
time_string.sprintf("%02d:%02d / %02d:%02d", em, es, maxm,
maxs);
{
time_string.sprintf("%02d:%02d / %02d:%02d", em, es, maxm, maxs);
}
}

return time_string;
Expand Down
12 changes: 12 additions & 0 deletions mythplugins/mythmusic/mythmusic/musicplayer.cpp
Expand Up @@ -644,9 +644,11 @@ void MusicPlayer::customEvent(QEvent *event)
playFile(mdata);
}
else
{
LOG(VB_GENERAL, LOG_ERR,
QString("MusicPlayer: got invalid MUSIC_COMMAND "
"PLAY_FILE - %1").arg(me->Message()));
}
}
else if (list[2] == "PLAY_URL")
{
Expand All @@ -658,9 +660,11 @@ void MusicPlayer::customEvent(QEvent *event)
playFile(mdata);
}
else
{
LOG(VB_GENERAL, LOG_ERR,
QString("MusicPlayer: got invalid MUSIC_COMMAND "
"PLAY_URL - %1").arg(me->Message()));
}
}
else if (list[2] == "PLAY_TRACK")
{
Expand All @@ -672,9 +676,11 @@ void MusicPlayer::customEvent(QEvent *event)
playFile(*mdata);
}
else
{
LOG(VB_GENERAL, LOG_ERR,
QString("MusicPlayer: got invalid MUSIC_COMMAND "
"PLAY_TRACK - %1").arg(me->Message()));
}
}
else if (list[2] == "GET_METADATA")
{
Expand Down Expand Up @@ -706,9 +712,11 @@ void MusicPlayer::customEvent(QEvent *event)
}
}
else
{
LOG(VB_GENERAL, LOG_ERR,
QString("MusicPlayer: got unknown/invalid MUSIC_COMMAND "
"- %1").arg(me->Message()));
}
}
else if (me->Message().startsWith("MUSIC_SETTINGS_CHANGED"))
{
Expand Down Expand Up @@ -778,14 +786,18 @@ void MusicPlayer::customEvent(QEvent *event)
int id = getNotificationID(host);

if (error == "Already_Running")
{
sendNotification(id, tr(""),
tr("Music File Scanner"),
tr("Can't run the music file scanner because it is already running on %1").arg(host));
}
else if (error == "Stalled")
{
sendNotification(id, tr(""),
tr("Music File Scanner"),
tr("The music file scanner has been running for more than 60 minutes on %1.\nResetting and trying again")
.arg(host));
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions mythplugins/mythmusic/mythmusic/playlist.cpp
Expand Up @@ -967,8 +967,10 @@ void Playlist::fillSonglistFromSmartPlaylist(const QString& category, const QStr
QString value1 = query.value(2).toString();
QString value2 = query.value(3).toString();
if (!bFirst)
{
whereClause += matchType + getCriteriaSQL(fieldName,
operatorName, value1, value2);
}
else
{
bFirst = false;
Expand Down
2 changes: 2 additions & 0 deletions mythplugins/mythmusic/mythmusic/playlisteditorview.cpp
Expand Up @@ -1508,8 +1508,10 @@ void PlaylistEditorView::getSmartPlaylistTracks(MusicGenericTree *node, int play
QString value1 = query.value(2).toString();
QString value2 = query.value(3).toString();
if (!bFirst)
{
whereClause += matchType + getCriteriaSQL(fieldName,
operatorName, value1, value2);
}
else
{
bFirst = false;
Expand Down

0 comments on commit 82d775d

Please sign in to comment.