dbus-top: use mvwaddstr when no arguments are needed
Currently, some of the code uses mvwprintw to print a string without
using a format string, this causes the following errors:
error: format not a string literal and no format arguments
[-Werror=format-security]
The fix is to use mvwaddstr when no arguments are needed.
Signed-off-by: Sui Chen <suichen@google.com>
Change-Id: Ib17ad7a7795cb7bf77161f8730139f38216b7aba
(cherry picked from commit 58f2806fe8400e0f9663c4fd58955521c6f5794d)
diff --git a/main.cpp b/main.cpp
index d56b72e..5293f9b 100644
--- a/main.cpp
+++ b/main.cpp
@@ -98,12 +98,12 @@
ret++;
if (static_cast<int>(txt.size()) > width)
{
- mvwprintw(win, y, x, txt.substr(0, width).c_str());
+ mvwaddstr(win, y, x, txt.substr(0, width).c_str());
txt = txt.substr(width);
}
else
{
- mvwprintw(win, y, x, txt.c_str());
+ mvwaddstr(win, y, x, txt.c_str());
break;
}
y++;
diff --git a/menu.cpp b/menu.cpp
index af59f14..47d1f57 100644
--- a/menu.cpp
+++ b/menu.cpp
@@ -75,7 +75,7 @@
{
s.push_back(' ');
}
- mvwprintw(win_, y, x, s.c_str());
+ mvwaddstr(win_, y, x, s.c_str());
wattrset(win_, 0);
}
else
@@ -319,4 +319,4 @@
*ret = r;
}
return true;
-}
\ No newline at end of file
+}
diff --git a/views.cpp b/views.cpp
index 0e6f8b0..fdbf85d 100644
--- a/views.cpp
+++ b/views.cpp
@@ -420,7 +420,7 @@
s.push_back(' ');
}
}
- mvwprintw(win, y, x, s.c_str());
+ mvwaddstr(win, y, x, s.c_str());
wattrset(win, 0);
}
else
@@ -492,7 +492,7 @@
}
else
{
- mvwprintw(win, y, x, "Sensor details not found");
+ mvwaddstr(win, y, x, "Sensor details not found");
}
}
DrawBorderIfNeeded();
@@ -853,29 +853,29 @@
{
mvwaddch(win, y1 - 3, x, '-');
}
- mvwprintw(win, y1 - 3, arrow_x - 8, "Press [Enter] to show/hide");
- mvwprintw(win, y1 - 2, caption_x - 5,
+ mvwaddstr(win, y1 - 3, arrow_x - 8, "Press [Enter] to show/hide");
+ mvwaddstr(win, y1 - 2, caption_x - 5,
"DBus fields for aggregating and sorting results:");
if (curr_menu_state_ == LeftSide)
{
- mvwprintw(win, y1 - 1, x1 - 4, "--[ Available Fields ]--");
- mvwprintw(win, y1 - 1, x2 - 4, "--- Active Fields ---");
+ mvwaddstr(win, y1 - 1, x1 - 4, "--[ Available Fields ]--");
+ mvwaddstr(win, y1 - 1, x2 - 4, "--- Active Fields ---");
}
else
{
- mvwprintw(win, y1 - 1, x1 - 4, "--- Available Fields ---");
- mvwprintw(win, y1 - 1, x2 - 4, "--[ Active Fields ]--");
+ mvwaddstr(win, y1 - 1, x1 - 4, "--- Available Fields ---");
+ mvwaddstr(win, y1 - 1, x2 - 4, "--[ Active Fields ]--");
}
if (curr_menu_state_ == LeftSide)
{
- mvwprintw(win, arrow_y, arrow_x, "-->");
- mvwprintw(win, caption_y, caption_x,
+ mvwaddstr(win, arrow_y, arrow_x, "-->");
+ mvwaddstr(win, caption_y, caption_x,
"Press [Space] to move to the right");
}
else
{
- mvwprintw(win, arrow_y, arrow_x, "<--");
- mvwprintw(win, caption_y, caption_x,
+ mvwaddstr(win, arrow_y, arrow_x, "<--");
+ mvwaddstr(win, caption_y, caption_x,
"Press [Space] to move to the left");
}
}