[PATCH 1/3] lib: abstract bit validity check in bit test/set/clear macros
authorJani Nikula <jani@nikula.org>
Mon, 23 Feb 2015 16:56:14 +0000 (18:56 +0200)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 21:48:06 +0000 (14:48 -0700)
db/fc24a4d8df93216ad016ee373e72c9b90e4cfa [new file with mode: 0644]

diff --git a/db/fc24a4d8df93216ad016ee373e72c9b90e4cfa b/db/fc24a4d8df93216ad016ee373e72c9b90e4cfa
new file mode 100644 (file)
index 0000000..315cd30
--- /dev/null
@@ -0,0 +1,98 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 4C279431FDA\r
+       for <notmuch@notmuchmail.org>; Mon, 23 Feb 2015 09:04:24 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 1.738\r
+X-Spam-Level: *\r
+X-Spam-Status: No, score=1.738 tagged_above=-999 required=5\r
+       tests=[DNS_FROM_AHBL_RHSBL=2.438, RCVD_IN_DNSWL_LOW=-0.7]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 9j91xhTg7lQG for <notmuch@notmuchmail.org>;\r
+       Mon, 23 Feb 2015 09:04:21 -0800 (PST)\r
+Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com\r
+       [209.85.212.180]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 8C809431FDD\r
+       for <notmuch@notmuchmail.org>; Mon, 23 Feb 2015 09:04:17 -0800 (PST)\r
+Received: by mail-wi0-f180.google.com with SMTP id h11so19009869wiw.1\r
+       for <notmuch@notmuchmail.org>; Mon, 23 Feb 2015 08:55:59 -0800 (PST)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=1e100.net; s=20130820;\r
+       h=x-gm-message-state:from:to:cc:subject:date:message-id;\r
+       bh=XREvlNBuClzhjkOne68KQzxqY8qB31lP4bfHesNv4RU=;\r
+       b=U2ApNUgnxEWi8ydqxi7WgxTEdEzMnFDQHQPEyPYsQdFmZQsNZmAVyBZw208exDhaUj\r
+       lBuvg6nb/4aDOGuwePRSS+FCO4jK6vLvur7UmGASZ85CjwZ32Ge9xj6VZwAGOu32tG8E\r
+       UWANO3cZZD1RmIluwz4xnsQT17bB38lRBo8cAWhFLyh09YrhEBSfn+hahcVnCJM+w+jo\r
+       UUSVORmY1FlVkIp3kpEJydMTk35ITCxgFvzkyR/bnWmzvrD8fF07YUwYNapMHmRwOHxE\r
+       suLTX8H9Dvfq18XQe/NHP5SLT3fDUPkdQS+ed2F6TOHEMTG1h2r46WFQ1JPMf8ZabcR/\r
+       ljSw==\r
+X-Gm-Message-State:\r
+ ALoCoQl0K8zY4RgWCYy5ijGv5qPpTejLUYQXP+3pIslMwIKQUccCsYvTdwLwp1P5DZ+iV5rd3gq+\r
+X-Received: by 10.181.13.174 with SMTP id ez14mr22451356wid.72.1424710559785; \r
+       Mon, 23 Feb 2015 08:55:59 -0800 (PST)\r
+Received: from localhost (mobile-internet-bcee3b-76.dhcp.inet.fi.\r
+       [188.238.59.76])\r
+       by mx.google.com with ESMTPSA id n3sm56356289wja.36.2015.02.23.08.55.58\r
+       (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+       Mon, 23 Feb 2015 08:55:59 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/3] lib: abstract bit validity check in bit test/set/clear\r
+       macros\r
+Date: Mon, 23 Feb 2015 18:56:14 +0200\r
+Message-Id: <1424710576-30468-1-git-send-email-jani@nikula.org>\r
+X-Mailer: git-send-email 2.1.4\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 23 Feb 2015 17:04:24 -0000\r
+\r
+Reduce duplication in the bit test/set/clear macros. No functional\r
+changes.\r
+---\r
+ lib/notmuch-private.h | 11 +++++------\r
+ 1 file changed, 5 insertions(+), 6 deletions(-)\r
+\r
+diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
+index 012ad25c42cd..02a8fc62b631 100644\r
+--- a/lib/notmuch-private.h\r
++++ b/lib/notmuch-private.h\r
+@@ -64,15 +64,14 @@ NOTMUCH_BEGIN_DECLS\r
+     strncmp ((var), (literal), sizeof (literal) - 1)\r
\r
+ /* Robust bit test/set/reset macros */\r
++#define _NOTMUCH_VALID_BIT(bit) \\r
++    ((bit) >= 0 && (bit) < CHAR_BIT * sizeof (unsigned long long))\r
+ #define NOTMUCH_TEST_BIT(val, bit) \\r
+-    (((bit) < 0 || (bit) >= CHAR_BIT * sizeof (unsigned long long)) ? 0       \\r
+-     : !!((val) & (1ull << (bit))))\r
++    (_NOTMUCH_VALID_BIT(bit) ? !!((val) & (1ull << (bit))) : 0)\r
+ #define NOTMUCH_SET_BIT(valp, bit) \\r
+-    (((bit) < 0 || (bit) >= CHAR_BIT * sizeof (unsigned long long)) ? *(valp) \\r
+-     : (*(valp) |= (1ull << (bit))))\r
++    (_NOTMUCH_VALID_BIT(bit) ? (*(valp) |= (1ull << (bit))) : *(valp))\r
+ #define NOTMUCH_CLEAR_BIT(valp,  bit) \\r
+-    (((bit) < 0 || (bit) >= CHAR_BIT * sizeof (unsigned long long)) ? *(valp) \\r
+-     : (*(valp) &= ~(1ull << (bit))))\r
++    (_NOTMUCH_VALID_BIT(bit) ? (*(valp) &= ~(1ull << (bit))) : *(valp))\r
\r
+ #define unused(x) x __attribute__ ((unused))\r
\r
+-- \r
+2.1.4\r
+\r