From patchwork Fri Sep 14 02:29:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 1455081 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id C504BDF24C for ; Fri, 14 Sep 2012 02:29:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754684Ab2INC3F (ORCPT ); Thu, 13 Sep 2012 22:29:05 -0400 Received: from mail-qa0-f46.google.com ([209.85.216.46]:54824 "EHLO mail-qa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754657Ab2INC3D (ORCPT ); Thu, 13 Sep 2012 22:29:03 -0400 Received: by qaas11 with SMTP id s11so3656988qaa.19 for ; Thu, 13 Sep 2012 19:29:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=Vbuzslih37FOFST9W4tG2NKMwNucYK2rhu71mODnclc=; b=fqRo81DTwHRLvvdq/8iiTuiXsMH8Kq6q+DEg7nzooPF+wzGJ5VzTgdYp0b8DyOLWvZ rKJ3fmnO7Gkr0JQ1EPvdM8UpeF69k0z+J3EiMtAjA6e33+OwRtyTleg68Hcs96+onIyD pD8U+qu8Ccu+1nZCe1u2A51T8Jpm6XaZbtP1YgDWsLN5sz8QQZDKEQmUYchFfK26jZSB VqNOKfklIC2Jk6s6UepiHeRDvF7/eqrYuFmJWORF8IAl6U/Rv+MnlPq3dyXPfckqueo6 xZersgDRa/ZgropeBy87orTbNTvs4s82DDW7SDiS9CRdzah6oCLTLDvyxOEFR8MShiND ksAg== MIME-Version: 1.0 Received: by 10.224.196.132 with SMTP id eg4mr3683740qab.93.1347589742356; Thu, 13 Sep 2012 19:29:02 -0700 (PDT) Received: by 10.229.146.194 with HTTP; Thu, 13 Sep 2012 19:29:02 -0700 (PDT) Date: Fri, 14 Sep 2012 10:29:02 +0800 Message-ID: Subject: [PATCH] Btrfs: using for_each_set_bit_from to simplify the code From: Wei Yongjun To: chris.mason@fusionio.com Cc: yongjun_wei@trendmicro.com.cn, linux-btrfs@vger.kernel.org Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Wei Yongjun Using for_each_set_bit_from() to simplify the code. spatch with a semantic match is used to found this. (http://coccinelle.lip6.fr/) Signed-off-by: Wei Yongjun Reviewed-by: David Sterba --- fs/btrfs/free-space-cache.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 6b10acf..b107e68 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -1454,9 +1454,7 @@ static int search_bitmap(struct btrfs_free_space_ctl *ctl, max_t(u64, *offset, bitmap_info->offset)); bits = bytes_to_bits(*bytes, ctl->unit); - for (i = find_next_bit(bitmap_info->bitmap, BITS_PER_BITMAP, i); - i < BITS_PER_BITMAP; - i = find_next_bit(bitmap_info->bitmap, BITS_PER_BITMAP, i + 1)) { + for_each_set_bit_from(i, bitmap_info->bitmap, BITS_PER_BITMAP) { next_zero = find_next_zero_bit(bitmap_info->bitmap, BITS_PER_BITMAP, i); if ((next_zero - i) >= bits) { @@ -2307,9 +2305,7 @@ static int btrfs_bitmap_cluster(struct btrfs_block_group_cache *block_group, again: found_bits = 0; - for (i = find_next_bit(entry->bitmap, BITS_PER_BITMAP, i); - i < BITS_PER_BITMAP; - i = find_next_bit(entry->bitmap, BITS_PER_BITMAP, i + 1)) { + for_each_set_bit_from(i, entry->bitmap, BITS_PER_BITMAP) { next_zero = find_next_zero_bit(entry->bitmap, BITS_PER_BITMAP, i); if (next_zero - i >= min_bits) {