From 417a6eb1e93c752359a2f768caacfdeef77336c3 Mon Sep 17 00:00:00 2001 From: Johanna Amann Date: Thu, 30 Jul 2020 12:10:54 -0700 Subject: [PATCH 1/2] Completely remove all traces of the COUNTER type. Relates to GH-1095 --- src/CompHash.cc | 1 - src/Expr.cc | 7 +-- src/Type.cc | 48 ++++++++----------- src/Type.h | 48 +++++++++---------- src/Val.cc | 6 +-- src/Val.h | 1 - src/analyzer/protocol/asn1/asn1.pac | 1 - src/broker/Data.cc | 6 --- src/input/Manager.cc | 4 -- src/input/readers/benchmark/Benchmark.cc | 1 - src/input/readers/sqlite/SQLite.cc | 1 - src/logging/Manager.cc | 1 - src/logging/writers/sqlite/SQLite.cc | 2 - src/parse.y | 7 +-- src/scan.l | 1 - src/threading/SerialTypes.cc | 4 -- src/threading/formatters/Ascii.cc | 2 - src/threading/formatters/JSON.cc | 1 - src/zeek.bif | 2 +- testing/btest/Baseline/language.count/out | 4 -- .../manager-1..stdout | 16 +++---- .../manager-1..stdout | 16 +++---- .../proxy-1..stdout | 4 +- .../proxy-2..stdout | 4 +- .../scripts.base.utils.hash_hrw/output | 16 +++---- testing/btest/language/count.zeek | 13 ++--- .../btest/plugins/hooks-plugin/src/Plugin.cc | 1 - .../btest/plugins/reader-plugin/src/Foo.cc | 1 - 28 files changed, 79 insertions(+), 140 deletions(-) diff --git a/src/CompHash.cc b/src/CompHash.cc index d3b9f728c7..1b84fb6b65 100644 --- a/src/CompHash.cc +++ b/src/CompHash.cc @@ -782,7 +782,6 @@ const char* CompositeHash::RecoverOneVal( switch ( tag ) { case zeek::TYPE_COUNT: - case zeek::TYPE_COUNTER: *pval = zeek::val_mgr->Count(*kp); break; diff --git a/src/Expr.cc b/src/Expr.cc index 0b37a9f5dc..c5eb6911de 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -1685,12 +1685,9 @@ BitExpr::BitExpr(BroExprTag arg_tag, ExprPtr arg_op1, ExprPtr arg_op2) if ( IsVector(bt2) ) bt2 = t2->AsVectorType()->Yield()->Tag(); - if ( (bt1 == zeek::TYPE_COUNT || bt1 == zeek::TYPE_COUNTER) && - (bt2 == zeek::TYPE_COUNT || bt2 == zeek::TYPE_COUNTER) ) + if ( (bt1 == zeek::TYPE_COUNT) && (bt2 == zeek::TYPE_COUNT) ) { - if ( bt1 == zeek::TYPE_COUNTER && bt2 == zeek::TYPE_COUNTER ) - ExprError("cannot apply a bitwise operator to two \"counter\" operands"); - else if ( is_vector(op1) || is_vector(op2) ) + if ( is_vector(op1) || is_vector(op2) ) SetType(zeek::make_intrusive(base_type(zeek::TYPE_COUNT))); else SetType(base_type(zeek::TYPE_COUNT)); diff --git a/src/Type.cc b/src/Type.cc index 940ac32e67..4fc8e97bdd 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -34,28 +34,27 @@ const char* type_name(zeek::TypeTag t) "bool", // 1 "int", // 2 "count", // 3 - "counter", // 4 - "double", // 5 - "time", // 6 - "interval", // 7 - "string", // 8 - "pattern", // 9 - "enum", // 10 - "timer", // 11 - "port", // 12 - "addr", // 13 - "subnet", // 14 - "any", // 15 - "table", // 16 - "union", // 17 - "record", // 18 - "types", // 19 - "func", // 20 - "file", // 21 - "vector", // 22 - "opaque", // 23 - "type", // 24 - "error", // 25 + "double", // 4 + "time", // 5 + "interval", // 6 + "string", // 7 + "pattern", // 8 + "enum", // 9 + "timer", // 10 + "port", // 11 + "addr", // 12 + "subnet", // 13 + "any", // 14 + "table", // 15 + "union", // 16 + "record", // 17 + "types", // 18 + "func", // 19 + "file", // 20 + "vector", // 21 + "opaque", // 22 + "type", // 23 + "error", // 24 }; if ( int(t) >= NUM_TYPES ) @@ -203,7 +202,6 @@ TypePtr Type::ShallowClone() case TYPE_BOOL: case TYPE_INT: case TYPE_COUNT: - case TYPE_COUNTER: case TYPE_DOUBLE: case TYPE_TIME: case TYPE_INTERVAL: @@ -1543,7 +1541,6 @@ bool same_type(const Type& arg_t1, const Type& arg_t2, case TYPE_BOOL: case TYPE_INT: case TYPE_COUNT: - case TYPE_COUNTER: case TYPE_DOUBLE: case TYPE_TIME: case TYPE_INTERVAL: @@ -1745,7 +1742,6 @@ bool is_assignable(TypeTag t) case TYPE_BOOL: case TYPE_INT: case TYPE_COUNT: - case TYPE_COUNTER: case TYPE_DOUBLE: case TYPE_TIME: case TYPE_INTERVAL: @@ -1797,8 +1793,6 @@ TypeTag max_type(TypeTag t1, TypeTag t2) CHECK_TYPE(TYPE_INT); CHECK_TYPE(TYPE_COUNT); - // Note - mixing two TYPE_COUNTER's still promotes to - // a TYPE_COUNT. return TYPE_COUNT; } else diff --git a/src/Type.h b/src/Type.h index 34ecdbb879..178249d802 100644 --- a/src/Type.h +++ b/src/Type.h @@ -39,28 +39,27 @@ enum TypeTag { TYPE_BOOL, // 1 TYPE_INT, // 2 TYPE_COUNT, // 3 - TYPE_COUNTER, // 4 - TYPE_DOUBLE, // 5 - TYPE_TIME, // 6 - TYPE_INTERVAL, // 7 - TYPE_STRING, // 8 - TYPE_PATTERN, // 9 - TYPE_ENUM, // 10 - TYPE_TIMER, // 11 - TYPE_PORT, // 12 - TYPE_ADDR, // 13 - TYPE_SUBNET, // 14 - TYPE_ANY, // 15 - TYPE_TABLE, // 16 - TYPE_UNION, // 17 - TYPE_RECORD, // 18 - TYPE_LIST, // 19 - TYPE_FUNC, // 20 - TYPE_FILE, // 21 - TYPE_VECTOR, // 22 - TYPE_OPAQUE, // 23 - TYPE_TYPE, // 24 - TYPE_ERROR // 25 + TYPE_DOUBLE, // 4 + TYPE_TIME, // 5 + TYPE_INTERVAL, // 6 + TYPE_STRING, // 7 + TYPE_PATTERN, // 8 + TYPE_ENUM, // 9 + TYPE_TIMER, // 10 + TYPE_PORT, // 11 + TYPE_ADDR, // 12 + TYPE_SUBNET, // 13 + TYPE_ANY, // 14 + TYPE_TABLE, // 15 + TYPE_UNION, // 16 + TYPE_RECORD, // 17 + TYPE_LIST, // 18 + TYPE_FUNC, // 19 + TYPE_FILE, // 20 + TYPE_VECTOR, // 21 + TYPE_OPAQUE, // 22 + TYPE_TYPE, // 23 + TYPE_ERROR // 24 #define NUM_TYPES (int(TYPE_ERROR) + 1) }; @@ -97,7 +96,6 @@ constexpr InternalTypeTag to_internal_type_tag(TypeTag tag) noexcept return TYPE_INTERNAL_INT; case TYPE_COUNT: - case TYPE_COUNTER: case TYPE_PORT: return TYPE_INTERNAL_UNSIGNED; @@ -818,7 +816,7 @@ inline bool is_assignable(Type* t) { return zeek::is_assignable(t->Tag()); } // True if the given type tag corresponds to an integral type. -inline bool IsIntegral(TypeTag t) { return (t == TYPE_INT || t == TYPE_COUNT || t == TYPE_COUNTER); } +inline bool IsIntegral(TypeTag t) { return (t == TYPE_INT || t == TYPE_COUNT ); } // True if the given type tag corresponds to an arithmetic type. inline bool IsArithmetic(TypeTag t) { return (IsIntegral(t) || t == TYPE_DOUBLE); } @@ -937,8 +935,6 @@ constexpr auto TYPE_BOOL = zeek::TYPE_BOOL; constexpr auto TYPE_INT = zeek::TYPE_INT; [[deprecated("Remove in v4.1. Use zeek::TYPE_COUNT instead.")]] constexpr auto TYPE_COUNT = zeek::TYPE_COUNT; -[[deprecated("Remove in v4.1. Use zeek::TYPE_COUNTER instead.")]] -constexpr auto TYPE_COUNTER = zeek::TYPE_COUNTER; [[deprecated("Remove in v4.1. Use zeek::TYPE_DOUBLE instead.")]] constexpr auto TYPE_DOUBLE = zeek::TYPE_DOUBLE; [[deprecated("Remove in v4.1. Use zeek::TYPE_TIME instead.")]] diff --git a/src/Val.cc b/src/Val.cc index 8ca9d4538f..224d0de5cf 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -517,10 +517,6 @@ static void BuildJSON(threading::formatter::JSON::NullDoubleWriter& writer, Val* writer.Uint64(val->AsCount()); break; - case TYPE_COUNTER: - writer.Uint64(val->AsCounter()); - break; - case TYPE_TIME: writer.Double(val->AsTime()); break; @@ -3449,7 +3445,7 @@ ValPtr check_and_promote(ValPtr v, t->Error("overflow promoting from signed/double to unsigned arithmetic value", v.get(), false, expr_location); return nullptr; } - else if ( t_tag == TYPE_COUNT || t_tag == TYPE_COUNTER ) + else if ( t_tag == TYPE_COUNT ) promoted_v = zeek::val_mgr->Count(v->CoerceToUnsigned()); else // port { diff --git a/src/Val.h b/src/Val.h index 0a99526fbb..8232213ff9 100644 --- a/src/Val.h +++ b/src/Val.h @@ -232,7 +232,6 @@ public: CONST_ACCESSOR2(zeek::TYPE_BOOL, bool, int_val, AsBool) CONST_ACCESSOR2(zeek::TYPE_INT, bro_int_t, int_val, AsInt) CONST_ACCESSOR2(zeek::TYPE_COUNT, bro_uint_t, uint_val, AsCount) - CONST_ACCESSOR2(zeek::TYPE_COUNTER, bro_uint_t, uint_val, AsCounter) CONST_ACCESSOR2(zeek::TYPE_DOUBLE, double, double_val, AsDouble) CONST_ACCESSOR2(zeek::TYPE_TIME, double, double_val, AsTime) CONST_ACCESSOR2(zeek::TYPE_INTERVAL, double, double_val, AsInterval) diff --git a/src/analyzer/protocol/asn1/asn1.pac b/src/analyzer/protocol/asn1/asn1.pac index 484ed27db7..c7cf6febeb 100644 --- a/src/analyzer/protocol/asn1/asn1.pac +++ b/src/analyzer/protocol/asn1/asn1.pac @@ -117,7 +117,6 @@ zeek::ValPtr asn1_integer_to_val(const ASN1Encoding* i, zeek::TypeTag t) case zeek::TYPE_INT: return zeek::val_mgr->Int(v); case zeek::TYPE_COUNT: - case zeek::TYPE_COUNTER: return zeek::val_mgr->Count(v); default: reporter->Error("bad asn1_integer_to_val tag: %s", zeek::type_name(t)); diff --git a/src/broker/Data.cc b/src/broker/Data.cc index 260dec8eb6..a6ea23f99e 100644 --- a/src/broker/Data.cc +++ b/src/broker/Data.cc @@ -93,8 +93,6 @@ struct val_converter { { if ( type->Tag() == zeek::TYPE_COUNT ) return zeek::val_mgr->Count(a); - if ( type->Tag() == zeek::TYPE_COUNTER ) - return zeek::val_mgr->Count(a); return nullptr; } @@ -463,8 +461,6 @@ struct type_checker { { if ( type->Tag() == zeek::TYPE_COUNT ) return true; - if ( type->Tag() == zeek::TYPE_COUNTER ) - return true; return false; } @@ -796,8 +792,6 @@ broker::expected bro_broker::val_to_data(const zeek::Val* v) return {v->AsInt()}; case zeek::TYPE_COUNT: return {v->AsCount()}; - case zeek::TYPE_COUNTER: - return {v->AsCounter()}; case zeek::TYPE_PORT: { auto p = v->AsPortVal(); diff --git a/src/input/Manager.cc b/src/input/Manager.cc index d26b51e104..7b596bdb4a 100644 --- a/src/input/Manager.cc +++ b/src/input/Manager.cc @@ -800,7 +800,6 @@ bool Manager::IsCompatibleType(zeek::Type* t, bool atomic_only) case zeek::TYPE_BOOL: case zeek::TYPE_INT: case zeek::TYPE_COUNT: - case zeek::TYPE_COUNTER: case zeek::TYPE_PORT: case zeek::TYPE_SUBNET: case zeek::TYPE_ADDR: @@ -1919,7 +1918,6 @@ int Manager::GetValueLength(const Value* val) const break; case zeek::TYPE_COUNT: - case zeek::TYPE_COUNTER: length += sizeof(val->val.uint_val); break; @@ -2015,7 +2013,6 @@ int Manager::CopyValue(char *data, const int startpos, const Value* val) const return sizeof(val->val.int_val); case zeek::TYPE_COUNT: - case zeek::TYPE_COUNTER: memcpy(data+startpos, (const void*) &(val->val.uint_val), sizeof(val->val.uint_val)); return sizeof(val->val.uint_val); @@ -2204,7 +2201,6 @@ zeek::Val* Manager::ValueToVal(const Stream* i, const Value* val, zeek::Type* re return zeek::val_mgr->Int(val->val.int_val).release(); case zeek::TYPE_COUNT: - case zeek::TYPE_COUNTER: return zeek::val_mgr->Count(val->val.int_val).release(); case zeek::TYPE_DOUBLE: diff --git a/src/input/readers/benchmark/Benchmark.cc b/src/input/readers/benchmark/Benchmark.cc index 13aad78233..f656c721c9 100644 --- a/src/input/readers/benchmark/Benchmark.cc +++ b/src/input/readers/benchmark/Benchmark.cc @@ -159,7 +159,6 @@ threading::Value* Benchmark::EntryToVal(zeek::TypeTag type, zeek::TypeTag subtyp break; case zeek::TYPE_COUNT: - case zeek::TYPE_COUNTER: val->val.uint_val = random(); break; diff --git a/src/input/readers/sqlite/SQLite.cc b/src/input/readers/sqlite/SQLite.cc index 733cb4cd7b..d2b9cd236e 100644 --- a/src/input/readers/sqlite/SQLite.cc +++ b/src/input/readers/sqlite/SQLite.cc @@ -183,7 +183,6 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p break; case zeek::TYPE_COUNT: - case zeek::TYPE_COUNTER: val->val.uint_val = sqlite3_column_int64(st, pos); break; diff --git a/src/logging/Manager.cc b/src/logging/Manager.cc index 8183369243..3d7d30fc08 100644 --- a/src/logging/Manager.cc +++ b/src/logging/Manager.cc @@ -956,7 +956,6 @@ threading::Value* Manager::ValToLogVal(zeek::Val* val, zeek::Type* ty) } case zeek::TYPE_COUNT: - case zeek::TYPE_COUNTER: lval->val.uint_val = val->InternalUnsigned(); break; diff --git a/src/logging/writers/sqlite/SQLite.cc b/src/logging/writers/sqlite/SQLite.cc index c1fa94e4c7..2370a732f9 100644 --- a/src/logging/writers/sqlite/SQLite.cc +++ b/src/logging/writers/sqlite/SQLite.cc @@ -64,7 +64,6 @@ string SQLite::GetTableType(int arg_type, int arg_subtype) { case zeek::TYPE_INT: case zeek::TYPE_COUNT: - case zeek::TYPE_COUNTER: case zeek::TYPE_PORT: // note that we do not save the protocol at the moment. Just like in the case of the ascii-writer type = "integer"; break; @@ -250,7 +249,6 @@ int SQLite::AddParams(Value* val, int pos) return sqlite3_bind_int(st, pos, val->val.int_val); case zeek::TYPE_COUNT: - case zeek::TYPE_COUNTER: return sqlite3_bind_int(st, pos, val->val.uint_val); case zeek::TYPE_PORT: diff --git a/src/parse.y b/src/parse.y index f42f4b04bd..3de9cb266b 100644 --- a/src/parse.y +++ b/src/parse.y @@ -10,7 +10,7 @@ %token TOK_ADD TOK_ADD_TO TOK_ADDR TOK_ANY %token TOK_ATENDIF TOK_ATELSE TOK_ATIF TOK_ATIFDEF TOK_ATIFNDEF %token TOK_BOOL TOK_BREAK TOK_CASE TOK_OPTION TOK_CONST -%token TOK_CONSTANT TOK_COPY TOK_COUNT TOK_COUNTER TOK_DEFAULT TOK_DELETE +%token TOK_CONSTANT TOK_COPY TOK_COUNT TOK_DEFAULT TOK_DELETE %token TOK_DOUBLE TOK_ELSE TOK_ENUM TOK_EVENT TOK_EXPORT TOK_FALLTHROUGH %token TOK_FILE TOK_FOR TOK_FUNCTION TOK_GLOBAL TOK_HOOK TOK_ID TOK_IF TOK_INT %token TOK_INTERVAL TOK_LIST TOK_LOCAL TOK_MODULE @@ -840,11 +840,6 @@ type: $$ = zeek::base_type(zeek::TYPE_COUNT)->Ref(); } - | TOK_COUNTER { - zeek::detail::set_location(@1); - $$ = zeek::base_type(zeek::TYPE_COUNTER)->Ref(); - } - | TOK_DOUBLE { zeek::detail::set_location(@1); $$ = zeek::base_type(zeek::TYPE_DOUBLE)->Ref(); diff --git a/src/scan.l b/src/scan.l index 2c2562d344..9d5c4d3884 100644 --- a/src/scan.l +++ b/src/scan.l @@ -220,7 +220,6 @@ option return TOK_OPTION; const return TOK_CONST; copy return TOK_COPY; count return TOK_COUNT; -counter return TOK_COUNTER; default return TOK_DEFAULT; delete return TOK_DELETE; double return TOK_DOUBLE; diff --git a/src/threading/SerialTypes.cc b/src/threading/SerialTypes.cc index c15f672b25..3d4eb34a0b 100644 --- a/src/threading/SerialTypes.cc +++ b/src/threading/SerialTypes.cc @@ -131,7 +131,6 @@ bool Value::IsCompatibleType(zeek::Type* t, bool atomic_only) case zeek::TYPE_BOOL: case zeek::TYPE_INT: case zeek::TYPE_COUNT: - case zeek::TYPE_COUNTER: case zeek::TYPE_PORT: case zeek::TYPE_SUBNET: case zeek::TYPE_ADDR: @@ -192,7 +191,6 @@ bool Value::Read(SerializationFormat* fmt) return fmt->Read(&val.int_val, "int"); case zeek::TYPE_COUNT: - case zeek::TYPE_COUNTER: return fmt->Read(&val.uint_val, "uint"); case zeek::TYPE_PORT: { @@ -339,7 +337,6 @@ bool Value::Write(SerializationFormat* fmt) const return fmt->Write(val.int_val, "int"); case zeek::TYPE_COUNT: - case zeek::TYPE_COUNTER: return fmt->Write(val.uint_val, "uint"); case zeek::TYPE_PORT: @@ -452,7 +449,6 @@ zeek::Val* Value::ValueToVal(const std::string& source, const Value* val, bool& return zeek::val_mgr->Int(val->val.int_val).release(); case zeek::TYPE_COUNT: - case zeek::TYPE_COUNTER: return zeek::val_mgr->Count(val->val.int_val).release(); case zeek::TYPE_DOUBLE: diff --git a/src/threading/formatters/Ascii.cc b/src/threading/formatters/Ascii.cc index 5e84bc67ac..76ad9f9ad4 100644 --- a/src/threading/formatters/Ascii.cc +++ b/src/threading/formatters/Ascii.cc @@ -90,7 +90,6 @@ bool Ascii::Describe(ODesc* desc, threading::Value* val, const string& name) con break; case zeek::TYPE_COUNT: - case zeek::TYPE_COUNTER: desc->Add(val->val.uint_val); break; @@ -260,7 +259,6 @@ threading::Value* Ascii::ParseValue(const string& s, const string& name, zeek::T break; case zeek::TYPE_COUNT: - case zeek::TYPE_COUNTER: val->val.uint_val = strtoull(start, &end, 10); if ( CheckNumberError(start, end) ) goto parse_error; diff --git a/src/threading/formatters/JSON.cc b/src/threading/formatters/JSON.cc index c44c1d5cf4..6afd6b42d7 100644 --- a/src/threading/formatters/JSON.cc +++ b/src/threading/formatters/JSON.cc @@ -106,7 +106,6 @@ void JSON::BuildJSON(NullDoubleWriter& writer, Value* val, const std::string& na break; case zeek::TYPE_COUNT: - case zeek::TYPE_COUNTER: writer.Uint64(val->val.uint_val); break; diff --git a/src/zeek.bif b/src/zeek.bif index 0de446fbbc..8eba767a54 100644 --- a/src/zeek.bif +++ b/src/zeek.bif @@ -48,7 +48,7 @@ bro_int_t parse_int(const char*& fmt) } static zeek::TypeTag ok_d_fmt[] = { - zeek::TYPE_BOOL, zeek::TYPE_ENUM, zeek::TYPE_INT, zeek::TYPE_COUNT, zeek::TYPE_COUNTER, zeek::TYPE_PORT, + zeek::TYPE_BOOL, zeek::TYPE_ENUM, zeek::TYPE_INT, zeek::TYPE_COUNT, zeek::TYPE_PORT, zeek::TYPE_SUBNET, zeek::TYPE_ERROR }; diff --git a/testing/btest/Baseline/language.count/out b/testing/btest/Baseline/language.count/out index f1e1eef587..e5a6e24228 100644 --- a/testing/btest/Baseline/language.count/out +++ b/testing/btest/Baseline/language.count/out @@ -1,5 +1,4 @@ type inference (PASS) -counter alias (PASS) hexadecimal (PASS) inequality operator (PASS) relational operator (PASS) @@ -19,9 +18,6 @@ bitwise and (PASS) bitwise and (PASS) bitwise or (PASS) bitwise or (PASS) -bitwise or (PASS) -bitwise xor (PASS) -bitwise xor (PASS) bitwise xor (PASS) bitwise complement (PASS) bitwise complement (PASS) diff --git a/testing/btest/Baseline/scripts.base.frameworks.cluster.custom_pool_limits/manager-1..stdout b/testing/btest/Baseline/scripts.base.frameworks.cluster.custom_pool_limits/manager-1..stdout index 015d95ee9d..1c62e0700d 100644 --- a/testing/btest/Baseline/scripts.base.frameworks.cluster.custom_pool_limits/manager-1..stdout +++ b/testing/btest/Baseline/scripts.base.frameworks.cluster.custom_pool_limits/manager-1..stdout @@ -1,18 +1,18 @@ 1st stuff hrw, 0, zeek/cluster/node/proxy-1/ -hrw (custom pool), 0, zeek/cluster/node/proxy-1/ +hrw (custom pool), 0, zeek/cluster/node/proxy-2/ hrw, 1, zeek/cluster/node/proxy-1/ -hrw (custom pool), 1, zeek/cluster/node/proxy-1/ +hrw (custom pool), 1, zeek/cluster/node/proxy-2/ hrw, 2, zeek/cluster/node/proxy-1/ hrw (custom pool), 2, zeek/cluster/node/proxy-1/ hrw, 3, zeek/cluster/node/proxy-1/ -hrw (custom pool), 3, zeek/cluster/node/proxy-1/ +hrw (custom pool), 3, zeek/cluster/node/proxy-2/ hrw, 13, zeek/cluster/node/proxy-1/ hrw (custom pool), 13, zeek/cluster/node/proxy-2/ hrw, 37, zeek/cluster/node/proxy-1/ hrw (custom pool), 37, zeek/cluster/node/proxy-2/ hrw, 42, zeek/cluster/node/proxy-1/ -hrw (custom pool), 42, zeek/cluster/node/proxy-2/ +hrw (custom pool), 42, zeek/cluster/node/proxy-1/ hrw, 101, zeek/cluster/node/proxy-1/ hrw (custom pool), 101, zeek/cluster/node/proxy-2/ rr, zeek/cluster/node/proxy-1/ @@ -32,19 +32,19 @@ rr (custom pool), zeek/cluster/node/proxy-1/ rr, zeek/cluster/node/proxy-1/ rr (custom pool), zeek/cluster/node/proxy-2/ hrw, 0, zeek/cluster/node/proxy-1/ -hrw (custom pool), 0, zeek/cluster/node/proxy-1/ +hrw (custom pool), 0, zeek/cluster/node/proxy-2/ hrw, 1, zeek/cluster/node/proxy-1/ -hrw (custom pool), 1, zeek/cluster/node/proxy-1/ +hrw (custom pool), 1, zeek/cluster/node/proxy-2/ hrw, 2, zeek/cluster/node/proxy-1/ hrw (custom pool), 2, zeek/cluster/node/proxy-1/ hrw, 3, zeek/cluster/node/proxy-1/ -hrw (custom pool), 3, zeek/cluster/node/proxy-1/ +hrw (custom pool), 3, zeek/cluster/node/proxy-2/ hrw, 13, zeek/cluster/node/proxy-1/ hrw (custom pool), 13, zeek/cluster/node/proxy-2/ hrw, 37, zeek/cluster/node/proxy-1/ hrw (custom pool), 37, zeek/cluster/node/proxy-2/ hrw, 42, zeek/cluster/node/proxy-1/ -hrw (custom pool), 42, zeek/cluster/node/proxy-2/ +hrw (custom pool), 42, zeek/cluster/node/proxy-1/ hrw, 101, zeek/cluster/node/proxy-1/ hrw (custom pool), 101, zeek/cluster/node/proxy-2/ 2nd stuff diff --git a/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution/manager-1..stdout b/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution/manager-1..stdout index 5ef98205eb..4966d2a267 100644 --- a/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution/manager-1..stdout +++ b/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution/manager-1..stdout @@ -1,11 +1,11 @@ 1st stuff -hrw, 0, zeek/cluster/node/proxy-1/ -hrw, 1, zeek/cluster/node/proxy-1/ +hrw, 0, zeek/cluster/node/proxy-2/ +hrw, 1, zeek/cluster/node/proxy-2/ hrw, 2, zeek/cluster/node/proxy-1/ -hrw, 3, zeek/cluster/node/proxy-1/ +hrw, 3, zeek/cluster/node/proxy-2/ hrw, 13, zeek/cluster/node/proxy-2/ hrw, 37, zeek/cluster/node/proxy-2/ -hrw, 42, zeek/cluster/node/proxy-2/ +hrw, 42, zeek/cluster/node/proxy-1/ hrw, 101, zeek/cluster/node/proxy-2/ rr, zeek/cluster/node/proxy-1/ rr, zeek/cluster/node/proxy-2/ @@ -15,13 +15,13 @@ rr, zeek/cluster/node/proxy-1/ rr, zeek/cluster/node/proxy-2/ rr, zeek/cluster/node/proxy-1/ rr, zeek/cluster/node/proxy-2/ -hrw, 0, zeek/cluster/node/proxy-1/ -hrw, 1, zeek/cluster/node/proxy-1/ +hrw, 0, zeek/cluster/node/proxy-2/ +hrw, 1, zeek/cluster/node/proxy-2/ hrw, 2, zeek/cluster/node/proxy-1/ -hrw, 3, zeek/cluster/node/proxy-1/ +hrw, 3, zeek/cluster/node/proxy-2/ hrw, 13, zeek/cluster/node/proxy-2/ hrw, 37, zeek/cluster/node/proxy-2/ -hrw, 42, zeek/cluster/node/proxy-2/ +hrw, 42, zeek/cluster/node/proxy-1/ hrw, 101, zeek/cluster/node/proxy-2/ 2nd stuff hrw, 0, zeek/cluster/node/proxy-2/ diff --git a/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution_bifs/proxy-1..stdout b/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution_bifs/proxy-1..stdout index b86028c482..0649079972 100644 --- a/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution_bifs/proxy-1..stdout +++ b/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution_bifs/proxy-1..stdout @@ -1,7 +1,5 @@ -got distributed event hrw, 0 -got distributed event hrw, 1 got distributed event hrw, 2 -got distributed event hrw, 3 +got distributed event hrw, 42 got distributed event rr, 0 got distributed event rr, 2 got distributed event rr, 13 diff --git a/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution_bifs/proxy-2..stdout b/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution_bifs/proxy-2..stdout index a83f3f7394..4f2bbbcea9 100644 --- a/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution_bifs/proxy-2..stdout +++ b/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution_bifs/proxy-2..stdout @@ -1,6 +1,8 @@ +got distributed event hrw, 0 +got distributed event hrw, 1 +got distributed event hrw, 3 got distributed event hrw, 13 got distributed event hrw, 37 -got distributed event hrw, 42 got distributed event hrw, 101 got distributed event rr, 1 got distributed event rr, 3 diff --git a/testing/btest/Baseline/scripts.base.utils.hash_hrw/output b/testing/btest/Baseline/scripts.base.utils.hash_hrw/output index 2c37b5b752..94ef962584 100644 --- a/testing/btest/Baseline/scripts.base.utils.hash_hrw/output +++ b/testing/btest/Baseline/scripts.base.utils.hash_hrw/output @@ -8,18 +8,18 @@ T F [id=0, user_data=alice] [id=3, user_data=dave] -[id=3, user_data=dave] -[id=0, user_data=alice] -[id=0, user_data=alice] +[id=4, user_data=eve] +[id=4, user_data=eve] [id=4, user_data=eve] [id=0, user_data=alice] +[id=3, user_data=dave] [id=1, user_data=bob] [id=0, user_data=alice] [id=1, user_data=bob] T +[id=4, user_data=eve] [id=3, user_data=dave] -[id=3, user_data=dave] -[id=3, user_data=dave] +[id=4, user_data=eve] [id=4, user_data=eve] [id=4, user_data=eve] [id=4, user_data=eve] @@ -30,11 +30,11 @@ T T [id=0, user_data=alice] [id=3, user_data=dave] -[id=3, user_data=dave] -[id=0, user_data=alice] -[id=0, user_data=alice] +[id=4, user_data=eve] +[id=4, user_data=eve] [id=4, user_data=eve] [id=0, user_data=alice] +[id=3, user_data=dave] [id=1, user_data=bob] [id=0, user_data=alice] [id=1, user_data=bob] diff --git a/testing/btest/language/count.zeek b/testing/btest/language/count.zeek index a2d3fb0cc2..ca683598ac 100644 --- a/testing/btest/language/count.zeek +++ b/testing/btest/language/count.zeek @@ -15,16 +15,12 @@ event zeek_init() local c4: count = 255; local c5: count = 18446744073709551615; # maximum allowed value local c6: count = 0xffffffffffffffff; # maximum allowed value - local c7: counter = 5; - local c8 = 1; + local c7 = 1; # Type inference test - test_case( "type inference", type_name(c8) == "count" ); + test_case( "type inference", type_name(c7) == "count" ); - # Counter alias test - - test_case( "counter alias", c2 == c7 ); # Test various constant representations @@ -49,13 +45,10 @@ event zeek_init() test_case( "assignment operator", c2 == 6 ); test_case( "bitwise and", c2 & 0x4 == 0x4 ); test_case( "bitwise and", c4 & 0x4 == 0x4 ); - test_case( "bitwise and", c8 & 0x4 == 0x0 ); + test_case( "bitwise and", c7 & 0x4 == 0x0 ); test_case( "bitwise or", c2 | 0x4 == c2 ); test_case( "bitwise or", c4 | 0x4 == c4 ); - test_case( "bitwise or", c8 | 0x4 == c7 ); - test_case( "bitwise xor", c7 ^ 0x4 == c8 ); test_case( "bitwise xor", c4 ^ 0x4 == 251 ); - test_case( "bitwise xor", c8 ^ 0x4 == c7 ); test_case( "bitwise complement", ~c6 == 0 ); test_case( "bitwise complement", ~~c4 == c4 ); diff --git a/testing/btest/plugins/hooks-plugin/src/Plugin.cc b/testing/btest/plugins/hooks-plugin/src/Plugin.cc index 4166443a6a..41fec8e258 100644 --- a/testing/btest/plugins/hooks-plugin/src/Plugin.cc +++ b/testing/btest/plugins/hooks-plugin/src/Plugin.cc @@ -179,7 +179,6 @@ void Plugin::RenderVal(const threading::Value* val, ODesc &d) const break; case TYPE_COUNT: - case TYPE_COUNTER: d.Add(val->val.uint_val); break; diff --git a/testing/btest/plugins/reader-plugin/src/Foo.cc b/testing/btest/plugins/reader-plugin/src/Foo.cc index a7e5021932..863b504e0b 100644 --- a/testing/btest/plugins/reader-plugin/src/Foo.cc +++ b/testing/btest/plugins/reader-plugin/src/Foo.cc @@ -107,7 +107,6 @@ threading::Value* Foo::EntryToVal(zeek::TypeTag type, zeek::TypeTag subtype) break; case zeek::TYPE_COUNT: - case zeek::TYPE_COUNTER: val->val.uint_val = random(); break; From cd3400f957ee846243a270f61061e758a23f2ee8 Mon Sep 17 00:00:00 2001 From: Johanna Amann Date: Fri, 31 Jul 2020 14:53:27 -0700 Subject: [PATCH 2/2] Re-add TYPE_COUNTER without function and deprecation marker. --- NEWS | 6 +++ src/Type.cc | 43 +++++++++--------- src/Type.h | 45 ++++++++++--------- .../manager-1..stdout | 16 +++---- .../manager-1..stdout | 16 +++---- .../proxy-1..stdout | 4 +- .../proxy-2..stdout | 4 +- .../scripts.base.utils.hash_hrw/output | 18 ++++---- 8 files changed, 81 insertions(+), 71 deletions(-) diff --git a/NEWS b/NEWS index 5401b91919..12ccfe656f 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,12 @@ Zeek 4.0.0 TODO: nothing notable yet +Removed Functionality +--------------------- + +- The counter type was removed. This type was never fully functional/used + anywhere. + Zeek 3.2.0 ========== diff --git a/src/Type.cc b/src/Type.cc index 4fc8e97bdd..f0031cff06 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -34,27 +34,28 @@ const char* type_name(zeek::TypeTag t) "bool", // 1 "int", // 2 "count", // 3 - "double", // 4 - "time", // 5 - "interval", // 6 - "string", // 7 - "pattern", // 8 - "enum", // 9 - "timer", // 10 - "port", // 11 - "addr", // 12 - "subnet", // 13 - "any", // 14 - "table", // 15 - "union", // 16 - "record", // 17 - "types", // 18 - "func", // 19 - "file", // 20 - "vector", // 21 - "opaque", // 22 - "type", // 23 - "error", // 24 + "counter", // 4 + "double", // 5 + "time", // 6 + "interval", // 7 + "string", // 8 + "pattern", // 9 + "enum", // 10 + "timer", // 11 + "port", // 12 + "addr", // 13 + "subnet", // 14 + "any", // 16 + "table", // 16 + "union", // 17 + "record", // 18 + "types", // 19 + "func", // 20 + "file", // 21 + "vector", // 22 + "opaque", // 23 + "type", // 24 + "error", // 25 }; if ( int(t) >= NUM_TYPES ) diff --git a/src/Type.h b/src/Type.h index 178249d802..432bd4adc1 100644 --- a/src/Type.h +++ b/src/Type.h @@ -39,27 +39,28 @@ enum TypeTag { TYPE_BOOL, // 1 TYPE_INT, // 2 TYPE_COUNT, // 3 - TYPE_DOUBLE, // 4 - TYPE_TIME, // 5 - TYPE_INTERVAL, // 6 - TYPE_STRING, // 7 - TYPE_PATTERN, // 8 - TYPE_ENUM, // 9 - TYPE_TIMER, // 10 - TYPE_PORT, // 11 - TYPE_ADDR, // 12 - TYPE_SUBNET, // 13 - TYPE_ANY, // 14 - TYPE_TABLE, // 15 - TYPE_UNION, // 16 - TYPE_RECORD, // 17 - TYPE_LIST, // 18 - TYPE_FUNC, // 19 - TYPE_FILE, // 20 - TYPE_VECTOR, // 21 - TYPE_OPAQUE, // 22 - TYPE_TYPE, // 23 - TYPE_ERROR // 24 + TYPE_COUNTER [[deprecated("Remove in v4.1. TYPE_COUNTER was removed; use TYPE_COUNT instead.")]], // 4 + TYPE_DOUBLE, // 5 + TYPE_TIME, // 6 + TYPE_INTERVAL, // 7 + TYPE_STRING, // 8 + TYPE_PATTERN, // 9 + TYPE_ENUM, // 10 + TYPE_TIMER, // 11 + TYPE_PORT, // 12 + TYPE_ADDR, // 13 + TYPE_SUBNET, // 14 + TYPE_ANY, // 15 + TYPE_TABLE, // 16 + TYPE_UNION, // 17 + TYPE_RECORD, // 18 + TYPE_LIST, // 19 + TYPE_FUNC, // 20 + TYPE_FILE, // 21 + TYPE_VECTOR, // 22 + TYPE_OPAQUE, // 23 + TYPE_TYPE, // 24 + TYPE_ERROR // 25 #define NUM_TYPES (int(TYPE_ERROR) + 1) }; @@ -935,6 +936,8 @@ constexpr auto TYPE_BOOL = zeek::TYPE_BOOL; constexpr auto TYPE_INT = zeek::TYPE_INT; [[deprecated("Remove in v4.1. Use zeek::TYPE_COUNT instead.")]] constexpr auto TYPE_COUNT = zeek::TYPE_COUNT; +[[deprecated("Remove in v4.1. TYPE_COUNTER was removed. Use zeek::TYPE_COUNT instead.")]] +constexpr auto TYPE_COUNTER = zeek::TYPE_COUNTER; [[deprecated("Remove in v4.1. Use zeek::TYPE_DOUBLE instead.")]] constexpr auto TYPE_DOUBLE = zeek::TYPE_DOUBLE; [[deprecated("Remove in v4.1. Use zeek::TYPE_TIME instead.")]] diff --git a/testing/btest/Baseline/scripts.base.frameworks.cluster.custom_pool_limits/manager-1..stdout b/testing/btest/Baseline/scripts.base.frameworks.cluster.custom_pool_limits/manager-1..stdout index 1c62e0700d..015d95ee9d 100644 --- a/testing/btest/Baseline/scripts.base.frameworks.cluster.custom_pool_limits/manager-1..stdout +++ b/testing/btest/Baseline/scripts.base.frameworks.cluster.custom_pool_limits/manager-1..stdout @@ -1,18 +1,18 @@ 1st stuff hrw, 0, zeek/cluster/node/proxy-1/ -hrw (custom pool), 0, zeek/cluster/node/proxy-2/ +hrw (custom pool), 0, zeek/cluster/node/proxy-1/ hrw, 1, zeek/cluster/node/proxy-1/ -hrw (custom pool), 1, zeek/cluster/node/proxy-2/ +hrw (custom pool), 1, zeek/cluster/node/proxy-1/ hrw, 2, zeek/cluster/node/proxy-1/ hrw (custom pool), 2, zeek/cluster/node/proxy-1/ hrw, 3, zeek/cluster/node/proxy-1/ -hrw (custom pool), 3, zeek/cluster/node/proxy-2/ +hrw (custom pool), 3, zeek/cluster/node/proxy-1/ hrw, 13, zeek/cluster/node/proxy-1/ hrw (custom pool), 13, zeek/cluster/node/proxy-2/ hrw, 37, zeek/cluster/node/proxy-1/ hrw (custom pool), 37, zeek/cluster/node/proxy-2/ hrw, 42, zeek/cluster/node/proxy-1/ -hrw (custom pool), 42, zeek/cluster/node/proxy-1/ +hrw (custom pool), 42, zeek/cluster/node/proxy-2/ hrw, 101, zeek/cluster/node/proxy-1/ hrw (custom pool), 101, zeek/cluster/node/proxy-2/ rr, zeek/cluster/node/proxy-1/ @@ -32,19 +32,19 @@ rr (custom pool), zeek/cluster/node/proxy-1/ rr, zeek/cluster/node/proxy-1/ rr (custom pool), zeek/cluster/node/proxy-2/ hrw, 0, zeek/cluster/node/proxy-1/ -hrw (custom pool), 0, zeek/cluster/node/proxy-2/ +hrw (custom pool), 0, zeek/cluster/node/proxy-1/ hrw, 1, zeek/cluster/node/proxy-1/ -hrw (custom pool), 1, zeek/cluster/node/proxy-2/ +hrw (custom pool), 1, zeek/cluster/node/proxy-1/ hrw, 2, zeek/cluster/node/proxy-1/ hrw (custom pool), 2, zeek/cluster/node/proxy-1/ hrw, 3, zeek/cluster/node/proxy-1/ -hrw (custom pool), 3, zeek/cluster/node/proxy-2/ +hrw (custom pool), 3, zeek/cluster/node/proxy-1/ hrw, 13, zeek/cluster/node/proxy-1/ hrw (custom pool), 13, zeek/cluster/node/proxy-2/ hrw, 37, zeek/cluster/node/proxy-1/ hrw (custom pool), 37, zeek/cluster/node/proxy-2/ hrw, 42, zeek/cluster/node/proxy-1/ -hrw (custom pool), 42, zeek/cluster/node/proxy-1/ +hrw (custom pool), 42, zeek/cluster/node/proxy-2/ hrw, 101, zeek/cluster/node/proxy-1/ hrw (custom pool), 101, zeek/cluster/node/proxy-2/ 2nd stuff diff --git a/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution/manager-1..stdout b/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution/manager-1..stdout index 4966d2a267..5ef98205eb 100644 --- a/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution/manager-1..stdout +++ b/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution/manager-1..stdout @@ -1,11 +1,11 @@ 1st stuff -hrw, 0, zeek/cluster/node/proxy-2/ -hrw, 1, zeek/cluster/node/proxy-2/ +hrw, 0, zeek/cluster/node/proxy-1/ +hrw, 1, zeek/cluster/node/proxy-1/ hrw, 2, zeek/cluster/node/proxy-1/ -hrw, 3, zeek/cluster/node/proxy-2/ +hrw, 3, zeek/cluster/node/proxy-1/ hrw, 13, zeek/cluster/node/proxy-2/ hrw, 37, zeek/cluster/node/proxy-2/ -hrw, 42, zeek/cluster/node/proxy-1/ +hrw, 42, zeek/cluster/node/proxy-2/ hrw, 101, zeek/cluster/node/proxy-2/ rr, zeek/cluster/node/proxy-1/ rr, zeek/cluster/node/proxy-2/ @@ -15,13 +15,13 @@ rr, zeek/cluster/node/proxy-1/ rr, zeek/cluster/node/proxy-2/ rr, zeek/cluster/node/proxy-1/ rr, zeek/cluster/node/proxy-2/ -hrw, 0, zeek/cluster/node/proxy-2/ -hrw, 1, zeek/cluster/node/proxy-2/ +hrw, 0, zeek/cluster/node/proxy-1/ +hrw, 1, zeek/cluster/node/proxy-1/ hrw, 2, zeek/cluster/node/proxy-1/ -hrw, 3, zeek/cluster/node/proxy-2/ +hrw, 3, zeek/cluster/node/proxy-1/ hrw, 13, zeek/cluster/node/proxy-2/ hrw, 37, zeek/cluster/node/proxy-2/ -hrw, 42, zeek/cluster/node/proxy-1/ +hrw, 42, zeek/cluster/node/proxy-2/ hrw, 101, zeek/cluster/node/proxy-2/ 2nd stuff hrw, 0, zeek/cluster/node/proxy-2/ diff --git a/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution_bifs/proxy-1..stdout b/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution_bifs/proxy-1..stdout index 0649079972..b86028c482 100644 --- a/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution_bifs/proxy-1..stdout +++ b/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution_bifs/proxy-1..stdout @@ -1,5 +1,7 @@ +got distributed event hrw, 0 +got distributed event hrw, 1 got distributed event hrw, 2 -got distributed event hrw, 42 +got distributed event hrw, 3 got distributed event rr, 0 got distributed event rr, 2 got distributed event rr, 13 diff --git a/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution_bifs/proxy-2..stdout b/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution_bifs/proxy-2..stdout index 4f2bbbcea9..a83f3f7394 100644 --- a/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution_bifs/proxy-2..stdout +++ b/testing/btest/Baseline/scripts.base.frameworks.cluster.topic_distribution_bifs/proxy-2..stdout @@ -1,8 +1,6 @@ -got distributed event hrw, 0 -got distributed event hrw, 1 -got distributed event hrw, 3 got distributed event hrw, 13 got distributed event hrw, 37 +got distributed event hrw, 42 got distributed event hrw, 101 got distributed event rr, 1 got distributed event rr, 3 diff --git a/testing/btest/Baseline/scripts.base.utils.hash_hrw/output b/testing/btest/Baseline/scripts.base.utils.hash_hrw/output index 94ef962584..2c37b5b752 100644 --- a/testing/btest/Baseline/scripts.base.utils.hash_hrw/output +++ b/testing/btest/Baseline/scripts.base.utils.hash_hrw/output @@ -8,18 +8,18 @@ T F [id=0, user_data=alice] [id=3, user_data=dave] -[id=4, user_data=eve] -[id=4, user_data=eve] +[id=3, user_data=dave] +[id=0, user_data=alice] +[id=0, user_data=alice] [id=4, user_data=eve] [id=0, user_data=alice] -[id=3, user_data=dave] [id=1, user_data=bob] [id=0, user_data=alice] [id=1, user_data=bob] T -[id=4, user_data=eve] [id=3, user_data=dave] -[id=4, user_data=eve] +[id=3, user_data=dave] +[id=3, user_data=dave] [id=4, user_data=eve] [id=4, user_data=eve] [id=4, user_data=eve] @@ -30,11 +30,11 @@ T T [id=0, user_data=alice] [id=3, user_data=dave] -[id=4, user_data=eve] -[id=4, user_data=eve] -[id=4, user_data=eve] -[id=0, user_data=alice] [id=3, user_data=dave] +[id=0, user_data=alice] +[id=0, user_data=alice] +[id=4, user_data=eve] +[id=0, user_data=alice] [id=1, user_data=bob] [id=0, user_data=alice] [id=1, user_data=bob]