Commit 83776b63 authored by Kristof Szabados's avatar Kristof Szabados
Browse files

reduced the scope of some of the variables


Signed-off-by: Kristof Szabados's avatarkristof <Kristof.Szabados@ericsson.com>
parent 8bbe456e
......@@ -139,12 +139,12 @@ JNIEXPORT void JNICALL Java_org_eclipse_titan_executor_jni_JNIMiddleWare_configu
// Fix for TR HO56282.
if (!Jnimw::userInterface)
return;
jboolean iscopy;
if (config_file == NULL || env->GetStringLength( config_file ) == 0 ) {
// use config string, which was generated by MainController
MainController::configure(Jnimw::mycfg.config_read_buffer);
}
else {
jboolean iscopy;
const char *conf_file = env->GetStringUTFChars(config_file, &iscopy);
MainController::configure(conf_file);
env->ReleaseStringUTFChars(config_file, conf_file);
......
......@@ -340,8 +340,8 @@ char* QuadInterval::generate_hex_interval(unsigned char source,
return res;
}
bool alt = false;
if (hi > 0) {
bool alt = false;
if (s_lo != 'A') {
res = mputprintf(res, "%c[%c-P]", s_hi, s_lo);
s_hi++;
......@@ -593,9 +593,8 @@ void QuadSet::do_negate() {
}
void QuadSet::add_negate_interval(const Quad& q1, const Quad& q2) {
unsigned int w;
if (q2 >= q1) {
w = q2.get_value() - q1.get_value();
unsigned int w = q2.get_value() - q1.get_value();
if (w > 0)
add(new QuadInterval(q1, q2));
else {
......
File mode changed from 100755 to 100644
......@@ -261,9 +261,9 @@ namespace Common {
va_list args)
{
if (!suppress_context) print_context(stderr);
Location my_location;
if (tail != 0 && loc && loc->get_filename() == 0) {
// borrow location information from the innermost context
Location my_location;
my_location.set_location( *(tail->location) );
loc = &my_location;
}
......
......@@ -201,14 +201,13 @@ int_val_t int_val_t::operator+(const int_val_t& right) const
// the beginning.
bool a_neg = is_negative();
bool b_neg = right.is_negative();
bool r_neg = a_neg && b_neg;
if (!a_neg && b_neg) return operator-(-right);
if (a_neg && !b_neg) return right.operator-(-(*this));
if (native_flag) {
long long result_;
if (right.is_native()) {
unsigned long long result = val.native + right.get_val();
result_ = val.native + right.get_val();
long long result_ = val.native + right.get_val();
bool r_neg = a_neg && b_neg;
if (static_cast<long long>(result) != result_ ||
(!r_neg && result_ < 0) || (r_neg && result_ > 0)) {
// We can safely assume that the sum of two non-negative long long
......
......@@ -256,8 +256,8 @@ void Type::parse_attributes()
if ((hasVariantAttrs())
&& (enable_text() || enable_raw() || enable_xer())) {
#ifndef NDEBUG
const char *fn = get_fullname().c_str();
if (rawAST_debug) {
const char *fn = get_fullname().c_str();
fprintf(stderr, "parse_attributes for %s\n", fn);
}
#endif
......@@ -2069,11 +2069,10 @@ void Type::chk_xer() { // XERSTUFF semantic check
if (ownertype==OT_TYPE_DEF
||ownertype==OT_COMP_FIELD
||ownertype==OT_RECORD_OF) {
XerAttributes *newx = 0;
if (is_ref()) {
// Merge XER attributes from the referenced type.
// This implements X.693amd1 clause 15.1.2
newx = new XerAttributes;
XerAttributes * newx = new XerAttributes;
Type *t1 = get_type_refd();
// chk_refd() (called by chk() for T_REFD) does not check
// the referenced type; do it now. This makes it fully recursive.
......
......@@ -541,9 +541,9 @@ namespace Common {
void CTs_EE_CTs::chk_tags_seq_comp(TagCollection& coll, CompField *cf,
bool is_mandatory)
{
Type *type = cf->get_type();
bool is_empty = coll.isEmpty();
if (!is_mandatory || !is_empty) {
Type *type = cf->get_type();
if (type->has_multiple_tags()) {
Error_Context cntxt(type, "While checking tags of component `%s'",
cf->get_name().get_dispname().c_str());
......
......@@ -1622,8 +1622,8 @@ static void check_special_chars(const struct makefile_struct *makefile)
static void add_base_dir(struct makefile_struct *makefile,
const char *dir_name, boolean has_modules)
{
struct base_dir_struct *base_dir;
if (dir_name != NULL) {
struct base_dir_struct *base_dir;
size_t i;
for (i = 0; i < makefile->nBaseDirs; i++) {
base_dir = makefile->BaseDirs + i;
......@@ -1919,7 +1919,6 @@ static void print_makefile(struct makefile_struct *makefile)
size_t i;
char *user_info;
const char* cxx;
const char* cpp;
const char *rm_command = makefile->gnu_make ? "$(RM)" : "rm -f";
FILE *fp;
boolean run_compiler = (makefile->nASN1Modules > 0)
......@@ -2103,6 +2102,7 @@ static void print_makefile(struct makefile_struct *makefile)
if (makefile->preprocess || makefile->ttcn3preprocessor) {
const char* cpp;
if (makefile->ttcn3preprocessor) {
cpp = makefile->ttcn3preprocessor;
} else {
......
......@@ -1592,8 +1592,8 @@ char *generate_raw_coding_negtest(char *src, const struct_def *sdef,
taglist_idx < cur_choice->nElements; ++taglist_idx) {
rawAST_coding_field_list *fields = cur_choice->fields + taglist_idx;
for (field_idx = 0; field_idx < fields->nElements; ++field_idx) {
rawAST_coding_fields *field = fields->fields + field_idx;
if (field_idx == 0) {
rawAST_coding_fields *field = fields->fields + field_idx;
src = mputprintf(src,
" if (idx_map[%d] < 0) {\n"
" negtest_confl_crosstag = TRUE;\n"
......
......@@ -2692,7 +2692,7 @@ bool SubType::add_ttcn_length(Ttcn::LengthRestriction *lr, size_t restriction_in
{
string s;
lr->append_stringRepr(s);
Value *lower=NULL,*upper=NULL;
Value *lower=NULL;
lr->set_my_scope(my_owner->get_my_scope());
lr->set_fullname(my_owner->get_fullname()+".<length_restriction_"+Int2string(restriction_index)+">");
lr->chk(Type::EXPECTED_CONSTANT);
......@@ -2700,7 +2700,7 @@ bool SubType::add_ttcn_length(Ttcn::LengthRestriction *lr, size_t restriction_in
if (!lower->get_my_scope()) FATAL_ERROR("no scope");
if (lower->get_valuetype() != Value::V_INT) return false;
if (lr->get_is_range()) {
upper = lr->get_upper_value();
Value *upper = lr->get_upper_value();
if (upper) {//HAS_UPPER
if (upper->get_valuetype()!=Value::V_INT) return false;
if (!upper->get_my_scope()) upper->set_my_scope(my_owner->get_my_scope());
......
......@@ -336,14 +336,13 @@ int main(int argc, char *argv[])
// Leave it relative.
if (!input_dir) input_dir = ".";
if (!output_file) output_file = "output.info";
std::string xsd_file_str;
if (!xsd_file) {
const char *ttcn3_dir = getenv("TTCN3_DIR");
if (!ttcn3_dir) {
std::cerr << "$TTCN3_DIR environment variable is not set" << std::endl;
param_error = true;
} else {
xsd_file_str = std::string(ttcn3_dir) + P_SEP + std::string("include") + P_SEP + std::string("tcov.xsd");
std::string xsd_file_str = std::string(ttcn3_dir) + P_SEP + std::string("include") + P_SEP + std::string("tcov.xsd");
xsd_file = xsd_file_str.c_str();
}
}
......
......@@ -4316,9 +4316,9 @@ namespace Ttcn {
size_t min_fps = nof_base_fps;
if (nof_local_fps < nof_base_fps) min_fps = nof_local_fps;
for (size_t i = 0; i < min_fps; i++) {
FormalPar *base_fp = base_fpl->get_fp_byIndex(i);
FormalPar *local_fp = fp_list->get_fp_byIndex(i);
if (local_fp->has_notused_defval()) {
FormalPar *base_fp = base_fpl->get_fp_byIndex(i);
if (base_fp->has_defval()) {
local_fp->set_defval(base_fp->get_defval());
} else {
......@@ -8398,9 +8398,9 @@ namespace Ttcn {
}
}
Ttcn::Template * body = actual_par->get_Template();
if (exp_val == Type::EXPECTED_STATIC_VALUE
||exp_val == Type::EXPECTED_CONSTANT) {
Ttcn::Template * body = actual_par->get_Template();
chk_defpar_template(body, exp_val);
}
// Rip out the type, derived ref and template from actual_par
......@@ -9949,7 +9949,6 @@ namespace Ttcn {
if (copy_needed) FATAL_ERROR("ActualPar::generate_code()");
bool is_restricted_template = gen_restriction_check != TR_NONE ||
gen_post_restriction_check != TR_NONE;
Common::Assignment *ass = ref->get_refd_assignment();
bool is_template_par = false;
Type* actual_par_type = NULL;
Type* formal_par_type = NULL;
......@@ -9961,6 +9960,7 @@ namespace Ttcn {
formal_par->get_asstype() == Common::Assignment::A_PAR_TEMPL_OUT) {
is_template_par = true;
}
Common::Assignment *ass = ref->get_refd_assignment();
actual_par_type = ass->get_Type()->get_field_type(ref->get_subrefs(),
is_template_par ? Type::EXPECTED_TEMPLATE : Type::EXPECTED_DYNAMIC_VALUE)->
get_type_refd_last();
......
......@@ -692,8 +692,6 @@ namespace Ttcn {
map< size_t, dynamic_array<field_err_t> > embedded_fld_array_m; // used for recursive calls
for (size_t i=0; i<fld_array.size(); i++) {
field_err_t& act_field_err = fld_array[i];
ErroneousAttributeSpec::indicator_t act_indicator = act_field_err.err_attr->get_indicator();
bool is_omit = act_field_err.err_attr->get_is_omit();
if (act_field_err.subrefs_array.size()<1) FATAL_ERROR("ErroneousAttributes::build_descr_tree()");
size_t fld_idx = act_field_err.subrefs_array[0];
if (omit_before_qual && (err_descr->omit_before!=-1) && (err_descr->omit_before>(int)fld_idx)) {
......@@ -708,6 +706,8 @@ namespace Ttcn {
act_field_err.qualifier->get_stringRepr().c_str(), omit_after_qual->get_stringRepr().c_str());
continue;
}
ErroneousAttributeSpec::indicator_t act_indicator = act_field_err.err_attr->get_indicator();
bool is_omit = act_field_err.err_attr->get_is_omit();
if (act_field_err.subrefs_array.size()==1) { // erroneous value
if (act_field_err.type_array.size()!=1) FATAL_ERROR("ErroneousAttributes::build_descr_tree()");
if ((act_field_err.type_array[0]->get_typetype()==Type::T_SET_A) &&
......
......@@ -431,7 +431,7 @@ char *make_posix_str_code(const char *pat, bool cs)
Free(mod_token);
if (posix_str == NULL) FATAL_ERROR("make_posix_str_code()");
size_t len = mstrlen(posix_str), skip = 0;
size_t len = mstrlen(posix_str);
if (maybe_fixed) { // maybe we can do fixed strings
*ret_val = 'F'; // "fixed"
......@@ -439,6 +439,7 @@ char *make_posix_str_code(const char *pat, bool cs)
ret_val = mputstrn(ret_val, posix_str + 2, len - 6);
}
else { // no fixed-string optimization possible
size_t skip = 0;
// TEXT decoder optimization
if (len > 3) {
if (!memcmp(posix_str + (len - 3), ".*$", 3)) {
......
......@@ -2767,9 +2767,9 @@ end:
switch (templatetype) {
case NAMED_TEMPLATE_LIST:
for (size_t i = 0;i < u.named_templates->get_nof_nts(); i++) {
Template* tmpl = u.named_templates->get_nt_byIndex(i)->get_template();
const string& name =
u.named_templates->get_nt_byIndex(i)->get_name().get_name();
NamedTemplate *nt = u.named_templates->get_nt_byIndex(i);
Template* tmpl = nt->get_template();
const string& name = nt->get_name().get_name();
if (!checked_map.has_key(name)) {
bool nrc = tmpl->chk_restriction(definition_name, TR_OMIT, usage_loc);
needs_runtime_check = needs_runtime_check || nrc;
......@@ -4068,21 +4068,14 @@ compile_time:
char *Template::generate_code_init_se(char *str, const char *name)
{ // named template list
size_t nof_nts = u.named_templates->get_nof_nts();
Type *type = my_governor->get_type_refd_last();
if (type->get_nof_comps() > 0) {
size_t nof_nts = u.named_templates->get_nof_nts();
for (size_t i = 0; i < nof_nts; i++) {
NamedTemplate *nt = u.named_templates->get_nt_byIndex(i);
const Identifier& fieldname = nt->get_name();
const char *fieldname_str = 0;
string at("AT_");
if (type->get_typetype()==Type::T_ANYTYPE) {
at += fieldname.get_name();
fieldname_str = at.c_str();
}
else {
fieldname_str = fieldname.get_name().c_str();
}
const char *fieldname_str = mprintf("%s%s",
type->get_typetype()==Type::T_ANYTYPE ? "AT_" : "", fieldname.get_name().c_str());
Template *t = nt->get_template();
if (t->needs_temp_ref()) {
Type *field_type;
......
......@@ -234,7 +234,6 @@ int Base_Type::begin_xml(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf,
unsigned int& flavor, int indent, boolean empty,
collector_fn collector, const char *type_atr, unsigned int flavor2) const
{
const int indenting = !is_canonical(flavor);
const int exer = is_exer(flavor);
int omit_tag = (indent != 0) // can never omit the tag at the toplevel
&& ( ((flavor & XER_RECOF) // can remove the tag even if not EXER
......@@ -243,24 +242,18 @@ int Base_Type::begin_xml(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf,
&& ( (p_td.xer_bits & (UNTAGGED|ANY_ATTRIBUTES|ANY_ELEMENT))
|| (flavor & (EMBED_VALUES|XER_LIST|ANY_ATTRIBUTES|USE_NIL|USE_TYPE_ATTR)))));
// If a default namespace is in effect (uri but no prefix) and the type
// is unqualified, the default namespace must be canceled; otherwise
// an XML tag without a ns prefix looks like it belongs to the def.namespace
const boolean empty_ns_hack = exer && !omit_tag && (indent > 0)
&& (p_td.xer_bits & FORM_UNQUALIFIED)
&& (flavor & DEF_NS_PRESENT);
if (exer && (p_td.xer_bits & XER_ATTRIBUTE)) {
begin_attribute(p_td, p_buf);
}
else if (!omit_tag) { // full tag
const int indenting = !is_canonical(flavor);
if (indenting) do_indent(p_buf, indent);
p_buf.put_c('<');
if (exer) write_ns_prefix(p_td, p_buf);
const namespace_t *ns_info = NULL;
boolean namespaces_needed = FALSE;
if (exer) {
const namespace_t *ns_info = NULL;
if (p_td.my_module != NULL && p_td.ns_index != -1) {
ns_info = p_td.my_module->get_ns((size_t)p_td.ns_index);
}
......@@ -289,6 +282,13 @@ int Base_Type::begin_xml(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf,
Free(collected_ns);
}
// If a default namespace is in effect (uri but no prefix) and the type
// is unqualified, the default namespace must be canceled; otherwise
// an XML tag without a ns prefix looks like it belongs to the def.namespace
const boolean empty_ns_hack = exer && !omit_tag && (indent > 0)
&& (p_td.xer_bits & FORM_UNQUALIFIED)
&& (flavor & DEF_NS_PRESENT);
if (empty_ns_hack) {
p_buf.put_s(9, (cbyte*)" xmlns=''");
flavor &= ~DEF_NS_PRESENT;
......@@ -338,7 +338,6 @@ void Base_Type::end_xml (const XERdescriptor_t& p_td, TTCN_Buffer& p_buf,
unsigned int flavor, int indent, boolean empty) const
{
int exer = is_exer(flavor);
int indenting = !is_canonical(flavor);
boolean omit_tag = (indent != 0) // can never omit the tag at the toplevel
&& ( ((flavor & XER_RECOF) // can remove the tag even if not EXER
&& !(exer && (flavor & BXER_EMPTY_ELEM))) // except 26.6, 26.7
......@@ -351,6 +350,7 @@ void Base_Type::end_xml (const XERdescriptor_t& p_td, TTCN_Buffer& p_buf,
}
else if (!empty && !omit_tag) {
// now close the tag
int indenting = !is_canonical(flavor);
if (indenting && !(flavor & SIMPLE_TYPE)) do_indent(p_buf, indent);
p_buf.put_s(2, (cbyte*)"</");
if (exer) write_ns_prefix(p_td, p_buf);
......
......@@ -1356,7 +1356,6 @@ unsigned int xlate(cbyte*in, int phase, unsigned char*dest) {
int CHARSTRING::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
unsigned int flavor, unsigned int /*flavor2*/, embed_values_dec_struct_t*) {
int exer = is_exer(flavor);
int success = reader.Ok(), depth = -1;
if (exer && (p_td.xer_bits & XER_ATTRIBUTE)) {
const char * name = verify_name(reader, p_td, exer);
......@@ -1370,6 +1369,7 @@ int CHARSTRING::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
else {
boolean omit_tag = exer
&& (p_td.xer_bits & UNTAGGED || flavor & (EMBED_VALUES|XER_LIST|USE_TYPE_ATTR|USE_NIL));
int success = reader.Ok(), depth = -1;
for (; success == 1; success = reader.Read()) {
int type = reader.NodeType();
if (XML_READER_TYPE_ELEMENT == type) {
......
......@@ -750,7 +750,6 @@ int FLOAT::RAW_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& buff,
boolean /*first_call*/)
{
int prepaddlength = buff.increase_pos_padd(p_td.raw->prepadding);
unsigned char *dv;
limit -= prepaddlength;
int decode_length = p_td.raw->fieldlength;
if ( p_td.raw->fieldlength > limit
......@@ -780,7 +779,7 @@ int FLOAT::RAW_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& buff,
cp.hexorder = ORDER_LSB;
buff.get_b((size_t) decode_length, data, cp, top_bit_ord);
if (decode_length == 64) {
dv = (unsigned char *) &tmp;
unsigned char *dv = (unsigned char *) &tmp;
#if defined __sparc__ || defined __sparc
memcpy(dv,data,8);
#else
......
......@@ -930,7 +930,6 @@ int HEXSTRING::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
int success = reader.Ok(), depth = -1, type;
boolean own_tag = !is_exerlist(flavor) && !(exer && (p_td.xer_bits & UNTAGGED));
const char * value = 0;
if (exer && (p_td.xer_bits & XER_ATTRIBUTE)) {
const char * name = verify_name(reader, p_td, exer);
(void)name;
......@@ -970,7 +969,7 @@ int HEXSTRING::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
type = reader.NodeType();
if (success == 1 && (XML_READER_TYPE_TEXT == type || XML_READER_TYPE_ATTRIBUTE == type)) {
value = (const char *)reader.Value();
const char * value = (const char *)reader.Value();
size_t len = value ? strlen(value) : 0;
if (exer && (p_td.xer_bits & BASE_64)) {
......
......@@ -276,11 +276,11 @@ INTEGER INTEGER::operator+(const INTEGER& other_value) const
: BN_is_negative(val.openssl);
boolean other_value_neg = other_value.native_flag
? (other_value.val.native < 0) : BN_is_negative(other_value.val.openssl);
boolean result_neg = this_neg && other_value_neg;
if (!this_neg && other_value_neg) return operator-(-other_value);
if (this_neg && !other_value_neg) return other_value.operator-(-(*this));
if (likely(native_flag)) {
if (likely(other_value.native_flag)) {
boolean result_neg = this_neg && other_value_neg;
unsigned int result_u = val.native + other_value.val.native;
int result = val.native + other_value.val.native;
if ((static_cast<int>(result_u) != result) || (!result_neg &&
......@@ -1625,7 +1625,6 @@ int INTEGER::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
unsigned int flavor, unsigned int /*flavor2*/, embed_values_dec_struct_t*)
{
const boolean exer = is_exer(flavor);
int depth = -1, success = reader.Ok(), type;
const char * value = 0;
boolean own_tag = !(exer && (p_td.xer_bits & UNTAGGED)) && !is_exerlist(flavor);
......@@ -1644,6 +1643,7 @@ tagless:
// Let the caller do reader.AdvanceAttribute();
}
else {
int depth = -1, success = reader.Ok(), type;
for (; success == 1; success = reader.Read()) {
type = reader.NodeType();
if (XML_READER_TYPE_ELEMENT == type) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment