[PATCH 3/5] virrandom: Fix printf format string in virRandomGenerateWWN()

Michal Privoznik posted 5 patches 2 years, 6 months ago
There is a newer version of this series
[PATCH 3/5] virrandom: Fix printf format string in virRandomGenerateWWN()
Posted by Michal Privoznik 2 years, 6 months ago
Firstly, drop needless concatenation of two static strings.
Secondly, use proper (portable) formatter for uint64_t so that
typecast to ULL can be dropped.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/util/virrandom.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/util/virrandom.c b/src/util/virrandom.c
index 7606dd1684..38fcfbc6ba 100644
--- a/src/util/virrandom.c
+++ b/src/util/virrandom.c
@@ -160,8 +160,7 @@ virRandomGenerateWWN(char **wwn,
         return -1;
     }
 
-    *wwn = g_strdup_printf("5" "%s%09llx", oui,
-                           (unsigned long long)virRandomBits(36));
+    *wwn = g_strdup_printf("5%s%09" PRIx64, oui, virRandomBits(36));
     return 0;
 }
 
-- 
2.41.0
Re: [PATCH 3/5] virrandom: Fix printf format string in virRandomGenerateWWN()
Posted by Peter Krempa 2 years, 6 months ago
On Tue, Jul 18, 2023 at 17:27:36 +0200, Michal Privoznik wrote:
> Firstly, drop needless concatenation of two static strings.
> Secondly, use proper (portable) formatter for uint64_t so that
> typecast to ULL can be dropped.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/util/virrandom.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Reviewed-by: Peter Krempa <pkrempa@redhat.com>