* [PATCH 1/3] lib: abstract bit validity check in bit test/set/clear macros
@ 2015-02-23 16:56 Jani Nikula
2015-02-23 16:56 ` [PATCH 2/3] lib: fix clang build warnings Jani Nikula
2015-02-23 16:56 ` [PATCH 3/3] cli: " Jani Nikula
0 siblings, 2 replies; 5+ messages in thread
From: Jani Nikula @ 2015-02-23 16:56 UTC (permalink / raw)
To: notmuch
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] lib: fix clang build warnings
2015-02-23 16:56 [PATCH 1/3] lib: abstract bit validity check in bit test/set/clear macros Jani Nikula
@ 2015-02-23 16:56 ` Jani Nikula
2015-02-23 16:56 ` [PATCH 3/3] cli: " Jani Nikula
1 sibling, 0 replies; 5+ messages in thread
From: Jani Nikula @ 2015-02-23 16:56 UTC (permalink / raw)
To: notmuch
Fix the following warning produced by clang 3.5.0:
lib/message.cc:899:4: warning: comparison of constant 64 with expression of type 'notmuch_message_flag_t' (aka '_notmuch_message_flag') is always true [-Wtautological-constant-out-of-range-compare]
! NOTMUCH_TEST_BIT (message->lazy_flags, flag))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./lib/notmuch-private.h:70:6: note: expanded from macro 'NOTMUCH_TEST_BIT'
(_NOTMUCH_VALID_BIT(bit) ? !!((val) & (1ull << (bit))) : 0)
^~~~~~~~~~~~~~~~~~~~~~~
./lib/notmuch-private.h:68:26: note: expanded from macro '_NOTMUCH_VALID_BIT'
((bit) >= 0 && (bit) < CHAR_BIT * sizeof (unsigned long long))
~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
lib/notmuch-private.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index 02a8fc62b631..8a1f2fab77af 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -65,7 +65,7 @@ NOTMUCH_BEGIN_DECLS
/* Robust bit test/set/reset macros */
#define _NOTMUCH_VALID_BIT(bit) \
- ((bit) >= 0 && (bit) < CHAR_BIT * sizeof (unsigned long long))
+ ((bit) >= 0 && ((unsigned long) bit) < CHAR_BIT * sizeof (unsigned long long))
#define NOTMUCH_TEST_BIT(val, bit) \
(_NOTMUCH_VALID_BIT(bit) ? !!((val) & (1ull << (bit))) : 0)
#define NOTMUCH_SET_BIT(valp, bit) \
--
2.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] cli: fix clang build warnings
2015-02-23 16:56 [PATCH 1/3] lib: abstract bit validity check in bit test/set/clear macros Jani Nikula
2015-02-23 16:56 ` [PATCH 2/3] lib: fix clang build warnings Jani Nikula
@ 2015-02-23 16:56 ` Jani Nikula
2015-02-23 19:11 ` Tomi Ollila
1 sibling, 1 reply; 5+ messages in thread
From: Jani Nikula @ 2015-02-23 16:56 UTC (permalink / raw)
To: notmuch
Fix the following warning produced by clang 3.5.0:
notmuch-search.c:730:25: warning: initializing 'void *' with an
expression of type 'const notmuch_opt_desc_t (*)[4]' discards
qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
{ NOTMUCH_OPT_INHERIT, &common_options, NULL, 0, 0 },
^~~~~~~~~~~~~~~
1 warning generated.
---
I'm not really happy with this one. An alternative would be to drop
const from common_options, but I'm not happy with that either. And I'm
not happy with the warning. :(
---
notmuch-search.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/notmuch-search.c b/notmuch-search.c
index 14b9f01c5ad1..a591d45b4c39 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -671,7 +671,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
{ NOTMUCH_OPT_INT, &ctx->offset, "offset", 'O', 0 },
{ NOTMUCH_OPT_INT, &ctx->limit, "limit", 'L', 0 },
{ NOTMUCH_OPT_INT, &ctx->dupe, "duplicate", 'D', 0 },
- { NOTMUCH_OPT_INHERIT, &common_options, NULL, 0, 0 },
+ { NOTMUCH_OPT_INHERIT, (void *) &common_options, NULL, 0, 0 },
{ 0, 0, 0, 0, 0 }
};
@@ -727,7 +727,7 @@ notmuch_address_command (notmuch_config_t *config, int argc, char *argv[])
(notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },
{ "false", NOTMUCH_EXCLUDE_FALSE },
{ 0, 0 } } },
- { NOTMUCH_OPT_INHERIT, &common_options, NULL, 0, 0 },
+ { NOTMUCH_OPT_INHERIT, (void *) &common_options, NULL, 0, 0 },
{ 0, 0, 0, 0, 0 }
};
--
2.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 3/3] cli: fix clang build warnings
2015-02-23 16:56 ` [PATCH 3/3] cli: " Jani Nikula
@ 2015-02-23 19:11 ` Tomi Ollila
2015-02-25 22:14 ` David Bremner
0 siblings, 1 reply; 5+ messages in thread
From: Tomi Ollila @ 2015-02-23 19:11 UTC (permalink / raw)
To: Jani Nikula, notmuch
On Mon, Feb 23 2015, Jani Nikula <jani@nikula.org> wrote:
> Fix the following warning produced by clang 3.5.0:
>
> notmuch-search.c:730:25: warning: initializing 'void *' with an
> expression of type 'const notmuch_opt_desc_t (*)[4]' discards
> qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
> { NOTMUCH_OPT_INHERIT, &common_options, NULL, 0, 0 },
> ^~~~~~~~~~~~~~~
> 1 warning generated.
>
> ---
>
> I'm not really happy with this one. An alternative would be to drop
> const from common_options, but I'm not happy with that either. And I'm
> not happy with the warning. :(
This looks tolerable to be and the whole series good. tests pass.
> ---
> notmuch-search.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/notmuch-search.c b/notmuch-search.c
> index 14b9f01c5ad1..a591d45b4c39 100644
> --- a/notmuch-search.c
> +++ b/notmuch-search.c
> @@ -671,7 +671,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
> { NOTMUCH_OPT_INT, &ctx->offset, "offset", 'O', 0 },
> { NOTMUCH_OPT_INT, &ctx->limit, "limit", 'L', 0 },
> { NOTMUCH_OPT_INT, &ctx->dupe, "duplicate", 'D', 0 },
> - { NOTMUCH_OPT_INHERIT, &common_options, NULL, 0, 0 },
> + { NOTMUCH_OPT_INHERIT, (void *) &common_options, NULL, 0, 0 },
> { 0, 0, 0, 0, 0 }
> };
>
> @@ -727,7 +727,7 @@ notmuch_address_command (notmuch_config_t *config, int argc, char *argv[])
> (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },
> { "false", NOTMUCH_EXCLUDE_FALSE },
> { 0, 0 } } },
> - { NOTMUCH_OPT_INHERIT, &common_options, NULL, 0, 0 },
> + { NOTMUCH_OPT_INHERIT, (void *) &common_options, NULL, 0, 0 },
> { 0, 0, 0, 0, 0 }
> };
>
> --
> 2.1.4
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 3/3] cli: fix clang build warnings
2015-02-23 19:11 ` Tomi Ollila
@ 2015-02-25 22:14 ` David Bremner
0 siblings, 0 replies; 5+ messages in thread
From: David Bremner @ 2015-02-25 22:14 UTC (permalink / raw)
To: Tomi Ollila, Jani Nikula, notmuch
Tomi Ollila <tomi.ollila@iki.fi> writes:
>
> This looks tolerable to be and the whole series good. tests pass.
Pushed,
d
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-02-25 22:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-23 16:56 [PATCH 1/3] lib: abstract bit validity check in bit test/set/clear macros Jani Nikula
2015-02-23 16:56 ` [PATCH 2/3] lib: fix clang build warnings Jani Nikula
2015-02-23 16:56 ` [PATCH 3/3] cli: " Jani Nikula
2015-02-23 19:11 ` Tomi Ollila
2015-02-25 22:14 ` David Bremner
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).