Skip to content

Commit 4712a25

Browse files
Alan-Jowettelazarg
authored andcommitted
PR feedback
Signed-off-by: Alan Jowett <[email protected]>
1 parent c77de33 commit 4712a25

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

Diff for: src/crab/ebpf_transformer.cpp

+6-18
Original file line numberDiff line numberDiff line change
@@ -942,10 +942,10 @@ void ebpf_transformer::forget_packet_pointers() {
942942
dom.initialize_packet();
943943
}
944944

945-
static void overflow_bounds(NumAbsDomain& inv, variable_t lhs, number_t span, int finite_width, bool issigned) {
945+
static void overflow_bounds(NumAbsDomain& inv, variable_t lhs, int finite_width, bool issigned) {
946946
using namespace crab::dsl_syntax;
947947
auto interval = inv[lhs];
948-
if (interval.ub() - interval.lb() >= span) {
948+
if (interval.size() >= interval_t::unsigned_int(finite_width).size()) {
949949
// Interval covers the full space.
950950
inv -= lhs;
951951
return;
@@ -980,21 +980,11 @@ static void overflow_bounds(NumAbsDomain& inv, variable_t lhs, number_t span, in
980980
}
981981

982982
static void overflow_signed(NumAbsDomain& inv, const variable_t lhs, const int finite_width) {
983-
const auto span{finite_width == 64 ? number_t{std::numeric_limits<uint64_t>::max()}
984-
: finite_width == 32 ? number_t{std::numeric_limits<uint32_t>::max()}
985-
: finite_width == 16 ? number_t{std::numeric_limits<uint16_t>::max()}
986-
: finite_width == 8 ? number_t{std::numeric_limits<uint8_t>::max()}
987-
: throw std::exception()};
988-
overflow_bounds(inv, lhs, span, finite_width, true);
983+
overflow_bounds(inv, lhs, finite_width, true);
989984
}
990985

991986
static void overflow_unsigned(NumAbsDomain& inv, const variable_t lhs, const int finite_width) {
992-
const auto span{finite_width == 64 ? number_t{std::numeric_limits<uint64_t>::max()}
993-
: finite_width == 32 ? number_t{std::numeric_limits<uint32_t>::max()}
994-
: finite_width == 16 ? number_t{std::numeric_limits<uint16_t>::max()}
995-
: finite_width == 8 ? number_t{std::numeric_limits<uint8_t>::max()}
996-
: throw std::exception()};
997-
overflow_bounds(inv, lhs, span, finite_width, false);
987+
overflow_bounds(inv, lhs, finite_width, false);
998988
}
999989
static void apply_signed(NumAbsDomain& inv, const binop_t& op, const variable_t xs, const variable_t xu,
1000990
const variable_t y, const number_t& z, const int finite_width) {
@@ -1550,13 +1540,11 @@ void ebpf_transformer::do_store_stack(NumAbsDomain& inv, const linear_expression
15501540
} else {
15511541
if ((width == 1 || width == 2 || width == 4) && type_inv.get_type(m_inv, val_type) == T_NUM) {
15521542
// Keep track of numbers on the stack that might be used as array indices.
1553-
auto stack_svalue = stack.store(inv, data_kind_t::svalues, addr, width, val_svalue);
1554-
auto stack_uvalue = stack.store(inv, data_kind_t::uvalues, addr, width, val_uvalue);
1555-
if (stack_svalue.has_value()) {
1543+
if (const auto stack_svalue = stack.store(inv, data_kind_t::svalues, addr, width, val_svalue)) {
15561544
inv.assign(stack_svalue, val_svalue);
15571545
overflow_signed(inv, *stack_svalue, width * 8);
15581546
}
1559-
if (stack_uvalue.has_value()) {
1547+
if (const auto stack_uvalue = stack.store(inv, data_kind_t::uvalues, addr, width, val_uvalue)) {
15601548
inv.assign(stack_uvalue, val_uvalue);
15611549
overflow_unsigned(inv, *stack_uvalue, width * 8);
15621550
}

0 commit comments

Comments
 (0)