1 Return-Path: <jani@nikula.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 4C279431FDA
\r
6 for <notmuch@notmuchmail.org>; Mon, 23 Feb 2015 09:04:24 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=1.738 tagged_above=-999 required=5
\r
12 tests=[DNS_FROM_AHBL_RHSBL=2.438, RCVD_IN_DNSWL_LOW=-0.7]
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id 9j91xhTg7lQG for <notmuch@notmuchmail.org>;
\r
17 Mon, 23 Feb 2015 09:04:21 -0800 (PST)
\r
18 Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com
\r
19 [209.85.212.180]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 8C809431FDD
\r
22 for <notmuch@notmuchmail.org>; Mon, 23 Feb 2015 09:04:17 -0800 (PST)
\r
23 Received: by mail-wi0-f180.google.com with SMTP id h11so19009869wiw.1
\r
24 for <notmuch@notmuchmail.org>; Mon, 23 Feb 2015 08:55:59 -0800 (PST)
\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
26 d=1e100.net; s=20130820;
\r
27 h=x-gm-message-state:from:to:cc:subject:date:message-id;
\r
28 bh=XREvlNBuClzhjkOne68KQzxqY8qB31lP4bfHesNv4RU=;
\r
29 b=U2ApNUgnxEWi8ydqxi7WgxTEdEzMnFDQHQPEyPYsQdFmZQsNZmAVyBZw208exDhaUj
\r
30 lBuvg6nb/4aDOGuwePRSS+FCO4jK6vLvur7UmGASZ85CjwZ32Ge9xj6VZwAGOu32tG8E
\r
31 UWANO3cZZD1RmIluwz4xnsQT17bB38lRBo8cAWhFLyh09YrhEBSfn+hahcVnCJM+w+jo
\r
32 UUSVORmY1FlVkIp3kpEJydMTk35ITCxgFvzkyR/bnWmzvrD8fF07YUwYNapMHmRwOHxE
\r
33 suLTX8H9Dvfq18XQe/NHP5SLT3fDUPkdQS+ed2F6TOHEMTG1h2r46WFQ1JPMf8ZabcR/
\r
36 ALoCoQl0K8zY4RgWCYy5ijGv5qPpTejLUYQXP+3pIslMwIKQUccCsYvTdwLwp1P5DZ+iV5rd3gq+
\r
37 X-Received: by 10.181.13.174 with SMTP id ez14mr22451356wid.72.1424710559785;
\r
38 Mon, 23 Feb 2015 08:55:59 -0800 (PST)
\r
39 Received: from localhost (mobile-internet-bcee3b-76.dhcp.inet.fi.
\r
41 by mx.google.com with ESMTPSA id n3sm56356289wja.36.2015.02.23.08.55.58
\r
42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
\r
43 Mon, 23 Feb 2015 08:55:59 -0800 (PST)
\r
44 From: Jani Nikula <jani@nikula.org>
\r
45 To: notmuch@notmuchmail.org
\r
46 Subject: [PATCH 1/3] lib: abstract bit validity check in bit test/set/clear
\r
48 Date: Mon, 23 Feb 2015 18:56:14 +0200
\r
49 Message-Id: <1424710576-30468-1-git-send-email-jani@nikula.org>
\r
50 X-Mailer: git-send-email 2.1.4
\r
51 X-BeenThere: notmuch@notmuchmail.org
\r
52 X-Mailman-Version: 2.1.13
\r
54 List-Id: "Use and development of the notmuch mail system."
\r
55 <notmuch.notmuchmail.org>
\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
57 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
59 List-Post: <mailto:notmuch@notmuchmail.org>
\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
62 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
63 X-List-Received-Date: Mon, 23 Feb 2015 17:04:24 -0000
\r
65 Reduce duplication in the bit test/set/clear macros. No functional
\r
68 lib/notmuch-private.h | 11 +++++------
\r
69 1 file changed, 5 insertions(+), 6 deletions(-)
\r
71 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
\r
72 index 012ad25c42cd..02a8fc62b631 100644
\r
73 --- a/lib/notmuch-private.h
\r
74 +++ b/lib/notmuch-private.h
\r
75 @@ -64,15 +64,14 @@ NOTMUCH_BEGIN_DECLS
\r
76 strncmp ((var), (literal), sizeof (literal) - 1)
\r
78 /* Robust bit test/set/reset macros */
\r
79 +#define _NOTMUCH_VALID_BIT(bit) \
\r
80 + ((bit) >= 0 && (bit) < CHAR_BIT * sizeof (unsigned long long))
\r
81 #define NOTMUCH_TEST_BIT(val, bit) \
\r
82 - (((bit) < 0 || (bit) >= CHAR_BIT * sizeof (unsigned long long)) ? 0 \
\r
83 - : !!((val) & (1ull << (bit))))
\r
84 + (_NOTMUCH_VALID_BIT(bit) ? !!((val) & (1ull << (bit))) : 0)
\r
85 #define NOTMUCH_SET_BIT(valp, bit) \
\r
86 - (((bit) < 0 || (bit) >= CHAR_BIT * sizeof (unsigned long long)) ? *(valp) \
\r
87 - : (*(valp) |= (1ull << (bit))))
\r
88 + (_NOTMUCH_VALID_BIT(bit) ? (*(valp) |= (1ull << (bit))) : *(valp))
\r
89 #define NOTMUCH_CLEAR_BIT(valp, bit) \
\r
90 - (((bit) < 0 || (bit) >= CHAR_BIT * sizeof (unsigned long long)) ? *(valp) \
\r
91 - : (*(valp) &= ~(1ull << (bit))))
\r
92 + (_NOTMUCH_VALID_BIT(bit) ? (*(valp) &= ~(1ull << (bit))) : *(valp))
\r
94 #define unused(x) x __attribute__ ((unused))
\r