2cf05b
From 94a416e1b67c72c69c19944937acc619503484b3 Mon Sep 17 00:00:00 2001
2cf05b
Message-Id: <94a416e1b67c72c69c19944937acc619503484b3@dist-git>
2cf05b
From: Boris Fiuczynski <fiuczy@linux.ibm.com>
2cf05b
Date: Fri, 13 May 2022 12:31:03 +0200
2cf05b
Subject: [PATCH] util: make reuse of ccw device address format constant
2cf05b
2cf05b
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2cf05b
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2cf05b
(cherry picked from commit b41163005c0874b1d4809523227cd1921f4852d2)
2cf05b
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2165011
2cf05b
Signed-off-by: Thomas Huth <thuth@redhat.com>
2cf05b
---
2cf05b
 src/conf/device_conf.h  | 1 -
2cf05b
 src/qemu/qemu_command.c | 2 +-
2cf05b
 src/util/virccw.c       | 2 +-
2cf05b
 src/util/virccw.h       | 2 ++
2cf05b
 4 files changed, 4 insertions(+), 3 deletions(-)
2cf05b
2cf05b
diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
2cf05b
index 60d90bbf19..950d333e2e 100644
2cf05b
--- a/src/conf/device_conf.h
2cf05b
+++ b/src/conf/device_conf.h
2cf05b
@@ -202,7 +202,6 @@ int virDomainDeviceCCWAddressParseXML(xmlNodePtr node,
2cf05b
                                       virCCWDeviceAddress *addr);
2cf05b
 bool virDomainDeviceCCWAddressEqual(virCCWDeviceAddress *addr1,
2cf05b
                                     virCCWDeviceAddress *addr2);
2cf05b
-#define VIR_CCW_DEVICE_ADDRESS_FMT "%x.%x.%04x"
2cf05b
 
2cf05b
 int virDomainDeviceDriveAddressParseXML(xmlNodePtr node,
2cf05b
                                         virDomainDeviceDriveAddress *addr);
2cf05b
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
2cf05b
index d23af97e0c..a7855d3370 100644
2cf05b
--- a/src/qemu/qemu_command.c
2cf05b
+++ b/src/qemu/qemu_command.c
2cf05b
@@ -613,7 +613,7 @@ qemuBuildDeviceAddressProps(virJSONValue *props,
2cf05b
         return 0;
2cf05b
 
2cf05b
     case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW: {
2cf05b
-        g_autofree char *devno = g_strdup_printf("%x.%x.%04x",
2cf05b
+        g_autofree char *devno = g_strdup_printf(VIR_CCW_DEVICE_ADDRESS_FMT,
2cf05b
                                                  info->addr.ccw.cssid,
2cf05b
                                                  info->addr.ccw.ssid,
2cf05b
                                                  info->addr.ccw.devno);
2cf05b
diff --git a/src/util/virccw.c b/src/util/virccw.c
2cf05b
index 409287b380..5a19d3a112 100644
2cf05b
--- a/src/util/virccw.c
2cf05b
+++ b/src/util/virccw.c
2cf05b
@@ -25,5 +25,5 @@
2cf05b
 char*
2cf05b
 virCCWDeviceAddressAsString(virCCWDeviceAddress *addr)
2cf05b
 {
2cf05b
-    return g_strdup_printf("%x.%x.%04x", addr->cssid, addr->ssid, addr->devno);
2cf05b
+    return g_strdup_printf(VIR_CCW_DEVICE_ADDRESS_FMT, addr->cssid, addr->ssid, addr->devno);
2cf05b
 }
2cf05b
diff --git a/src/util/virccw.h b/src/util/virccw.h
2cf05b
index 21a03406fa..127359c299 100644
2cf05b
--- a/src/util/virccw.h
2cf05b
+++ b/src/util/virccw.h
2cf05b
@@ -22,6 +22,8 @@
2cf05b
 
2cf05b
 #include "internal.h"
2cf05b
 
2cf05b
+#define VIR_CCW_DEVICE_ADDRESS_FMT "%x.%x.%04x"
2cf05b
+
2cf05b
 typedef struct _virCCWDeviceAddress virCCWDeviceAddress;
2cf05b
 struct _virCCWDeviceAddress {
2cf05b
     unsigned int cssid;
2cf05b
-- 
2cf05b
2.39.1
2cf05b