mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Switch some internal enum values to unsigned
This commit is contained in:
parent
3ab16e7adc
commit
c2caa9e6a1
3 changed files with 12 additions and 6 deletions
|
@ -142,9 +142,7 @@ bool CompositeHash::RecoverOneVal(const HashKey& hk, Type* t, ValPtr* pval, bool
|
|||
zeek_int_t i;
|
||||
hk.Read("int", i);
|
||||
|
||||
if ( tag == TYPE_ENUM )
|
||||
*pval = t->AsEnumType()->GetEnumVal(i);
|
||||
else if ( tag == TYPE_BOOL )
|
||||
if ( tag == TYPE_BOOL )
|
||||
*pval = val_mgr->Bool(i);
|
||||
else if ( tag == TYPE_INT )
|
||||
*pval = val_mgr->Int(i);
|
||||
|
@ -164,6 +162,8 @@ bool CompositeHash::RecoverOneVal(const HashKey& hk, Type* t, ValPtr* pval, bool
|
|||
|
||||
case TYPE_PORT: *pval = val_mgr->Port(u); break;
|
||||
|
||||
case TYPE_ENUM: *pval = t->AsEnumType()->GetEnumVal(static_cast<int>(u)); break;
|
||||
|
||||
default:
|
||||
reporter->InternalError("bad internal unsigned int in CompositeHash::RecoverOneVal()");
|
||||
*pval = nullptr;
|
||||
|
|
|
@ -1548,6 +1548,12 @@ void EnumType::CheckAndAddName(const string& module_name, const char* name, zeek
|
|||
return;
|
||||
}
|
||||
|
||||
if ( val > std::numeric_limits<::zeek_int_t>::max() ) {
|
||||
reporter->Error("enumerator value cannot be greater than max int");
|
||||
SetError();
|
||||
return;
|
||||
}
|
||||
|
||||
auto fullname = detail::make_full_var_name(module_name.c_str(), name);
|
||||
auto id = id::find(fullname);
|
||||
|
||||
|
|
|
@ -110,11 +110,11 @@ constexpr InternalTypeTag to_internal_type_tag(TypeTag tag) noexcept {
|
|||
case TYPE_VOID: return TYPE_INTERNAL_VOID;
|
||||
|
||||
case TYPE_BOOL:
|
||||
case TYPE_INT:
|
||||
case TYPE_ENUM: return TYPE_INTERNAL_INT;
|
||||
case TYPE_INT: return TYPE_INTERNAL_INT;
|
||||
|
||||
case TYPE_COUNT:
|
||||
case TYPE_PORT: return TYPE_INTERNAL_UNSIGNED;
|
||||
case TYPE_PORT:
|
||||
case TYPE_ENUM: return TYPE_INTERNAL_UNSIGNED;
|
||||
|
||||
case TYPE_DOUBLE:
|
||||
case TYPE_TIME:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue