Skip to content

Commit

Permalink
tidy: Explicitly convert boolean to integer for some library calls.
Browse files Browse the repository at this point in the history
The clang-tidy "implicit boolean conversion" check pointed out a
couple of places where a system library is expecting a boolean value,
but the API states that the value is an integer.  These true/false
values could be converted to 1/0, but the intent seems more obvious if
the true/false values are kept and are explicitly converted to integer
values.

https://clang.llvm.org/extra/clang-tidy/checks/readability-implicit-bool-conversion.html
  • Loading branch information
linuxdude42 committed Mar 26, 2019
1 parent 20f071f commit d38cd5b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion mythplugins/mytharchive/mytharchivehelper/main.cpp
Expand Up @@ -1946,7 +1946,7 @@ static int getFileInfo(QString inFile, QString outFile, int lenMethod)

buf[0]=0;
if (avctx)
avcodec_string(buf, sizeof(buf), avctx, false);
avcodec_string(buf, sizeof(buf), avctx, static_cast<int>(false));

switch (st->codecpar->codec_type)
{
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmyth/audio/audiopulsehandler.cpp
Expand Up @@ -310,12 +310,12 @@ bool PulseHandler::SuspendInternal(bool suspend)
m_pending_operations = 2;
pa_operation *operation_sink =
pa_context_suspend_sink_by_index(
m_ctx, PA_INVALID_INDEX, suspend, OperationCallback, this);
m_ctx, PA_INVALID_INDEX, static_cast<int>(suspend), OperationCallback, this);
pa_operation_unref(operation_sink);

pa_operation *operation_source =
pa_context_suspend_source_by_index(
m_ctx, PA_INVALID_INDEX, suspend, OperationCallback, this);
m_ctx, PA_INVALID_INDEX, static_cast<int>(suspend), OperationCallback, this);
pa_operation_unref(operation_source);

// run the loop manually and wait for the callbacks
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/avformatdecoder.cpp
Expand Up @@ -954,7 +954,7 @@ bool AvFormatDecoder::CanHandle(char testbuf[kDecoderProbeBufferSize],
score--;
}

return av_probe_input_format2(&probe, true, &score) != nullptr;
return av_probe_input_format2(&probe, static_cast<int>(true), &score) != nullptr;
}

void AvFormatDecoder::InitByteContext(bool forceseek)
Expand Down Expand Up @@ -1053,7 +1053,7 @@ int AvFormatDecoder::OpenFile(RingBuffer *rbuffer, bool novideo,

LOG(VB_PLAYBACK, LOG_DEBUG, LOC + "OpenFile -- begin");

fmt = av_probe_input_format(&probe, true);
fmt = av_probe_input_format(&probe, static_cast<int>(true));
if (!fmt)
{
LOG(VB_GENERAL, LOG_ERR, LOC +
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/subtitlescreen.cpp
Expand Up @@ -2354,7 +2354,7 @@ bool SubtitleScreen::InitialiseAssLibrary(void)
return false;

ass_set_message_cb(m_assLibrary, myth_libass_log, nullptr);
ass_set_extract_fonts(m_assLibrary, true);
ass_set_extract_fonts(m_assLibrary, static_cast<int>(true));
LOG(VB_PLAYBACK, LOG_INFO, LOC + "Initialised libass object.");
}

Expand Down Expand Up @@ -2465,7 +2465,7 @@ void SubtitleScreen::ResizeAssRenderer(void)
// TODO this probably won't work properly for anamorphic content and XVideo
ass_set_frame_size(m_assRenderer, m_safeArea.width(), m_safeArea.height());
ass_set_margins(m_assRenderer, 0, 0, 0, 0);
ass_set_use_margins(m_assRenderer, true);
ass_set_use_margins(m_assRenderer, static_cast<int>(true));
ass_set_font_scale(m_assRenderer, 1.0);
}

Expand Down
2 changes: 1 addition & 1 deletion mythtv/programs/mythutil/musicmetautils.cpp
Expand Up @@ -284,7 +284,7 @@ static int CalcTrackLength(const MythUtilCommandLineParser &cmdline)
avcodec_parameters_to_context(avctx, st->codecpar);
av_codec_set_pkt_timebase(avctx, st->time_base);

avcodec_string(buf, sizeof(buf), avctx, false);
avcodec_string(buf, sizeof(buf), avctx, static_cast<int>(false));

switch (inputFC->streams[i]->codecpar->codec_type)
{
Expand Down

0 comments on commit d38cd5b

Please sign in to comment.