[PATCH v1] hw/char/riscv_htif: Fix format specifier for uint64_t

Chao Liu posted 1 patch 1 month, 2 weeks ago
Failed in applying to current master (apply log)
There is a newer version of this series
hw/char/riscv_htif.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
[PATCH v1] hw/char/riscv_htif: Fix format specifier for uint64_t
Posted by Chao Liu 1 month, 2 weeks ago
Use PRIx64 instead of %llx for uint64_t arguments to avoid
-Werror=format warnings on platforms where uint64_t is not
long long.

This fixes the cross-riscv64-system CI failure:
  https://gitlab.com/TaoTang/qemu/-/jobs/13878406521

Fixes: d98f7a541c2c ("riscv_htif: reject invalid signature ranges (end <= begin)")
Signed-off-by: Chao Liu <chao.liu.zevorn@gmail.com>
Tested-by: Tao Tang <tangtao1634@phytium.com.cn>
---
 hw/char/riscv_htif.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/char/riscv_htif.c b/hw/char/riscv_htif.c
index 65ddea3fc8..a53d2ace02 100644
--- a/hw/char/riscv_htif.c
+++ b/hw/char/riscv_htif.c
@@ -172,8 +172,9 @@ static void htif_handle_tohost_write(HTIFState *s, uint64_t val_written)
                  */
                 if (sig_file && begin_sig_addr && end_sig_addr) {
                     if (end_sig_addr <= begin_sig_addr) {
-                        error_report("Invalid HTIF signature range: begin=0x%llx end=0x%llx",
-                                    begin_sig_addr, end_sig_addr);
+                        error_report("Invalid HTIF signature range:"
+                                     " begin=0x%" PRIx64 " end=0x%" PRIx64,
+                                     begin_sig_addr, end_sig_addr);
                         return;
                     }
                     uint64_t sig_len = end_sig_addr - begin_sig_addr;
-- 
2.53.0
Re: [PATCH v1] hw/char/riscv_htif: Fix format specifier for uint64_t
Posted by Alistair Francis 1 month, 2 weeks ago
On Sun, Apr 12, 2026 at 11:25 AM Chao Liu <chao.liu.zevorn@gmail.com> wrote:
>
> Use PRIx64 instead of %llx for uint64_t arguments to avoid
> -Werror=format warnings on platforms where uint64_t is not
> long long.
>
> This fixes the cross-riscv64-system CI failure:
>   https://gitlab.com/TaoTang/qemu/-/jobs/13878406521
>
> Fixes: d98f7a541c2c ("riscv_htif: reject invalid signature ranges (end <= begin)")
> Signed-off-by: Chao Liu <chao.liu.zevorn@gmail.com>
> Tested-by: Tao Tang <tangtao1634@phytium.com.cn>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/char/riscv_htif.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/hw/char/riscv_htif.c b/hw/char/riscv_htif.c
> index 65ddea3fc8..a53d2ace02 100644
> --- a/hw/char/riscv_htif.c
> +++ b/hw/char/riscv_htif.c
> @@ -172,8 +172,9 @@ static void htif_handle_tohost_write(HTIFState *s, uint64_t val_written)
>                   */
>                  if (sig_file && begin_sig_addr && end_sig_addr) {
>                      if (end_sig_addr <= begin_sig_addr) {
> -                        error_report("Invalid HTIF signature range: begin=0x%llx end=0x%llx",
> -                                    begin_sig_addr, end_sig_addr);
> +                        error_report("Invalid HTIF signature range:"
> +                                     " begin=0x%" PRIx64 " end=0x%" PRIx64,
> +                                     begin_sig_addr, end_sig_addr);
>                          return;
>                      }
>                      uint64_t sig_len = end_sig_addr - begin_sig_addr;
> --
> 2.53.0
>
>
Re: [PATCH v1] hw/char/riscv_htif: Fix format specifier for uint64_t
Posted by Philippe Mathieu-Daudé 1 month, 2 weeks ago
On 12/4/26 03:23, Chao Liu wrote:
> Use PRIx64 instead of %llx for uint64_t arguments to avoid
> -Werror=format warnings on platforms where uint64_t is not
> long long.
> 
> This fixes the cross-riscv64-system CI failure:
>    https://gitlab.com/TaoTang/qemu/-/jobs/13878406521

This link might last less than this commit, better to document here:

../hw/char/riscv_htif.c: In function ‘htif_handle_tohost_write’:
../hw/char/riscv_htif.c:175:38: error: format ‘%llx’ expects argument of 
type ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ {aka 
‘long unsigned int’} [-Werror=format=]
   175 |                         error_report("Invalid HTIF signature 
range: begin=0x%llx end=0x%llx",
       | 
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   176 |                                     begin_sig_addr, end_sig_addr);
       |                                     ~~~~~~~~~~~~~~
       |                                     |
       |                                     uint64_t {aka long unsigned 
int}

> 
> Fixes: d98f7a541c2c ("riscv_htif: reject invalid signature ranges (end <= begin)")
> Signed-off-by: Chao Liu <chao.liu.zevorn@gmail.com>
> Tested-by: Tao Tang <tangtao1634@phytium.com.cn>
> ---
>   hw/char/riscv_htif.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>