[PATCH 0/3] ch: Couple of format directive fixes

*** BLURB HERE *** Michal Prívozník (3): ch: Use uint for @maxvcpus in virCHDomainRefreshThreadInfo() ch: Use int for @niothreads in virCHMonitorGetIOThreads() ch: Use proper format directive for @i in virCHProcessSetupIOThreads() src/ch/ch_domain.c | 4 ++-- src/ch/ch_monitor.c | 4 ++-- src/ch/ch_process.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) -- 2.41.0

The @maxvcpus variable inside of virCHDomainRefreshThreadInfo() holds retval of virDomainDefGetVcpusMax() which returns an unsigned int. Also, the variable is then passed to VIR_WARN() with incorrect format directive (%ld). Switch variable to uint and fix the format directive. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/ch/ch_domain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ch/ch_domain.c b/src/ch/ch_domain.c index 35e3471cba..d6b64b6c59 100644 --- a/src/ch/ch_domain.c +++ b/src/ch/ch_domain.c @@ -225,7 +225,7 @@ chValidateDomainDeviceDef(const virDomainDeviceDef *dev, int virCHDomainRefreshThreadInfo(virDomainObj *vm) { - size_t maxvcpus = virDomainDefGetVcpusMax(vm->def); + unsigned int maxvcpus = virDomainDefGetVcpusMax(vm->def); virCHMonitorThreadInfo *info = NULL; size_t nthreads; size_t ncpus = 0; @@ -252,7 +252,7 @@ virCHDomainRefreshThreadInfo(virDomainObj *vm) /* TODO: Remove the warning when hotplug is implemented.*/ if (ncpus != maxvcpus) - VIR_WARN("Mismatch in the number of cpus, expected: %ld, actual: %ld", + VIR_WARN("Mismatch in the number of cpus, expected: %u, actual: %zu", maxvcpus, ncpus); return 0; -- 2.41.0

The @niothreads inside of virCHMonitorGetIOThreads() is declared as of size_t type. This would work, except the variable is then passed to VIR_DEBUG with incorrect format directive (%ld) and returned. But the function returns an int not size_t. Fix the variable declaration and format directive. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/ch/ch_monitor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 4f32b1ee4c..200ad6c77b 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -937,7 +937,7 @@ virCHMonitorGetIOThreads(virCHMonitor *mon, virDomainIOThreadInfo ***iothreads) { size_t nthreads = 0; - size_t niothreads = 0; + int niothreads = 0; int thd_index; virDomainIOThreadInfo **iothreadinfolist = NULL; virDomainIOThreadInfo *iothreadinfo = NULL; @@ -969,7 +969,7 @@ virCHMonitorGetIOThreads(virCHMonitor *mon, } } - VIR_DEBUG("niothreads = %ld", niothreads); + VIR_DEBUG("niothreads = %d", niothreads); *iothreads = g_steal_pointer(&iothreadinfolist); return niothreads; -- 2.41.0

The @i variable inside of virCHProcessSetupIOThreads() is a typical loop counter - it's declared as size_t. But when passed to VIR_DEBUG an invalid format directive is used (%ld). Fix that. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/ch/ch_process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 44c5b0611e..6d3a9612bd 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -332,7 +332,7 @@ virCHProcessSetupIOThreads(virDomainObj *vm) return -1; for (i = 0; i < niothreads; i++) { - VIR_DEBUG("IOThread index = %ld , tid = %d", i, iothreads[i]->iothread_id); + VIR_DEBUG("IOThread index = %zu , tid = %d", i, iothreads[i]->iothread_id); if (virCHProcessSetupIOThread(vm, iothreads[i]) < 0) return -1; } -- 2.41.0

On a Tuesday in 2023, Michal Privoznik wrote:
*** BLURB HERE ***
Michal Prívozník (3): ch: Use uint for @maxvcpus in virCHDomainRefreshThreadInfo() ch: Use int for @niothreads in virCHMonitorGetIOThreads() ch: Use proper format directive for @i in virCHProcessSetupIOThreads()
src/ch/ch_domain.c | 4 ++-- src/ch/ch_monitor.c | 4 ++-- src/ch/ch_process.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Ján Tomko
-
Michal Privoznik