Skip to content

Commit

Permalink
Reduce warnings oc (#3154)
Browse files Browse the repository at this point in the history
  • Loading branch information
alkino authored Nov 4, 2024
1 parent d26ea08 commit b4789ad
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 45 deletions.
20 changes: 6 additions & 14 deletions src/oc/code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1397,7 +1397,7 @@ void hoc_pop_frame(void) {

// call a function
void hoc_call() {
int i, isec;
int isec;
Symbol* sp = pc[0].sym; /* symbol table entry */
/* for function */
if (++fp >= framelast) {
Expand Down Expand Up @@ -1575,7 +1575,7 @@ void hoc_Numarg(void) {
}

void hoc_Argtype() {
int narg, iarg, type, itype = 0;
int iarg, itype = 0;
Frame* f = fp - 1;
if (f == frame) {
hoc_execerror("argtype can only be called in a func or proc", 0);
Expand Down Expand Up @@ -1813,9 +1813,7 @@ Symbol* hoc_get_last_pointer_symbol(void) { /* hard to imagine a kludgier functi

void hoc_autoobject(void) { /* AUTOOBJ symbol at pc+1. */
/* pointer to object pointer left on stack */
int i;
Symbol* obs;
Object** obp;
#if PDEBUG
printf("code for hoc_autoobject()\n");
#endif
Expand Down Expand Up @@ -2068,7 +2066,7 @@ void hoc_le(void) {
}

void hoc_eq() {
auto const& entry1 = get_stack_entry_variant(0);
/* auto const& entry1 = */ get_stack_entry_variant(0);
auto const& entry2 = get_stack_entry_variant(1);
auto const type2 = get_legacy_int_type(entry2);
double result{};
Expand Down Expand Up @@ -2097,7 +2095,7 @@ void hoc_eq() {

void hoc_ne() {
auto const& entry1 = get_stack_entry_variant(0);
auto const& entry2 = get_stack_entry_variant(1);
/* auto const& entry2 = */ get_stack_entry_variant(1);
auto const type1 = get_legacy_int_type(entry1);
double result{};
switch (type1) {
Expand Down Expand Up @@ -2425,16 +2423,10 @@ list. */
/* modified greatly by Hines. Very unsafe in general. */
{
#if 1
/*---- local variables -----*/
Symbol *doomed, *sp;
/*---- start function ------*/

/* copy address of the symbol that will be deleted */
doomed = (pc++)->sym;
Symbol *doomed = (pc++)->sym;

#endif
/* hoc_execerror("delete_symbol doesn't work right now.", (char *)0);*/
#if 1
/* hoc_execerror("delete_symbol doesn't work right now.", (char *)0);*/
if (doomed->type == UNDEF)
fprintf(stderr, "%s: no such variable\n", doomed->name);
else if (doomed->defined_on_the_fly == 0)
Expand Down
1 change: 0 additions & 1 deletion src/oc/hoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,6 @@ void inputReadyThread() {
#endif

void hoc_final_exit(void) {
char* buf;
#if defined(USE_PYTHON)
if (neuron::python::methods.interpreter_start) {
neuron::python::methods.interpreter_start(0);
Expand Down
3 changes: 1 addition & 2 deletions src/oc/hoc_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,7 @@ void hoc_unix_mac_pc(void) {
#endif
}
void hoc_show_winio(void) {
int b;
b = (int) chkarg(1, 0., 1.);
int b = (int) chkarg(1, 0., 1.);

Check warning on line 325 in src/oc/hoc_init.cpp

View check run for this annotation

Codecov / codecov/patch

src/oc/hoc_init.cpp#L325

Added line #L325 was not covered by tests
#if defined(WIN32)
hoc_winio_show(b);
#endif
Expand Down
33 changes: 9 additions & 24 deletions src/oc/hoc_oop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,28 +584,22 @@ void hoc_newobj_ret(void) {
}

void hoc_newobj(void) { /* template at pc+1 */
Object *ob, **obp;
Objectdata* obd;
Symbol *sym, *s;
int i, total;
int narg;

sym = (pc++)->sym;
narg = (pc++)->i;
Symbol *sym = (pc++)->sym;
int narg = (pc++)->i;
#if USE_PYTHON
/* look inside stack because of limited number of temporary objects? */
/* whatever. we will keep the strategy */
if (hoc_inside_stacktype(narg) == OBJECTVAR) {
#endif
obp = hoc_look_inside_stack<Object**>(narg);
ob = hoc_newobj1(sym, narg);
Object** obp = hoc_look_inside_stack<Object**>(narg);
Object* ob = hoc_newobj1(sym, narg);
hoc_nopop(); /* the object pointer */
hoc_dec_refcount(obp);
*(obp) = ob;
hoc_pushobj(obp);
#if USE_PYTHON
} else { /* Assignment to OBJECTTMP not allowed */
Object* o = hoc_obj_look_inside_stack(narg);
hoc_obj_look_inside_stack(narg);

Check warning on line 602 in src/oc/hoc_oop.cpp

View check run for this annotation

Codecov / codecov/patch

src/oc/hoc_oop.cpp#L602

Added line #L602 was not covered by tests
hoc_execerror("Assignment to $o only allowed if caller arg was declared as objref",
nullptr);
}
Expand Down Expand Up @@ -788,13 +782,11 @@ void hoc_objvardecl(void) { /* symbol at pc+1, number of indices at pc+2 */
}

void hoc_cmp_otype(void) { /* NUMBER, OBJECTVAR, or STRING must be the type */
int type;
type = (pc++)->i;
++pc;
}

void hoc_known_type(void) {
int type;
type = ((pc++)->i);
++pc;
}

void hoc_objectvar(void) { /* object variable symbol at pc+1. */
Expand Down Expand Up @@ -1374,25 +1366,18 @@ void hoc_object_eval(void) {
}

void hoc_ob_pointer(void) {
int type;
Symbol* sym;
#if PDEBUG
printf("code for hoc_ob_pointer\n");
#endif
type = hoc_stacktype();
int type = hoc_stacktype();
if (type == VAR) {
} else if (type == SYMBOL) {
auto* d_sym = hoc_look_inside_stack<Symbol*>(0);
if (d_sym->type == RANGEVAR) {
Symbol* sym = hoc_spop();
int nindex = hoc_ipop();
Section* sec = nrn_sec_pop();
double x;
if (nindex) {
x = hoc_xpop();
} else {
x = .5;
}
double x = nindex ? hoc_xpop() : .5;
hoc_push(nrn_rangepointer(sec, sym, x));
} else if (d_sym->type == VAR && d_sym->subtype == USERPROPERTY) {
hoc_pushpx(cable_prop_eval_pointer(hoc_spop()));
Expand Down
4 changes: 0 additions & 4 deletions src/oc/scoprand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ other in nrnmech.dll.
*
******************************************************************************/

#ifndef LINT
static char RCSid[] = "random.cpp,v 1.4 1999/01/04 12:46:49 hines Exp";
#endif

#include <math.h>
#include "oc_mcran4.hpp"
#include "mcran4.h"
Expand Down

0 comments on commit b4789ad

Please sign in to comment.