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