Skip to content

Commit

Permalink
Clean code by reducing warning and dead code (#3139)
Browse files Browse the repository at this point in the history
Warning are for unused variables.
Dead code is the RCS_version and RCS_date that has not been updated since a really long time.
  • Loading branch information
Nicolas Cornu authored Nov 8, 2024
1 parent 490655a commit 7f6d710
Show file tree
Hide file tree
Showing 52 changed files with 85 additions and 424 deletions.
6 changes: 2 additions & 4 deletions cmake/NeuronFileLists.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,7 @@ set(MODLUNIT_FILES_LIST
passn.cpp
symbol.cpp
units.cpp
units1.cpp
version.cpp)
units1.cpp)

set(NOCMODL_FILES_LIST
consist.cpp
Expand All @@ -400,8 +399,7 @@ set(NOCMODL_FILES_LIST
netrec_discon.cpp
simultan.cpp
solve.cpp
symbol.cpp
version.cpp)
symbol.cpp)

set(IVOS_FILES_LIST observe.cpp resource.cpp)

Expand Down
5 changes: 0 additions & 5 deletions src/modlunit/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ Item* qlint;
#endif

static const char* pgm_name = "model";
extern const char* RCS_version;
extern const char* RCS_date;
static void openfiles(int, char**);
static void debug_item(Item* q, int indent, FILE* file);

