ppc: use DIV_ROUND_UP
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Thu, 22 Jun 2017 11:04:16 +0000 (13:04 +0200)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Thu, 31 Aug 2017 10:29:07 +0000 (12:29 +0200)
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>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Richard Henderson <rth@twiddle.net>
target/ppc/mem_helper.c
target/ppc/translate.c

index e6383c6bfa83ed2e1c1a3a13ea8c6e8a945ef98a..a34e604db309a7bff8e4000a58d0f3c108bab143 100644 (file)
@@ -111,7 +111,7 @@ void helper_lswx(CPUPPCState *env, target_ulong addr, uint32_t reg,
                  uint32_t ra, uint32_t rb)
 {
     if (likely(xer_bc != 0)) {
-        int num_used_regs = (xer_bc + 3) / 4;
+        int num_used_regs = DIV_ROUND_UP(xer_bc, 4);
         if (unlikely((ra != 0 && lsw_reg_in_range(reg, num_used_regs, ra)) ||
                      lsw_reg_in_range(reg, num_used_regs, rb))) {
             raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM,
index 01233e8b6d07cb564dbc89d83e16d61917e9845f..606b605ba0a4620b4ee4652a3ca53172e7bfcda3 100644 (file)
@@ -2880,7 +2880,7 @@ static void gen_lswi(DisasContext *ctx)
     }
     if (nb == 0)
         nb = 32;
-    nr = (nb + 3) / 4;
+    nr = DIV_ROUND_UP(nb, 4);
     if (unlikely(lsw_reg_in_range(start, nr, ra))) {
         gen_inval_exception(ctx, POWERPC_EXCP_INVAL_LSWX);
         return;