You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.9 KiB

From 5ef67fc5ef6fc0dc0b48ff07ba48093881561d9c Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <slyich@gmail.com>
Date: Mon, 6 Dec 2021 08:04:49 +0000
Subject: [PATCH 2/2] src/pamix_ui.cpp: fix %d/%zu printf() confusion
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
`ncuses-6.3` added printf-style function attributes and now makes
it easier to catch cases when user input is used in palce of format
string. Current PAmix warns as:
PAmix/src/pamix_ui.cpp: In member function 'void pamix_ui::drawHeader() const':
PAmix/src/pamix_ui.cpp:187:22: warning: format '%d' expects argument of type 'int', but argument 5 has type 'std::map<unsigned int, std::unique_ptr<Entry> >::size_type' {aka 'long unsigned int'} [-Wformat=]
187 | mvprintw(0, 1, "%d/%d", m_Entries->empty() ? 0 : m_SelectedEntry + 1, m_Entries->size());
| ~^ ~~~~~~~~~~~~~~~~~
| | |
| int std::map<unsigned int, std::unique_ptr<Entry> >::size_type {aka long unsigned int}
| %ld
Let's match both numbers to use %d.
Signed-off-by: Petr Šabata <contyk@redhat.com>
---
src/pamix_ui.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/pamix_ui.cpp b/src/pamix_ui.cpp
index 423d2ba..ff5bc61 100644
--- a/src/pamix_ui.cpp
+++ b/src/pamix_ui.cpp
@@ -184,7 +184,7 @@ void pamix_ui::redrawVolumeBars() {
}
void pamix_ui::drawHeader() const {
- mvprintw(0, 1, "%d/%d", m_Entries->empty() ? 0 : m_SelectedEntry + 1, m_Entries->size());
+ mvprintw(0, 1, "%d/%d", m_Entries->empty() ? 0 : m_SelectedEntry + 1, (unsigned)m_Entries->size());
mvprintw(0, 10, "%s", entryTypeNames[m_EntriesType]);
}
--
2.38.1