Expand All @@ -57,9 +55,6 @@ int main(int argc, char* argv[]) {
* files
* We first look for a .mrg file and then a .mod file
*/
Fprintf(stderr, "%s %s %s\n", pgm_name, RCS_version, RCS_date);


init(); /* keywords into symbol table, initialize
* lists, etc. */
unit_init();
Expand Down
2 changes: 0 additions & 2 deletions src/modlunit/units.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,6 @@ void unit_stk_clean() {

// allow the outside world to call either modl_units() or unit_init().
static void units_alloc() {
int i;
static int units_alloc_called = 0;
if (!units_alloc_called) {
units_alloc_called = 1;
Expand All @@ -521,7 +520,6 @@ static void units_alloc() {
extern void unit_init();

void modl_units() {
int i;
static int first = 1;
unitonflag = 1;
if (first) {
Expand Down
184 changes: 0 additions & 184 deletions src/modlunit/version.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion src/nocmodl/deriv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ void deriv_used(Symbol* s, Item* q1, Item* q2) /* q1, q2 are begin and end token

/* args are --- derivblk: DERIVATIVE NAME stmtlist '}' */
void massagederiv(Item* q1, Item* q2, Item* q3, Item* q4) {
int count = 0, deriv_implicit, solve_seen;
int count = 0, deriv_implicit;
char units[SB];
Item *qs, *q, *mixed_eqns(Item * q2, Item * q3, Item * q4);
Symbol *s, *derfun, *state;
Expand Down
21 changes: 6 additions & 15 deletions src/nocmodl/kinetic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ void genmatterms(Reaction* r, int fn);
#define MAXKINBLK 20
static int nstate_[MAXKINBLK];

static int sparse_declared_[10];
static int sparsedeclared(int i) {
assert(i < 10);
return sparse_declared_[i]++;
}

char* qconcat(Item* q1, Item* q2) /* return names as single string */
{
char *cp, *ovrfl, *cs, *n;
Expand Down Expand Up @@ -208,7 +202,6 @@ void flux(Item* qREACTION, Item* qdir, Item* qlast) {
reactlist->krate[1] = qconcat(qdir->next->next, qlast);
if (ldifuslist) { /* function of current ? */
Item* q;
int isfunc;
for (q = qdir->next->next; q != qlast; q = q->next) {
Symbol* s;
if (q->itemtype == SYMBOL) {
Expand Down Expand Up @@ -652,7 +645,7 @@ void kinetic_implicit(Symbol* fun, const char* dt, const char* mname) {
Item* qv;
Reaction* r1;
Rlist *rlst, *clst;
int i, nstate, flag, sparsedec, firsttrans, firsttrans1;
int i, nstate, flag, firsttrans, firsttrans1;

firsttrans = 0; /* general declarations done only for NOT_CVODE_FLAG */
firsttrans1 = 0;
Expand Down Expand Up @@ -952,7 +945,6 @@ void massageconserve(Item* q1, Item* q3, Item* q5) /* CONSERVE react '=' expr */
{
/* the list of states is in rterm at this time with the first at the end */
Reaction* r1;
Item* qv;

r1 = conslist;
conslist = (Reaction*) emalloc(sizeof(Reaction));
Expand All @@ -963,7 +955,7 @@ void massageconserve(Item* q1, Item* q3, Item* q5) /* CONSERVE react '=' expr */
conslist->krate[1] = (char*) 0;
/*SUPPRESS 440*/
replacstr(q1, "/*");
qv = insertstr(q1, "");
insertstr(q1, "");
/*SUPPRESS 440*/
Insertstr(q5->next, "*/\n");
/*SUPPRESS 440*/
Expand Down Expand Up @@ -1075,7 +1067,6 @@ int number_states(Symbol* fun, Rlist** prlst, Rlist** pclst) {
void kinlist(Symbol* fun, Rlist* rlst) {
int i;
Symbol* s;
Item* qv;

if (rlst->slist_decl) {
return;
Expand All @@ -1093,15 +1084,15 @@ void kinlist(Symbol* fun, Rlist* rlst) {
fun->u.i,
s->varnum,
s->name);
qv = lappendstr(initlist, buf);
lappendstr(initlist, buf);
Sprintf(
buf, " _dlist%d[%d+_i] = {D%s_columnindex, _i};}\n", fun->u.i, s->varnum, s->name);
qv = lappendstr(initlist, buf);
lappendstr(initlist, buf);
} else {
Sprintf(buf, "_slist%d[%d] = {%s_columnindex, 0};", fun->u.i, s->varnum, s->name);
qv = lappendstr(initlist, buf);
lappendstr(initlist, buf);
Sprintf(buf, " _dlist%d[%d] = {D%s_columnindex, 0};\n", fun->u.i, s->varnum, s->name);
qv = lappendstr(initlist, buf);
lappendstr(initlist, buf);
}
s->used = 0;
}
Expand Down
7 changes: 0 additions & 7 deletions src/nocmodl/modl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ extern int numlist;
extern const char* nmodl_version_;
extern int usederivstatearray;

/*SUPPRESS 763*/
static const char* pgm_name = "nmodl";
extern const char* RCS_version;
extern const char* RCS_date;

static void openfiles(const char* given_filename, const char* output_dir);

int main(int argc, char** argv) {
Expand Down Expand Up @@ -212,8 +207,6 @@ int main(int argc, char** argv) {
}

static void openfiles(const char* given_filename, const char* output_dir) {
char s[NRN_BUFSIZE];

char output_filename[NRN_BUFSIZE];
char input_filename[NRN_BUFSIZE];
modprefix = strdup(given_filename); // we want to keep original string to open input file
Expand Down
1 change: 0 additions & 1 deletion src/nocmodl/netrec_discon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ void netrec_discon() {
static void general_discon_adjust(Item* varname, Item* equal, Item* expr, Item* lastok) {
int listnum = netrec_state_count % 10;
int neq = netrec_state_count / 10;
int i;
Symbol* sym = SYM(varname);
int sindex;
if (cvode_not_allowed) {
Expand Down
1 change: 0 additions & 1 deletion src/nocmodl/parse1.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ static int leftside; /* inside left hand side of equation? */
static int pstate; /* number of state in a primary expression */
static int tstate; /* number of states in a term */
static Item *lastok; /* last token accepted by expr */
static int scopindep = 0;/* SCoP independent explicitly declared if 1 */
static int extdef2 = 0; /* flag that says we are in an EXTDEF2 function */
static List *table_list = LIST0; /* table information for TABLE statement */
static Item* astmt_end_; /* see kinetic.c vectorizing */
Expand Down
6 changes: 0 additions & 6 deletions src/nocmodl/solve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ void whileloop(Item* qsol, long type, int ss) {
/* executing more that one for loop in a single call to model() is an error
which is trapped in scop */
static int called = 0, firstderf = 1;
const char* cp = 0;

switch (type) {
case DERF:
Expand All @@ -336,11 +335,6 @@ void whileloop(Item* qsol, long type, int ss) {
deltaindep = ifnew_parminstall(buf, sval, "", "");
firstderf = 0;
}
if (type == DERF) {
cp = "dt";
} else if (type == DISCRETE) {
cp = "0.0";
}
if (ss) {
return;
}
Expand Down
4 changes: 0 additions & 4 deletions src/nocmodl/version.cpp

This file was deleted.

2 changes: 0 additions & 2 deletions src/nrncvode/cvodestb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ void nrn_record_init();
void nrn_play_init();
void fixed_play_continuous(NrnThread* nt);
void nrn_solver_prepare();
static void check_thresh(NrnThread*);

// for fixed step thread
void deliver_net_events(NrnThread* nt) {
int i;
if (net_cvode_instance) {
net_cvode_instance->check_thresh(nt);
net_cvode_instance->deliver_net_events(nt);
Expand Down
Loading

0 comments on commit 7f6d710

Please sign in to comment.