Skip to content

Commit

Permalink
addressing various compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpipe committed Dec 20, 2023
1 parent df626d4 commit 508312e
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 60 deletions.
10 changes: 6 additions & 4 deletions ascend/compiler/importhandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ ASC_DLLSPEC int importhandler_add(struct ImportHandler *handler){
for(i=0; i< IMPORTHANDLER_MAX; ++i){
if(importhandler_library->handlers[i] == NULL)break;
if(importhandler_library->handlers[i]->name == handler->name){
#ifdef IMPORTHANDLER_VERBOSE
ERROR_REPORTER_HERE(ASC_USER_NOTE,"Handler already loaded");
#endif
return 0;
}
}
Expand Down Expand Up @@ -100,7 +102,7 @@ int importhandler_import(struct ImportHandler *handler, struct FilePath *fp
p = ASC_NEW(struct ImportPackage);
p->fp = ospath_new_copy(fp);
p->partialpath = ASC_NEW_ARRAY_CLEAR(char,strlen(partialpath)+1);
strncpy(p->partialpath,partialpath,strlen(partialpath));
strcpy(p->partialpath,partialpath);
MSG("partialpath='%s'",p->partialpath);
p->cleanupfunc = cleanupfunc;
p->handler = handler;
Expand Down Expand Up @@ -151,7 +153,7 @@ static int importhandler_unload(struct ImportPackage *p){
*/
char *importhandler_extlib_filename(const char *partialname){
char *buffer;
buffer = ASC_NEW_ARRAY(char,PATH_MAX);
buffer = ASC_NEW_ARRAY(char,PATH_MAX+1);

#if defined(ASC_EXTLIBSUFFIX) && defined(ASC_EXTLIBPREFIX)
/*
Expand Down Expand Up @@ -200,7 +202,7 @@ int importhandler_extlib_import(const struct FilePath *fp,const char *initfunc,c
struct FilePath *fp1;
char *stem;
char *path;
char auto_initfunc[PATH_MAX];
char auto_initfunc[PATH_MAX+1];
int result;

MSG("Importing '%s'",partialpath);
Expand All @@ -219,7 +221,7 @@ int importhandler_extlib_import(const struct FilePath *fp,const char *initfunc,c
if(initfunc==NULL){
fp1 = ospath_new(partialpath);
stem = ospath_getbasefilename(fp1);
strncpy(auto_initfunc,stem,PATH_MAX);
strncpy(auto_initfunc,stem,PATH_MAX);auto_initfunc[PATH_MAX]='\0';
ospath_free(fp1);
ASC_FREE(stem);

Expand Down
2 changes: 1 addition & 1 deletion ascend/compiler/initialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ static int SpecialSelfName(CONST struct Name *n){
}

/**
Produces a list of lists of argument instances. a the list returned is never NULL except when out of memory. Entries in this list may be NULL if some argument search fails. Argument search is successful IFF errlist returned is empty (length 0).
Produces a list of lists of argument instances. the list returned is never NULL except when out of memory. Entries in this list may be NULL if some argument search fails. Argument search is successful IFF errlist returned is empty (length 0).
*/
static struct gl_list_t *ProcessExtMethodArgs(struct Instance *inst,
CONST struct VariableList *vl, struct gl_list_t *errlist
Expand Down
23 changes: 10 additions & 13 deletions ascend/compiler/instantiate.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,12 @@ void instantiation_error(error_severity_t sev
va_error_reporter(sev
, Asc_ModuleBestName(StatementModule(stat))
, StatementLineNum(stat), NULL
, fmt, &args2
, fmt, args2
);
}else{
va_error_reporter(sev
, NULL, 0, NULL
, fmt, &args2
, fmt, args2
);
}
va_end(args);
Expand Down Expand Up @@ -4781,8 +4781,6 @@ static int ExecuteREL(struct Instance *inst, struct Statement *statement){
enum Expr_enum reltype;
//char *iname;

char *iname;

#ifdef DEBUG_RELS
CONSOLE_DEBUG("ENTERED ExecuteREL");
#endif
Expand Down Expand Up @@ -4862,6 +4860,7 @@ static int ExecuteREL(struct Instance *inst, struct Statement *statement){
#ifdef DEBUG_RELS
STATEMENT_NOTE(statement, "End of ExecuteREL. huh?");
#endif
return 0;
}

/**
Expand Down Expand Up @@ -10026,7 +10025,7 @@ int ExecuteUnSelectedForStatements(struct Instance *inst,
{
struct Statement *statement;
unsigned long c,len;
int return_value;
//int return_value;
struct gl_list_t *list;
list = GetList(sl);
len = gl_length(list);
Expand All @@ -10042,32 +10041,31 @@ int ExecuteUnSelectedForStatements(struct Instance *inst,
case CALL:
case CASGN:
case ASGN:
return_value = 1;
break;
case FNAME:
if (g_iteration>=MAXNUMBER) {
STATEMENT_ERROR(statement,
"FNAME not allowed inside a SELECT Statement");
}
return_value = 1; /*ignore it */
//return_value = 1; /*ignore it */
break;
case ALIASES:
return_value = ExecuteUnSelectedALIASES(inst,statement);
ExecuteUnSelectedALIASES(inst,statement);
break;
case ISA:
return_value = ExecuteUnSelectedISA(inst,statement);
ExecuteUnSelectedISA(inst,statement);
break;
case FOR:
return_value = ExecuteUnSelectedForStatements(inst,
ExecuteUnSelectedForStatements(inst,
ForStatStmts(statement));
break;
case REL:
case EXT:
case LOGREL:
return_value = ExecuteUnSelectedEQN(inst,statement);
ExecuteUnSelectedEQN(inst,statement);
break;
case WHEN:
return_value = ExecuteUnSelectedWHEN(inst,statement);
ExecuteUnSelectedWHEN(inst,statement);
break;
case COND:
STATEMENT_ERROR(statement,
Expand All @@ -10085,7 +10083,6 @@ int ExecuteUnSelectedForStatements(struct Instance *inst,
" declarative section unSEL FOR");
}
}
/* FIXME this should be 'return_value', shouldn't it??? */
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion ascend/general/dstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ char *Asc_DStringSet(Asc_DString *dsPtr, CONST char *string)
/*
* Copy the new string into the buffer
*/
strncpy(dsPtr->string, string, (size_t)length);
strncpy(dsPtr->string, string, (size_t)length+1);
dsPtr->length = length;
dsPtr->string[dsPtr->length] = '\0';
return dsPtr->string;
Expand Down
2 changes: 1 addition & 1 deletion ascend/general/ltmatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ unsigned long ltmatrix_access(ltmatrix* matrix, unsigned long row, unsigned long
asc_assert(matrix!=NULL);
ASC_ASSERT_RANGE(row,0,matrix->dimension);
ASC_ASSERT_RANGE(col,0,matrix->dimension);
unsigned long index;
unsigned long index = 99999;
unsigned long r;
unsigned long c;
unsigned long d;
Expand Down
39 changes: 19 additions & 20 deletions ascend/general/ospath.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@
#endif

/* PATH_MAX is in ospath.h */
#define DRIVEMAX 3
#define DRIVEMAX 2
#define LISTMAX 256

struct FilePath{
char path[PATH_MAX]; /** the string version of the represented POSIX path */
char path[PATH_MAX+1]; /** the string version of the represented POSIX path */

#ifdef WINPATHS
char drive[DRIVEMAX]; /** the drive the path resides on (field is absent in POSIX systems) */
char drive[DRIVEMAX+1]; /** the drive the path resides on (field is absent in POSIX systems) */
#endif
};

Expand Down Expand Up @@ -279,12 +279,12 @@ void ospath_free_str(char *str){
void ospath_fixslash(char *path){

char *p;
char temp[PATH_MAX];
char temp[PATH_MAX+1];
int startslash;
int endslash;
STRTOKVAR(nexttok);

STRNCPY(temp,path,PATH_MAX);
strcpy(temp,path);temp[PATH_MAX]='\0';

#if 0
X(path);
Expand Down Expand Up @@ -416,7 +416,7 @@ void ospath_extractdriveletter(struct FilePath *fp)
}
*(p-2)='\0';
}else{
STRNCPY(fp->drive,"",DRIVEMAX);
fp->drive[0] = '\0';
}
#if 0
M("RESULT");
Expand Down Expand Up @@ -761,7 +761,7 @@ struct FilePath *ospath_getparentatdepthn(struct FilePath *fp, unsigned depth)

char *ospath_getbasefilename(struct FilePath *fp){
char *temp;
unsigned length, offset;
unsigned length ;
char *pos;

if(fp==NULL)return NULL;
Expand All @@ -778,9 +778,8 @@ char *ospath_getbasefilename(struct FilePath *fp){
/* reverse find '/' but DON'T ignore a trailing slash*/
/* (this is changed from the original implementation)*/
length = strlen(fp->path);
offset = length;

pos = strrchr(fp->path, PATH_SEPARATOR_CHAR); /* OFFSET! */
pos = strrchr(fp->path, PATH_SEPARATOR_CHAR);

/* extract filename given position of find / and return it.*/
if(pos != NULL){
Expand All @@ -793,7 +792,7 @@ char *ospath_getbasefilename(struct FilePath *fp){
return temp;
}else{
temp = ASC_NEW_ARRAY(char, length+1);
STRNCPY(temp, fp->path, length);
strcpy(temp, fp->path);
*(temp+length)='\0';
return temp;
}
Expand Down Expand Up @@ -1062,8 +1061,8 @@ int ospath_cmp(struct FilePath *fp1, struct FilePath *fp2){
struct FilePath *ospath_concat(const struct FilePath *fp1, const struct FilePath *fp2){

struct FilePath *fp;
char temp[2][PATH_MAX];
char temp2[PATH_MAX];
char temp[2][PATH_MAX+1];
char temp2[PATH_MAX+1];
struct FilePath *r;

X(fp1->path);
Expand Down Expand Up @@ -1096,13 +1095,13 @@ struct FilePath *ospath_concat(const struct FilePath *fp1, const struct FilePath
/* now, both paths are valid...*/

#ifdef WINPATHS
STRNCPY(temp[0],fp1->drive,PATH_MAX);
strcpy(temp[0],fp1->drive);
STRNCAT(temp[0],fp1->path,PATH_MAX-strlen(temp[0]));
#else
STRNCPY(temp[0], fp1->path,PATH_MAX);
strcpy(temp[0], fp1->path);
#endif

STRNCPY(temp[1], fp2->path,PATH_MAX);
strcpy(temp[1], fp2->path);

/* make sure temp has a / on the end. */
if(temp[0][strlen(temp[0]) - 1] != PATH_SEPARATOR_CHAR){
Expand All @@ -1127,7 +1126,7 @@ struct FilePath *ospath_concat(const struct FilePath *fp1, const struct FilePath
}

/* create a new path object with the two path strings appended together.*/
STRNCPY(temp2,temp[0],PATH_MAX);
strcpy(temp2,temp[0]);
STRNCAT(temp2,temp[1],PATH_MAX-strlen(temp2));
#if 1
V(strlen(temp2));
Expand All @@ -1142,7 +1141,7 @@ struct FilePath *ospath_concat(const struct FilePath *fp1, const struct FilePath

void ospath_append(struct FilePath *fp, struct FilePath *fp1){
char *p;
char temp[2][PATH_MAX];
char temp[2][PATH_MAX+1];
struct FilePath fp2;

ospath_copy(&fp2,fp1);
Expand Down Expand Up @@ -1172,11 +1171,11 @@ void ospath_append(struct FilePath *fp, struct FilePath *fp1){
#if 0
temp[0] = CALLOC(1+strlen(fp->path), sizeof(char));
#endif
STRNCPY(temp[0], fp->path, PATH_MAX);
strcpy(temp[0], fp->path);
#if 0
temp[1] = CALLOC(strlen(fp2.path), sizeof(char));
#endif
STRNCPY(temp[1], fp2.path, PATH_MAX);
strcpy(temp[1], fp2.path);

X(temp[0]);
X(temp[1]);
Expand All @@ -1199,7 +1198,7 @@ void ospath_append(struct FilePath *fp, struct FilePath *fp1){
X(temp[1]);

/*create new path string.*/
STRNCPY(fp->path,temp[0], PATH_MAX);
strcpy(fp->path,temp[0]);
STRNCAT(fp->path,temp[1], PATH_MAX-strlen(fp->path));

X(fp->path);
Expand Down
17 changes: 9 additions & 8 deletions ascend/linear/ranki.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ static void rankikw_factor(linsolqr_system_t sys)
mtx_range_t pivot_candidates;
real64 *tmp;
real64 pivot, *pivots;
int32 length;
//int32 length;
mtx_matrix_t mtx;

length = sys->rng.high - sys->rng.low + 1;
//length = sys->rng.high - sys->rng.low + 1;
tmp = sys->ludata->tmp;
/* eliminate row takes care of zeroing the relevant region and won't
change values outside of it. */
Expand All @@ -188,7 +188,6 @@ static void rankikw_factor(linsolqr_system_t sys)
sys->smallest_pivot = MAXDOUBLE;
last_row = pivot_candidates.high = sys->rng.high;
for( nz.row = sys->rng.low ; nz.row <= last_row ; ) {

pivot_candidates.low = nz.col = nz.row;
pivots[nz.row]=pivot = mtx_value(mtx,&nz);
pivot = fabs(pivot);
Expand All @@ -215,7 +214,6 @@ static void rankikw_factor(linsolqr_system_t sys)
mtx_drag(mtx,nz.row,last_row);
number_drag(pivots,nz.row,last_row);
--last_row;
#undef KAA_DEBUG
#ifdef KAA_DEBUG
ERROR_REPORTER_HERE(ASC_PROG_WARNING,"Warning: Row %d is dependent with pivot %20.8g",nz.row,pivot);
#endif /* KAA_DEBUG */
Expand Down Expand Up @@ -247,10 +245,10 @@ static void rankijz_factor(linsolqr_system_t sys)
mtx_region_t candidates;
real64 *tmp;
real64 pivot, *pivots;
int32 length;
//int32 length;
mtx_matrix_t mtx;

length = sys->rng.high - sys->rng.low + 1;
//length = sys->rng.high - sys->rng.low + 1;
tmp = sys->ludata->tmp;
/* eliminate row takes care of zeroing the relevant region and won't
change values outside of it. */
Expand Down Expand Up @@ -320,7 +318,9 @@ static void rankijz_factor(linsolqr_system_t sys)
*/
int ranki_entry(linsolqr_system_t sys,mtx_region_t *region){
struct rhs_list *rl;
#ifdef KAA_DEBUG
double comptime;
#endif

CHECK_SYSTEM(sys);
if( sys->factored )
Expand Down Expand Up @@ -353,7 +353,9 @@ int ranki_entry(linsolqr_system_t sys,mtx_region_t *region){
ensure_capacity(sys);
ensure_lu_capacity(sys);

#ifdef KAA_DEBUG
comptime = tm_cpu_time();
#endif
switch(sys->fmethod) {
case ranki_ka:
case ranki_kw:
Expand All @@ -369,8 +371,7 @@ int ranki_entry(linsolqr_system_t sys,mtx_region_t *region){
*/
sys->factored = TRUE;

#undef KAA_DEBUG
#if KAA_DEBUG
#ifdef KAA_DEBUG
comptime = tm_cpu_time() - comptime;
ERROR_REPORTER_HERE(ASC_PROG_NOTE,"Time for Inversion = %f",comptime);
ERROR_REPORTER_HERE(ASC_PROG_ERR,"Non-zeros in Inverse = %d",mtx_nonzeros_in_region(sys->factors,region));
Expand Down
2 changes: 1 addition & 1 deletion ascend/system/graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#include <ascend/general/panic.h>
#include <ascend/utilities/ascDynaLoad.h>

#define ASC_GRAPH_DEBUG
//#define ASC_GRAPH_DEBUG
#ifdef ASC_GRAPH_DEBUG
# define MSG CONSOLE_DEBUG
#else
Expand Down

0 comments on commit 508312e

Please sign in to comment.