From f0704d78b42423f6040e224452cee4ee4aff30cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Thu, 22 Jun 2017 13:04:16 +0200 Subject: [PATCH] ppc: use DIV_ROUND_UP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Acked-by: David Gibson Reviewed-by: Richard Henderson --- target/ppc/mem_helper.c | 2 +- target/ppc/translate.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c index e6383c6bfa..a34e604db3 100644 --- a/target/ppc/mem_helper.c +++ b/target/ppc/mem_helper.c @@ -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, diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 01233e8b6d..606b605ba0 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -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;