diff --git a/tgt-vhdl/expr.cc b/tgt-vhdl/expr.cc index 555a50f43..744ed5537 100644 --- a/tgt-vhdl/expr.cc +++ b/tgt-vhdl/expr.cc @@ -1,7 +1,7 @@ /* * VHDL code generation for expressions. * - * Copyright (C) 2008-2009 Nick Gasson (nick@nickg.me.uk) + * Copyright (C) 2008-2011 Nick Gasson (nick@nickg.me.uk) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -313,8 +313,10 @@ static vhdl_expr *translate_binary(ivl_expr_t e) return NULL; vhdl_expr *rhs = translate_expr(ivl_expr_oper2(e)); - if (NULL == rhs) + if (NULL == rhs) { + delete lhs; return NULL; + } int lwidth = lhs->get_type()->get_width(); int rwidth = rhs->get_type()->get_width(); diff --git a/tgt-vhdl/vhdl_element.cc b/tgt-vhdl/vhdl_element.cc index 8d5bdcb44..e7e0957b6 100644 --- a/tgt-vhdl/vhdl_element.cc +++ b/tgt-vhdl/vhdl_element.cc @@ -1,7 +1,7 @@ /* * VHDL abstract syntax elements. * - * Copyright (C) 2008 Nick Gasson (nick@nickg.me.uk) + * Copyright (C) 2008-2011 Nick Gasson (nick@nickg.me.uk) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -79,7 +79,7 @@ void vhdl_element::set_comment(std::string comment) void vhdl_element::emit_comment(std::ostream &of, int level, bool end_of_line) const { - if (comment_.size() > 0) { + if (! comment_.empty()) { if (end_of_line) of << " -- " << comment_; else { diff --git a/tgt-vhdl/vhdl_syntax.cc b/tgt-vhdl/vhdl_syntax.cc index 747717e24..a55902de8 100644 --- a/tgt-vhdl/vhdl_syntax.cc +++ b/tgt-vhdl/vhdl_syntax.cc @@ -1,7 +1,7 @@ /* * VHDL abstract syntax elements. * - * Copyright (C) 2008-2010 Nick Gasson (nick@nickg.me.uk) + * Copyright (C) 2008-2011 Nick Gasson (nick@nickg.me.uk) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -230,7 +230,7 @@ void vhdl_process::emit(std::ostream &of, int level) const newline(of, level); emit_comment(of, level); - if (name_.size() > 0) + if (! name_.empty()) of << name_ << ": "; of << "process "; @@ -315,7 +315,7 @@ void vhdl_comp_inst::emit(std::ostream &of, int level) const of << inst_name_ << ": " << comp_name_; // If there are no ports or generics we don't need to mention them... - if (mapping_.size() > 0) { + if (! mapping_.empty()) { newline(of, indent(level)); of << "port map ("; @@ -362,7 +362,7 @@ void vhdl_component_decl::emit(std::ostream &of, int level) const emit_comment(of, level); of << "component " << name_ << " is"; - if (ports_.size() > 0) { + if (! ports_.empty()) { newline(of, indent(level)); of << "port ("; emit_children(of, ports_, indent(level), ";"); @@ -956,7 +956,7 @@ void vhdl_binop_expr::emit(std::ostream &of, int level) const { open_parens(of); - assert(operands_.size() > 0); + assert(! operands_.empty()); std::list::const_iterator it = operands_.begin(); (*it)->emit(of, level); diff --git a/tgt-vvp/vvp.c b/tgt-vvp/vvp.c index 38f8203c7..07c946695 100644 --- a/tgt-vvp/vvp.c +++ b/tgt-vvp/vvp.c @@ -59,7 +59,7 @@ __inline__ static void draw_execute_header(ivl_design_t des) } fprintf(vvp_out, ":ivl_version \"" VERSION "\""); /* I am assuming that a base release will have a blank tag. */ - if (strcmp(VERSION_TAG, "") != 0) { + if (*VERSION_TAG != 0) { fprintf(vvp_out, " \"(" VERSION_TAG ")\""); } fprintf(vvp_out, ";\n"); diff --git a/vvp/array.cc b/vvp/array.cc index 0dd77eb64..2d0be3155 100644 --- a/vvp/array.cc +++ b/vvp/array.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2010 Stephen Williams (steve@icarus.com) + * Copyright (c) 2007-2011 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -1440,7 +1440,9 @@ void array_word_change(vvp_array_t array, unsigned long addr) class array_resolv_list_t : public resolv_list_s { public: - explicit array_resolv_list_t(char*lab) : resolv_list_s(lab) { } + explicit array_resolv_list_t(char*lab) : resolv_list_s(lab) { + array = 0; + } vvp_array_t*array; bool resolve(bool mes); diff --git a/vvp/compile.cc b/vvp/compile.cc index 5c2aec1f4..1b7b6dcde 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -405,7 +405,9 @@ void postpone_functor_input(vvp_net_ptr_t port, char*lab) */ struct functor_gen_resolv_list_s: public resolv_list_s { - explicit functor_gen_resolv_list_s(char*txt) : resolv_list_s(txt) { } + explicit functor_gen_resolv_list_s(char*txt) : resolv_list_s(txt) { + ref = 0; + } vvp_net_t**ref; virtual bool resolve(bool mes); }; diff --git a/vvp/vvp_net.cc b/vvp/vvp_net.cc index eb55d3b68..ca55be7db 100644 --- a/vvp/vvp_net.cc +++ b/vvp/vvp_net.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2010 Stephen Williams (steve@icarus.com) + * Copyright (c) 2004-2011 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -2652,7 +2652,7 @@ vvp_vector8_t::vvp_vector8_t(const vvp_vector8_t&that) { size_ = that.size_; if (size_ <= sizeof val_) { - ptr_ = that.ptr_; + memcpy(val_, that.val_, sizeof val_); } else { ptr_ = new unsigned char[size_]; memcpy(ptr_, that.ptr_, size_); diff --git a/vvp/vvp_net.h b/vvp/vvp_net.h index ce9aed357..112a9bc7c 100644 --- a/vvp/vvp_net.h +++ b/vvp/vvp_net.h @@ -1,7 +1,7 @@ #ifndef __vvp_net_H #define __vvp_net_H /* - * Copyright (c) 2004-2010 Stephen Williams (steve@icarus.com) + * Copyright (c) 2004-2011 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -924,8 +924,7 @@ inline vvp_vector8_t::vvp_vector8_t(unsigned size__) : size_(size__) { if (size_ <= sizeof val_) { - // This should set all the bytes of val_ to 0 - ptr_ = 0; + memset(val_, 0, sizeof val_); } else { ptr_ = new unsigned char[size_]; memset(ptr_, 0, size_);