Tarantool development patches archive
 help / color / mirror / Atom feed
From: "n.pettik" <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH 7/8] sql: clean-up affinity from SQL source code
Date: Tue, 5 Feb 2019 20:46:22 +0300	[thread overview]
Message-ID: <9A482763-8007-445F-A4EE-36F4F40F89A6@tarantool.org> (raw)
In-Reply-To: <a8756505-2272-346b-51d1-1e9741af6c70@tarantool.org>


>> -                * 15 is 1111 in a binary form.
>> -                * Since all existing types can be fitted in 4 bits
>> -                * (field_type_MAX == 10), it is enough to 'and'
>> -                * p5 with this constant. Node that all other flags
>> -                * that can be stored in p5 are >= 16.
>> +                * Since all existing types can be fitted in 4
>> +                * bits (field_type_MAX == 9), it is enough to
>> +                * 'and' p5 with field mask. Note that values of
>> +                * other flags that can be stored in p5 of these
>> +                * opcodes are >= FIELD_TYPE_MASK.
> 
> They can not be == FIELD_TYPE_MASK. Please, again, do not try to
> write here any constants, including bit counts. A definition named
> MASK is already enough to make it clear, that p5 'and' mask give a
> type.

Ok, I won’t argue. 

> Please, apply the diff below. I made enum field_type_mask an
> anonymous enum, as we usually do with independent constants. Also, I
> used FIELD_TYPE_MASK instead of 15 in static assertion, and removed
> the comment from vdbe.c about what a mask is.

Seems like compilers don’t allow to compare two different enums,
even though their values are defined: 

/tarantool/src/box/field_def.h:91:30: error: comparison between ‘enum field_type’ and ‘enum <anonymous>’ [-Werror=enum-compare]
 static_assert(field_type_MAX <= FIELD_TYPE_MASK, "values of enum field_type "\
 
So I added explicit cast:

diff --git a/src/box/field_def.h b/src/box/field_def.h
index dc7730f9f..f944de9d6 100644
--- a/src/box/field_def.h
+++ b/src/box/field_def.h
@@ -88,8 +88,8 @@ enum {
  * For detailed explanation see context of OP_Eq, OP_Lt etc
  * opcodes in vdbe.c.
  */
-static_assert(field_type_MAX <= FIELD_TYPE_MASK, "values of enum field_type "\
-             "should fit into 4 bits of VdbeOp.p5");
+static_assert((int) field_type_MAX <= (int) FIELD_TYPE_MASK,
+             "values of enum field_type should fit into 4 bits of VdbeOp.p5”);

The rest of diff applied as is.

  reply	other threads:[~2019-02-05 17:46 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-28  9:34 [tarantool-patches] [PATCH 0/8] Eliminate affinity from " Nikita Pettik
2018-12-28  9:34 ` [tarantool-patches] [PATCH 1/8] sql: remove SQLITE_ENABLE_UPDATE_DELETE_LIMIT define Nikita Pettik
2018-12-29 17:42   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-16 14:25     ` n.pettik
2018-12-28  9:34 ` [tarantool-patches] [PATCH 2/8] sql: use field type instead of affinity for type_def Nikita Pettik
2018-12-29 17:42   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-16 14:26     ` n.pettik
2018-12-28  9:34 ` [tarantool-patches] [PATCH 3/8] sql: remove numeric affinity Nikita Pettik
2018-12-29  9:01   ` [tarantool-patches] " Konstantin Osipov
2018-12-29 17:42   ` Vladislav Shpilevoy
2019-01-09  8:26     ` Konstantin Osipov
2019-01-16 14:26     ` n.pettik
2019-01-22 15:41       ` Vladislav Shpilevoy
2019-01-28 16:39         ` n.pettik
2019-01-30 13:04           ` Vladislav Shpilevoy
2019-02-01 16:39             ` n.pettik
2019-01-09  8:20   ` Konstantin Osipov
2018-12-28  9:34 ` [tarantool-patches] [PATCH 4/8] sql: replace affinity with field type for func Nikita Pettik
2018-12-28  9:34 ` [tarantool-patches] [PATCH 5/8] sql: replace field type with affinity for VDBE runtime Nikita Pettik
2018-12-29 17:42   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-16 14:26     ` n.pettik
2019-01-22 15:41       ` Vladislav Shpilevoy
2019-01-28 16:39         ` n.pettik
2019-01-30 13:04           ` Vladislav Shpilevoy
2019-02-01 16:39             ` n.pettik
2019-02-05 15:08               ` Vladislav Shpilevoy
2019-02-05 17:46                 ` n.pettik
2018-12-28  9:34 ` [tarantool-patches] [PATCH 6/8] sql: replace affinity with field type in struct Expr Nikita Pettik
2018-12-29 17:42   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-16 14:26     ` n.pettik
2019-01-22 15:41       ` Vladislav Shpilevoy
2019-01-28 16:39         ` n.pettik
2019-01-30 13:04           ` Vladislav Shpilevoy
2019-02-01 16:39             ` n.pettik
2019-02-05 15:08               ` Vladislav Shpilevoy
2019-02-05 17:46                 ` n.pettik
2018-12-28  9:34 ` [tarantool-patches] [PATCH 7/8] sql: clean-up affinity from SQL source code Nikita Pettik
2018-12-29 17:42   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-16 14:26     ` n.pettik
2019-01-22 15:41       ` Vladislav Shpilevoy
2019-01-28 16:40         ` n.pettik
2019-01-30 13:04           ` Vladislav Shpilevoy
2019-02-01 16:39             ` n.pettik
2019-02-05 15:08               ` Vladislav Shpilevoy
2019-02-05 17:46                 ` n.pettik [this message]
2018-12-28  9:34 ` [tarantool-patches] [PATCH 8/8] Remove affinity from field definition Nikita Pettik
2019-02-05 19:41 ` [tarantool-patches] Re: [PATCH 0/8] Eliminate affinity from source code Vladislav Shpilevoy
2019-02-08 13:37 ` Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9A482763-8007-445F-A4EE-36F4F40F89A6@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='[tarantool-patches] Re: [PATCH 7/8] sql: clean-up affinity from SQL source code' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox