[PATCH 0/3] fix some coding issues

Jiang Jiacheng (3): qemu:fix a misspelling in log remote: fix misspelling in the documation of 'daemonCreateClientStream' storage/util: replace unnecessary while loop by if src/qemu/qemu_process.c | 2 +- src/remote/remote_daemon_stream.c | 4 ++-- src/storage/storage_util.c | 4 +--- src/util/virutil.c | 6 +----- 4 files changed, 5 insertions(+), 11 deletions(-) -- 2.33.0

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com> --- src/qemu/qemu_process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b6adcf2f2a..04d14e7eb0 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7590,7 +7590,7 @@ qemuProcessLaunch(virConnectPtr conn, g_autofree int *nicindexes = NULL; unsigned long long maxMemLock = 0; - VIR_DEBUG("conn=%p driver=%p vm=%p name=%s if=%d asyncJob=%d " + VIR_DEBUG("conn=%p driver=%p vm=%p name=%s id=%d asyncJob=%d " "incoming.uri=%s " "incoming.fd=%d incoming.path=%s " "snapshot=%p vmop=%d flags=0x%x", -- 2.33.0

On 1/5/23 12:51, Jiang Jiacheng wrote:
Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com> --- src/qemu/qemu_process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
I'd prefer s/qemu/qemuProcessLaunch/ to make it more obvious what's happening in this patch when reading git log.
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b6adcf2f2a..04d14e7eb0 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7590,7 +7590,7 @@ qemuProcessLaunch(virConnectPtr conn, g_autofree int *nicindexes = NULL; unsigned long long maxMemLock = 0;
- VIR_DEBUG("conn=%p driver=%p vm=%p name=%s if=%d asyncJob=%d " + VIR_DEBUG("conn=%p driver=%p vm=%p name=%s id=%d asyncJob=%d " "incoming.uri=%s " "incoming.fd=%d incoming.path=%s " "snapshot=%p vmop=%d flags=0x%x",
Michal

Fix a misspelling in the documation of 'daemonCreateClientStream'. Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com> --- src/remote/remote_daemon_stream.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_stream.c index 912f3f9f94..8873af51da 100644 --- a/src/remote/remote_daemon_stream.c +++ b/src/remote/remote_daemon_stream.c @@ -337,10 +337,10 @@ daemonStreamFilter(virNetServerClient *client, /* - * @conn: a connection object to associate the stream with + * @client: a locked client object * @header: the method call to associate with the stream * - * Creates a new stream for this conn + * Creates a new stream for this client * * Returns a new stream object, or NULL upon OOM */ -- 2.33.0

These while loops exit directly due to break after entering. Use if instead of these while loops. Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com> --- src/storage/storage_util.c | 4 +--- src/util/virutil.c | 6 +----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 3871718b09..520fdd03d0 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -3784,12 +3784,10 @@ getNewStyleBlockDevice(const char *lun_path, if (virDirOpen(&block_dir, block_path) < 0) return -1; - while ((direrr = virDirRead(block_dir, &block_dirent, block_path)) > 0) { + if ((direrr = virDirRead(block_dir, &block_dirent, block_path)) > 0) { *block_device = g_strdup(block_dirent->d_name); VIR_DEBUG("Block device is '%s'", *block_device); - - break; } if (direrr < 0) diff --git a/src/util/virutil.c b/src/util/virutil.c index 7e246d22d1..ddc66001cb 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -1432,15 +1432,11 @@ virHostHasIOMMU(void) { g_autoptr(DIR) iommuDir = NULL; struct dirent *iommuGroup = NULL; - int direrr; if (virDirOpenQuiet(&iommuDir, "/sys/kernel/iommu_groups/") < 0) return false; - while ((direrr = virDirRead(iommuDir, &iommuGroup, NULL)) > 0) - break; - - if (direrr < 0 || !iommuGroup) + if (virDirRead(iommuDir, &iommuGroup, NULL) < 0 || !iommuGroup) return false; return true; -- 2.33.0

On 1/5/23 12:51, Jiang Jiacheng wrote:
Jiang Jiacheng (3): qemu:fix a misspelling in log remote: fix misspelling in the documation of 'daemonCreateClientStream' storage/util: replace unnecessary while loop by if
src/qemu/qemu_process.c | 2 +- src/remote/remote_daemon_stream.c | 4 ++-- src/storage/storage_util.c | 4 +--- src/util/virutil.c | 6 +----- 4 files changed, 5 insertions(+), 11 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> and pushed.
participants (2)
-
Jiang Jiacheng
-
Michal Prívozník