diff mbox

[v2,21/29] msix: use DIV_ROUND_UP

Message ID 20170713163219.9024-22-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau July 13, 2017, 4:32 p.m. UTC
I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/pci/msix.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Philippe Mathieu-Daudé July 14, 2017, 4:24 a.m. UTC | #1
On 07/13/2017 01:32 PM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>   hw/pci/msix.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/pci/msix.c b/hw/pci/msix.c
> index 5078d3dd19..c944c02135 100644
> --- a/hw/pci/msix.c
> +++ b/hw/pci/msix.c
> @@ -438,7 +438,7 @@ void msix_save(PCIDevice *dev, QEMUFile *f)
>       }
>   
>       qemu_put_buffer(f, dev->msix_table, n * PCI_MSIX_ENTRY_SIZE);
> -    qemu_put_buffer(f, dev->msix_pba, (n + 7) / 8);
> +    qemu_put_buffer(f, dev->msix_pba, DIV_ROUND_UP(n, 8));
>   }
>   
>   /* Should be called after restoring the config space. */
> @@ -453,7 +453,7 @@ void msix_load(PCIDevice *dev, QEMUFile *f)
>   
>       msix_clear_all_vectors(dev);
>       qemu_get_buffer(f, dev->msix_table, n * PCI_MSIX_ENTRY_SIZE);
> -    qemu_get_buffer(f, dev->msix_pba, (n + 7) / 8);
> +    qemu_get_buffer(f, dev->msix_pba, DIV_ROUND_UP(n, 8));
>       msix_update_function_masked(dev);
>   
>       for (vector = 0; vector < n; vector++) {
>
Richard Henderson July 14, 2017, 8:41 a.m. UTC | #2
On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   hw/pci/msix.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~
diff mbox

Patch

diff --git a/hw/pci/msix.c b/hw/pci/msix.c
index 5078d3dd19..c944c02135 100644
--- a/hw/pci/msix.c
+++ b/hw/pci/msix.c
@@ -438,7 +438,7 @@  void msix_save(PCIDevice *dev, QEMUFile *f)
     }
 
     qemu_put_buffer(f, dev->msix_table, n * PCI_MSIX_ENTRY_SIZE);
-    qemu_put_buffer(f, dev->msix_pba, (n + 7) / 8);
+    qemu_put_buffer(f, dev->msix_pba, DIV_ROUND_UP(n, 8));
 }
 
 /* Should be called after restoring the config space. */
@@ -453,7 +453,7 @@  void msix_load(PCIDevice *dev, QEMUFile *f)
 
     msix_clear_all_vectors(dev);
     qemu_get_buffer(f, dev->msix_table, n * PCI_MSIX_ENTRY_SIZE);
-    qemu_get_buffer(f, dev->msix_pba, (n + 7) / 8);
+    qemu_get_buffer(f, dev->msix_pba, DIV_ROUND_UP(n, 8));
     msix_update_function_masked(dev);
 
     for (vector = 0; vector < n; vector++) {