Fix some initialization problem found with cppcheck.
This patch adds a few missing initializations to various constructors and reworks the realloc() error handling code in driver-vpi/main.c.
This commit is contained in:
parent
cb86fb15bf
commit
eb525b6c2a
|
|
@ -154,12 +154,15 @@ static int startsWith (char *prefix, char *str)
|
||||||
|
|
||||||
static void appendn (char **ptr, char *app, int count)
|
static void appendn (char **ptr, char *app, int count)
|
||||||
{
|
{
|
||||||
*ptr = (char *) realloc(*ptr,strlen(*ptr)+(count?count:strlen(app))+1);
|
char *nptr = (char *) realloc(*ptr, strlen(*ptr) +
|
||||||
|
(count?count:strlen(app)) + 1);
|
||||||
|
|
||||||
if (*ptr == NULL) {
|
if (nptr == NULL) {
|
||||||
fprintf(stderr,"error: out of memory\n");
|
fprintf(stderr,"error: out of memory\n");
|
||||||
|
free(*ptr);
|
||||||
myExit(4);
|
myExit(4);
|
||||||
}
|
}
|
||||||
|
*ptr = nptr;
|
||||||
|
|
||||||
if (count)
|
if (count)
|
||||||
strncat(*ptr,app,count);
|
strncat(*ptr,app,count);
|
||||||
|
|
@ -187,12 +190,14 @@ static void appendBackSlash(char **str)
|
||||||
|
|
||||||
static void assignn (char **ptr, char *str, int count)
|
static void assignn (char **ptr, char *str, int count)
|
||||||
{
|
{
|
||||||
*ptr = (char *) realloc(*ptr,(count?count:strlen(str))+1);
|
char *nptr = (char *) realloc(*ptr, (count?count:strlen(str)) + 1);
|
||||||
|
|
||||||
if (*ptr == NULL) {
|
if (nptr == NULL) {
|
||||||
fprintf(stderr,"error: out of memory\n");
|
fprintf(stderr,"error: out of memory\n");
|
||||||
|
free(*ptr);
|
||||||
myExit(4);
|
myExit(4);
|
||||||
}
|
}
|
||||||
|
*ptr = nptr;
|
||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
strncpy(*ptr,str,count);
|
strncpy(*ptr,str,count);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000-2008 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2000-2010 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
|
||||||
|
|
@ -40,6 +40,7 @@ NetModulo::NetModulo(NetScope*s, perm_string n, unsigned wr,
|
||||||
pin(0).set_dir(Link::OUTPUT); // Result
|
pin(0).set_dir(Link::OUTPUT); // Result
|
||||||
pin(1).set_dir(Link::INPUT); // DataA
|
pin(1).set_dir(Link::INPUT); // DataA
|
||||||
pin(2).set_dir(Link::INPUT); // DataB
|
pin(2).set_dir(Link::INPUT); // DataB
|
||||||
|
signed_flag_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetModulo::~NetModulo()
|
NetModulo::~NetModulo()
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,9 @@ NetScope::NetScope(NetScope*up, const hname_t&n, NetScope::TYPE t)
|
||||||
default: /* BEGIN_END and FORK_JOIN, do nothing */
|
default: /* BEGIN_END and FORK_JOIN, do nothing */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
lineno_ = 0;
|
||||||
|
def_lineno_ = 0;
|
||||||
|
genvar_tmp_val = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetScope::~NetScope()
|
NetScope::~NetScope()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2008-2010 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
|
||||||
|
|
@ -50,6 +50,9 @@ NetTran::NetTran(NetScope*scope__, perm_string n, ivl_switch_type_t tt)
|
||||||
if (pin_count() == 3) {
|
if (pin_count() == 3) {
|
||||||
pin(2).set_dir(Link::INPUT); // Enable
|
pin(2).set_dir(Link::INPUT); // Enable
|
||||||
}
|
}
|
||||||
|
wid_ = 0;
|
||||||
|
part_ = 0;
|
||||||
|
off_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetTran::NetTran(NetScope*scope__, perm_string n, unsigned wid, unsigned part, unsigned off)
|
NetTran::NetTran(NetScope*scope__, perm_string n, unsigned wid, unsigned part, unsigned off)
|
||||||
|
|
|
||||||
68
net_udp.cc
68
net_udp.cc
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2000-2010 Stephen Williams (steve@icarus.com)
|
||||||
* Copyright (c) 2001 Stephan Boettcher <stephan@nevis.columbia.edu>
|
* Copyright (c) 2001 Stephan Boettcher <stephan@nevis.columbia.edu>
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
# include "compiler.h"
|
# include "compiler.h"
|
||||||
|
|
||||||
# include "netlist.h"
|
# include "netlist.h"
|
||||||
|
|
||||||
NetUDP::NetUDP(NetScope*s, perm_string n, unsigned pins, PUdp *u)
|
NetUDP::NetUDP(NetScope*s, perm_string n, unsigned pins, PUdp *u)
|
||||||
|
|
@ -30,56 +29,53 @@ NetUDP::NetUDP(NetScope*s, perm_string n, unsigned pins, PUdp *u)
|
||||||
for (unsigned idx = 1 ; idx < pins ; idx += 1) {
|
for (unsigned idx = 1 ; idx < pins ; idx += 1) {
|
||||||
pin(idx).set_dir(Link::INPUT);
|
pin(idx).set_dir(Link::INPUT);
|
||||||
}
|
}
|
||||||
|
table_idx = udp->tinput.count()-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetUDP::first(string&inp, char&out) const
|
bool NetUDP::first(string&inp, char&out) const
|
||||||
{
|
{
|
||||||
table_idx = (unsigned) -1;
|
table_idx = (unsigned) -1;
|
||||||
return next(inp, out);
|
return next(inp, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetUDP::next(string&inp, char&out) const
|
bool NetUDP::next(string&inp, char&out) const
|
||||||
{
|
{
|
||||||
table_idx++;
|
table_idx++;
|
||||||
|
|
||||||
if (table_idx >= udp->tinput.count())
|
if (table_idx >= udp->tinput.count()) return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
if (is_sequential())
|
if (is_sequential()) {
|
||||||
{
|
inp = string("") + udp->tcurrent[table_idx] +
|
||||||
inp = string("") + udp->tcurrent[table_idx] + udp->tinput[table_idx];
|
udp->tinput[table_idx];
|
||||||
assert(inp.length() == pin_count());
|
assert(inp.length() == pin_count());
|
||||||
}
|
} else {
|
||||||
else
|
inp = udp->tinput[table_idx];
|
||||||
{
|
assert(inp.length() == (pin_count()-1));
|
||||||
inp = udp->tinput[table_idx];
|
}
|
||||||
assert(inp.length() == (pin_count()-1));
|
|
||||||
}
|
|
||||||
|
|
||||||
out = udp->toutput[table_idx];
|
out = udp->toutput[table_idx];
|
||||||
assert( (out == '0')
|
assert((out == '0') ||
|
||||||
|| (out == '1')
|
(out == '1') ||
|
||||||
|| (out == 'x')
|
(out == 'x') ||
|
||||||
|| (is_sequential() && (out == '-')));
|
(is_sequential() && (out == '-')));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
char NetUDP::get_initial() const
|
char NetUDP::get_initial() const
|
||||||
{
|
{
|
||||||
assert (is_sequential());
|
assert (is_sequential());
|
||||||
|
|
||||||
switch (udp->initial)
|
switch (udp->initial) {
|
||||||
{
|
case verinum::V0:
|
||||||
case verinum::V0:
|
return '0';
|
||||||
return '0';
|
case verinum::V1:
|
||||||
case verinum::V1:
|
return '1';
|
||||||
return '1';
|
case verinum::Vx:
|
||||||
case verinum::Vx:
|
case verinum::Vz:
|
||||||
case verinum::Vz:
|
return 'x';
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(0);
|
||||||
return 'x';
|
return 'x';
|
||||||
}
|
|
||||||
|
|
||||||
assert(0);
|
|
||||||
return 'x';
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
3
synth.cc
3
synth.cc
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999-2008 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 1999-2010 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
|
||||||
|
|
@ -113,6 +113,7 @@ int do_expr::event_wait(NetEvWait*stmt)
|
||||||
class synth_f : public functor_t {
|
class synth_f : public functor_t {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
synth_f() { top_ = NULL; }
|
||||||
void process(class Design*, class NetProcTop*);
|
void process(class Design*, class NetProcTop*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue