Fix port/enum values SizeOf not being a count

Really, they both should be count. But, they were getting provided as an
integer. Port is easy since it is backed by an unsigned value. Enums
*should* be unsigned, but aren't. This doesn't address that, it just
takes the other name for this operator (absolute value) and makes the
enum value positive if it's negative.

This fixes a case where using the size of operator on enum/port values
in certain contexts (like the default parameter of a struct) would cause
an internal error.
This commit is contained in:
Evan Typanski 2024-09-17 10:55:45 -04:00
parent ba91de59b0
commit d3dd8a155d
4 changed files with 29 additions and 3 deletions

View file

@ -1,2 +1,2 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
expression warning in <...>/sizeof.zeek, line 73: count underflow (5 - 9)
expression warning in <...>/sizeof.zeek, line 83: count underflow (5 - 9)

View file

@ -7,11 +7,13 @@ Expr: 18446744073709551612
Signed Expr: 4
Double -1.23: 1.230000
Enum ENUM3: 2
Enum in record: 2 2
File 21.000000
Function add_interface: 2
Integer -10: 10
Interval -5.0 secs: 5.000000
Port 80/tcp: 65616
Port in record: 65616 65616
Record [i=10, j=<uninitialized>, k=<uninitialized>]: 3
Set: 3
String 'Hello': 5