Update tgt- directories with cppcheck suggested fixes

This commit is contained in:
Cary R 2021-01-02 13:30:00 -08:00
parent 1d318c4393
commit fbe42f13e2
14 changed files with 33 additions and 34 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003-2014 Stephen Williams (steve@icarus.com) * Copyright (c) 2003-2021 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -553,7 +553,7 @@ static void lpm_show_mux(ivl_lpm_t net)
edif_cellref_t ref; edif_cellref_t ref;
edif_joint_t jnt; edif_joint_t jnt;
unsigned idx, rdx; unsigned idx;
char cellname[32]; char cellname[32];
@ -626,6 +626,7 @@ static void lpm_show_mux(ivl_lpm_t net)
} }
for (idx = 0 ; idx < wid_z ; idx += 1) { for (idx = 0 ; idx < wid_z ; idx += 1) {
unsigned rdx;
for (rdx = 0 ; rdx < wid_r ; rdx += 1) { for (rdx = 0 ; rdx < wid_r ; rdx += 1) {
unsigned pin; unsigned pin;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001-2010 Stephen Williams (steve@icarus.com) * Copyright (c) 2001-2021 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -30,9 +30,7 @@ static size_t xnf_mangle_scope_name(ivl_scope_t net, char*buf, size_t nbuf)
if (parent) { if (parent) {
cnt = xnf_mangle_scope_name(parent, buf, nbuf); cnt = xnf_mangle_scope_name(parent, buf, nbuf);
buf += cnt; buf += cnt;
nbuf -= cnt;
*buf++ = '/'; *buf++ = '/';
nbuf -= 1;
cnt += 1; cnt += 1;
} }

View File

@ -2,7 +2,7 @@
// are not used here. // are not used here.
// target_design() // target_design()
unusedFunction:stub.c:1774 unusedFunction:stub.c:1837
// target_query() // target_query()
unusedFunction:stub.c:1844 unusedFunction:stub.c:1907

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2007-2013 Stephen Williams (steve@icarus.com) * Copyright (c) 2007-2021 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -75,7 +75,7 @@ static void show_branch_access_expression(ivl_expr_t net, unsigned ind)
} }
ivl_discipline_t tb_disc = discipline_of_nexus(tb); ivl_discipline_t tb_disc = discipline_of_nexus(tb);
if (ta_disc == 0) { if (tb_disc == 0) {
fprintf(out, "%*sERROR: Reference terminal of branch has no discipline\n", fprintf(out, "%*sERROR: Reference terminal of branch has no discipline\n",
ind, ""); ind, "");
stub_errors += 1; stub_errors += 1;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000-2020 Stephen Williams (steve@icarus.com) * Copyright (c) 2000-2021 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -1427,7 +1427,7 @@ static void show_signal(ivl_signal_t net)
fprintf(out, " %s %s %s", type, sign, port); fprintf(out, " %s %s %s", type, sign, port);
show_type_of_signal(net); show_type_of_signal(net);
fprintf(out, " %s[word=%u, adr=%d] <width=%u%s> <discipline=%s> ", fprintf(out, " %s[word=%u, adr=%u] <width=%u%s> <discipline=%s> ",
ivl_signal_basename(net), ivl_signal_basename(net),
idx, ivl_signal_array_base(net)+idx, idx, ivl_signal_array_base(net)+idx,
ivl_signal_width(net), ivl_signal_width(net),

View File

@ -2,4 +2,4 @@
// are not used here. // are not used here.
// target_design() // target_design()
unusedFunction:verilog.c:408 unusedFunction:verilog.c:411

View File

@ -1,7 +1,7 @@
/* /*
* VHDL abstract syntax elements. * VHDL abstract syntax elements.
* *
* Copyright (C) 2008-2011 Nick Gasson (nick@nickg.me.uk) * Copyright (C) 2008-2021 Nick Gasson (nick@nickg.me.uk)
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -66,7 +66,7 @@ vector<vhdl_element*> vhdl_element::allocated_;
// Just a counter of total bytes allocated for statistics // Just a counter of total bytes allocated for statistics
size_t vhdl_element::total_alloc_(0); size_t vhdl_element::total_alloc_(0);
void vhdl_element::set_comment(std::string comment) void vhdl_element::set_comment(const std::string&comment)
{ {
comment_ = comment; comment_ = comment;
} }

View File

@ -1,7 +1,7 @@
/* /*
* VHDL abstract syntax elements. * VHDL abstract syntax elements.
* *
* Copyright (C) 2008 Nick Gasson (nick@nickg.me.uk) * Copyright (C) 2008-2021 Nick Gasson (nick@nickg.me.uk)
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -52,7 +52,7 @@ public:
virtual void emit(std::ostream &of, int level=0) const = 0; virtual void emit(std::ostream &of, int level=0) const = 0;
void print() const; void print() const;
void set_comment(std::string comment); void set_comment(const std::string&comment);
static int free_all_objects(); static int free_all_objects();
static size_t total_allocated(); static size_t total_allocated();

View File

@ -1,7 +1,7 @@
/* /*
* VHDL abstract syntax elements. * VHDL abstract syntax elements.
* *
* Copyright (C) 2008-2013 Nick Gasson (nick@nickg.me.uk) * Copyright (C) 2008-2021 Nick Gasson (nick@nickg.me.uk)
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -38,7 +38,7 @@ typedef set<vhdl_var_ref*> vhdl_var_set_t;
class vhdl_expr : public vhdl_element { class vhdl_expr : public vhdl_element {
public: public:
vhdl_expr(const vhdl_type* type, bool isconst=false) explicit vhdl_expr(const vhdl_type* type, bool isconst=false)
: type_(type), isconst_(isconst) {} : type_(type), isconst_(isconst) {}
virtual ~vhdl_expr(); virtual ~vhdl_expr();
@ -227,7 +227,7 @@ enum time_unit_t {
class vhdl_const_time : public vhdl_expr { class vhdl_const_time : public vhdl_expr {
public: public:
vhdl_const_time(uint64_t value, time_unit_t units = TIME_UNIT_NS) explicit vhdl_const_time(uint64_t value, time_unit_t units = TIME_UNIT_NS)
: vhdl_expr(vhdl_type::time(), true), value_(value), units_(units) {} : vhdl_expr(vhdl_type::time(), true), value_(value), units_(units) {}
void emit(std::ostream &of, int level) const; void emit(std::ostream &of, int level) const;
private: private:
@ -464,7 +464,7 @@ enum vhdl_severity_t {
class vhdl_report_stmt : public vhdl_seq_stmt { class vhdl_report_stmt : public vhdl_seq_stmt {
public: public:
vhdl_report_stmt(vhdl_expr *text, explicit vhdl_report_stmt(vhdl_expr *text,
vhdl_severity_t severity = SEVERITY_NOTE); vhdl_severity_t severity = SEVERITY_NOTE);
virtual ~vhdl_report_stmt() {} virtual ~vhdl_report_stmt() {}
@ -602,7 +602,7 @@ private:
*/ */
class vhdl_decl : public vhdl_element { class vhdl_decl : public vhdl_element {
public: public:
vhdl_decl(const string& name, const vhdl_type *type = NULL, explicit vhdl_decl(const string& name, const vhdl_type *type = NULL,
vhdl_expr *initial = NULL) vhdl_expr *initial = NULL)
: name_(name), type_(type), initial_(initial), : name_(name), type_(type), initial_(initial),
has_initial_(initial != NULL) {} has_initial_(initial != NULL) {}

View File

@ -1,7 +1,7 @@
/* /*
* VHDL variable and signal types. * VHDL variable and signal types.
* *
* Copyright (C) 2008-2013 Nick Gasson (nick@nickg.me.uk) * Copyright (C) 2008-2021 Nick Gasson (nick@nickg.me.uk)
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -188,7 +188,7 @@ vhdl_type *vhdl_type::type_for(int width, bool issigned,
return vhdl_type::nunsigned(width, lsb); return vhdl_type::nunsigned(width, lsb);
} }
vhdl_type *vhdl_type::array_of(vhdl_type *b, std::string &n, int m, int l) vhdl_type *vhdl_type::array_of(vhdl_type *b, const std::string &n, int m, int l)
{ {
return new vhdl_type(b, n, m, l); return new vhdl_type(b, n, m, l);
} }

View File

@ -1,7 +1,7 @@
/* /*
* VHDL variable and signal types. * VHDL variable and signal types.
* *
* Copyright (C) 2008-2010 Nick Gasson (nick@nickg.me.uk) * Copyright (C) 2008-2021 Nick Gasson (nick@nickg.me.uk)
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -46,7 +46,7 @@ enum vhdl_type_name_t {
class vhdl_type : public vhdl_element { class vhdl_type : public vhdl_element {
public: public:
// Scalar constructor // Scalar constructor
vhdl_type(vhdl_type_name_t name, int msb = 0, int lsb = 0) explicit vhdl_type(vhdl_type_name_t name, int msb = 0, int lsb = 0)
: name_(name), msb_(msb), lsb_(lsb), base_(NULL) {} : name_(name), msb_(msb), lsb_(lsb), base_(NULL) {}
// Array constructor // Array constructor
@ -84,7 +84,7 @@ public:
static vhdl_type *type_for(int width, bool issigned, static vhdl_type *type_for(int width, bool issigned,
int lsb=0, bool unresolved=false); int lsb=0, bool unresolved=false);
static vhdl_type *array_of(vhdl_type *b, std::string &n, int m, int l); static vhdl_type *array_of(vhdl_type *b, const std::string &n, int m, int l);
protected: protected:
vhdl_type_name_t name_; vhdl_type_name_t name_;
int msb_, lsb_; int msb_, lsb_;

View File

@ -5,4 +5,4 @@
unusedFunction:vlog95.c:59 unusedFunction:vlog95.c:59
// target_query() // target_query()
unusedFunction:vlog95.c:251 unusedFunction:vlog95.c:257

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2011-2014 Cary R. (cygcary@yahoo.com) * Copyright (C) 2011-2021 Cary R. (cygcary@yahoo.com)
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -65,7 +65,7 @@ static int32_t get_int32_from_bits(const char *bits, unsigned nbits,
// HERE: Need to emit 1 instead of -1 for some of the constants. // HERE: Need to emit 1 instead of -1 for some of the constants.
// if (is_signed && (nbits > 1) && (msb == '1') && (trim_wid < 32U)) { // if (is_signed && (nbits > 1) && (msb == '1') && (trim_wid < 32U)) {
if (is_signed && (msb == '1') && (trim_wid < 32U)) { if (is_signed && (msb == '1') && (trim_wid < 32U)) {
value |= ~(((int32_t)1 << trim_wid) - (int32_t)1); value |= ~(((uint32_t)1 << trim_wid) - (uint32_t)1);
} }
*result_type = 0; *result_type = 0;
return value; return value;
@ -309,7 +309,7 @@ int64_t get_int64_from_number(ivl_expr_t expr, int *result_type)
} }
/* Sign extend as needed. */ /* Sign extend as needed. */
if (is_signed && (msb == '1') && (trim_wid < 64U)) { if (is_signed && (msb == '1') && (trim_wid < 64U)) {
value |= ~(((int64_t)1 << trim_wid) - (int64_t)1); value |= ~(((uint64_t)1 << trim_wid) - (uint64_t)1);
} }
*result_type = 0; *result_type = 0;
return value; return value;

View File

@ -2,7 +2,7 @@
// are not used here. // are not used here.
// target_design() // target_design()
unusedFunction:vvp.c:148 unusedFunction:vvp.c:152
// target_query() // target_query()
unusedFunction:vvp.c:246 unusedFunction:vvp.c:250