From 9d97f1e5402c595d6ef76ebfad9f57c33f033864 Mon Sep 17 00:00:00 2001 From: Botond Baranyi <botond.baranyi@ericsson.com> Date: Tue, 3 Apr 2018 16:30:47 +0200 Subject: [PATCH] Revert "Fixed RAW encoding of -2147483648 (bug 533067)" This reverts commit c746cc2da07e1089b0a293045fbd77d31016aef1. --- core/Integer.cc | 2 +- core/RAW.cc | 7 ++----- core/RAW.hh | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/core/Integer.cc b/core/Integer.cc index 42e5eb984..1301fae04 100644 --- a/core/Integer.cc +++ b/core/Integer.cc @@ -1177,7 +1177,7 @@ int INTEGER::RAW_encode(const TTCN_Typedescriptor_t& p_td, RAW_enc_tree& myleaf) } else { // not IntX, use the field length length = (p_td.raw->fieldlength + 7) / 8; - if (min_bits(value, neg_sgbit) > p_td.raw->fieldlength) { + if (min_bits(value) > p_td.raw->fieldlength) { TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_LEN_ERR, "There are insufficient bits to encode '%s' : ", p_td.name); value = 0; // substitute with zero diff --git a/core/RAW.cc b/core/RAW.cc index 80d218084..3a220ae71 100644 --- a/core/RAW.cc +++ b/core/RAW.cc @@ -309,16 +309,13 @@ RAW_enc_tree* RAW_enc_tree::get_node(RAW_enc_tr_pos &req_pos) * @return the number of bits needed to represent the given integer * in sign+magnitude */ -int min_bits(int a, bool signbit) +int min_bits(int a) { - if (a == INT_MIN) { - return sizeof(int) * 8 + signbit; - } register int bits = 0; register int tmp = a; if (a < 0) { bits = 1; - tmp = -a; // doesn't work on INT_MIN + tmp = -a; } while (tmp != 0) { bits++; diff --git a/core/RAW.hh b/core/RAW.hh index 6c32d68f7..410566776 100644 --- a/core/RAW.hh +++ b/core/RAW.hh @@ -52,7 +52,7 @@ extern const unsigned char BitMaskTable[9]; class RAW_enc_tree; struct TTCN_Typedescriptor_t; struct TTCN_TEXTdescriptor_t; -int min_bits(int a, bool signbit); +int min_bits(int a); int min_bits(BIGNUM *a); enum ext_bit_t{ EXT_BIT_NO, /**< No extension bit */ -- GitLab