Skip to content

Commit

Permalink
Minor changes recommended by cppcheck and clang++
Browse files Browse the repository at this point in the history
  • Loading branch information
boysetsfrog committed Jul 19, 2013
1 parent fd88a86 commit f4b2939
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/buffer/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ namespace Main
class WindowBuffer
{
public:
virtual ~WindowBuffer() { }
virtual size_t Size() const = 0;
virtual std::string String(uint32_t position) const { return ""; }
virtual std::string PrintString(uint32_t position) const { return ""; }
Expand Down
8 changes: 8 additions & 0 deletions src/buffer/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,12 @@ std::string Library::String(uint32_t position) const
{
return Get(position)->album_;
}
else if (Get(position)->type_ == Mpc::SongType)
{
return Get(position)->song_->FormatString(settings_.Get(Setting::LibraryFormat));
}

return "";
}

std::string Library::PrintString(uint32_t position) const
Expand All @@ -470,6 +476,8 @@ std::string Library::PrintString(uint32_t position) const
{
return " " + Get(position)->song_->FormatString(settings_.Get(Setting::LibraryFormat));
}

return "";
}


Expand Down
4 changes: 2 additions & 2 deletions src/buffer/list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ namespace Mpc
class List
{
public:
List(std::string const name) : path_(name), name_(name) { }
List(std::string const path, std::string const name) : path_(path), name_(name) { }
List(std::string const & name) : path_(name), name_(name) { }
List(std::string const & path, std::string const & name) : path_(path), name_(name) { }

bool operator!=(Mpc::List const & rhs) const
{
Expand Down
1 change: 1 addition & 0 deletions src/callback.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace Main
class CallbackInterface
{
public:
virtual ~CallbackInterface() { }
virtual void operator() (Parameter) = 0;
};

Expand Down
6 changes: 3 additions & 3 deletions src/mode/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,9 @@ void Command::QuitAll(std::string const & arguments)

void Command::Volume(std::string const & arguments)
{
uint32_t Vol = atoi(arguments.c_str());
uint32_t Vol = (uint32_t) atoi(arguments.c_str());

if ((Vol <= 100) && (Vol >= 0))
if (Vol <= 100)
{
Player::Volume(Vol);
}
Expand Down Expand Up @@ -1096,7 +1096,7 @@ void Command::DebugClient(std::string const & arguments)

void Command::TestScreen(std::string const & arguments)
{
screen_.ActiveWindow().ScrollTo(999999);
screen_.ActiveWindow().ScrollTo(65535);
screen_.ScrollTo(screen_.ActiveWindow().Playlist(0));
screen_.ScrollTo(screen_.ActiveWindow().Current());
screen_.ActiveWindow().ScrollTo(0);
Expand Down
10 changes: 4 additions & 6 deletions src/mode/normal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ std::string Normal::InputCharToString(int input) const
std::string result = "";
bool converted = false;

if (conversionTable.size() == 0)
if (conversionTable.empty() == true)
{
conversionTable[ESCAPE_KEY] = "Esc";
conversionTable[KEY_PPAGE] = "PageUp";
Expand Down Expand Up @@ -706,7 +706,7 @@ std::string Normal::MouseInputToString() const
#ifdef HAVE_MOUSE_SUPPORT
static std::map<uint32_t, std::string> conversionTable;

if (conversionTable.size() == 0)
if (conversionTable.empty() == true)
{
conversionTable[BUTTON4_PRESSED] = "ScrollWheelUp";
conversionTable[BUTTON2_PRESSED] = "ScrollWheelDown";
Expand Down Expand Up @@ -736,9 +736,8 @@ std::string Normal::MouseInputToString() const

return "";
}
#else
return "";
#endif
return "";
}


Expand Down Expand Up @@ -1312,12 +1311,11 @@ void Normal::DisplayModeLine()

std::string Normal::ScrollString()
{
float currentScroll = 0.0;
std::ostringstream scrollStream;

if (screen_.ActiveWindow().BufferSize() > 0)
{
currentScroll = ((screen_.ActiveWindow().CurrentLine())/(static_cast<float>(screen_.ActiveWindow().BufferSize()) - 2));
float currentScroll = ((screen_.ActiveWindow().CurrentLine())/(static_cast<float>(screen_.ActiveWindow().BufferSize()) - 2));
currentScroll += .005;
scrollStream << (screen_.ActiveWindow().CurrentLine() + 1) << "/" << screen_.ActiveWindow().BufferSize() << " -- ";

Expand Down
6 changes: 3 additions & 3 deletions src/mpdclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ void Client::Connect(std::string const & hostname, uint16_t port, uint32_t timeo
uint16_t connect_port = port;
uint32_t connect_timeout = timeout_ms;
std::string connect_password = "";
size_t pos;

DeleteConnection();

Expand All @@ -155,8 +154,9 @@ void Client::Connect(std::string const & hostname, uint16_t port, uint32_t timeo
{
connect_hostname = host_env;

pos = connect_hostname.find_last_of("@");
if ( pos != connect_hostname.npos )
size_t const pos = connect_hostname.find_last_of("@");

if (pos != connect_hostname.npos)
{
connect_password = connect_hostname.substr(0, pos);
connect_hostname = connect_hostname.substr(pos + 1);
Expand Down
11 changes: 4 additions & 7 deletions src/screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,13 +580,10 @@ void Screen::Update()
}

// Paint the main window
if (MaxRows() >= 0)
{
for (uint32_t i = 0; (i < static_cast<uint32_t>(MaxRows())); ++i)
{
ActiveWindow().Print(i);
}
}
for (uint32_t i = 0; (i < static_cast<uint32_t>(MaxRows())); ++i)
{
ActiveWindow().Print(i);
}

ActiveWindow().Refresh();

Expand Down

0 comments on commit f4b2939

Please sign in to comment.