From patchwork Sun Jun 5 07:43:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 9155179 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CB78260574 for ; Sun, 5 Jun 2016 09:05:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDE4227C0C for ; Sun, 5 Jun 2016 09:05:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0DFB272AA; Sun, 5 Jun 2016 09:05:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7BC74272AA for ; Sun, 5 Jun 2016 09:05:46 +0000 (UTC) Received: from localhost ([::1]:36135 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9U09-0007aq-Kw for patchwork-qemu-devel@patchwork.kernel.org; Sun, 05 Jun 2016 05:05:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41159) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9TwF-00047Y-OX for qemu-devel@nongnu.org; Sun, 05 Jun 2016 05:01:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b9TwD-0004oc-Rm for qemu-devel@nongnu.org; Sun, 05 Jun 2016 05:01:42 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:51831) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9Tw6-0004lF-Ui; Sun, 05 Jun 2016 05:01:35 -0400 Received: from tsrv.tls.msk.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id E465840914; Sun, 5 Jun 2016 12:01:26 +0300 (MSK) Received: from tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by tsrv.tls.msk.ru (Postfix) with SMTP id 784D4B03; Sun, 5 Jun 2016 10:43:38 +0300 (MSK) Received: (nullmailer pid 1174 invoked by uid 1000); Sun, 05 Jun 2016 07:43:32 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Date: Sun, 5 Jun 2016 10:43:18 +0300 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 86.62.121.231 Subject: [Qemu-devel] [PULL 41/52] block: Use DIV_ROUND_UP X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , qemu-trivial@nongnu.org, Michael Tokarev , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Laurent Vivier Replace (((n) + (d) - 1) /(d)) by DIV_ROUND_UP(n,d). This patch is the result of coccinelle script scripts/coccinelle/round.cocci CC: qemu-block@nongnu.org Signed-off-by: Laurent Vivier Reviewed-by: Eric Blake Signed-off-by: Michael Tokarev --- block/vvfat.c | 3 +-- hw/block/tc58128.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index a39dbe6..6d2e21c 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1960,8 +1960,7 @@ DLOG(fprintf(stderr, "check direntry %d:\n", i); print_direntry(direntries + i)) /* check file size with FAT */ cluster_count = get_cluster_count_for_direntry(s, direntries + i, path2); if (cluster_count != - (le32_to_cpu(direntries[i].size) + s->cluster_size - - 1) / s->cluster_size) { + DIV_ROUND_UP(le32_to_cpu(direntries[i].size), s->cluster_size)) { DLOG(fprintf(stderr, "Cluster count mismatch\n")); goto fail; } diff --git a/hw/block/tc58128.c b/hw/block/tc58128.c index 7909d50..1d9f7ee 100644 --- a/hw/block/tc58128.c +++ b/hw/block/tc58128.c @@ -45,7 +45,7 @@ static void init_dev(tc58128_dev * dev, const char *filename) } } else { /* Build first block with number of blocks */ - blocks = (ret + 528 * 32 - 1) / (528 * 32); + blocks = DIV_ROUND_UP(ret, 528 * 32); dev->flash_contents[0] = blocks & 0xff; dev->flash_contents[1] = (blocks >> 8) & 0xff; dev->flash_contents[2] = (blocks >> 16) & 0xff;