Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions sources/checkpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -1420,10 +1420,16 @@ int DoRecovery(int *moduletype)
if ( !(fd = fopen(recoveryfile, "r")) ) return(__LINE__);

/* load the complete recovery file into a buffer */
if ( fread(&pos, sizeof(POSITION), 1, fd) != 1 ) return(__LINE__);
if ( fread(&pos, sizeof(POSITION), 1, fd) != 1 ) {
fclose(fd);
return(__LINE__);
}
size = BASEPOSITION(pos) - sizeof(POSITION);
buf = Malloc1(size, "recovery buffer");
if ( fread(buf, size, 1, fd) != 1 ) return(__LINE__);
if ( fread(buf, size, 1, fd) != 1 ) {
fclose(fd);
return(__LINE__);
}

/* pointer p will go through the buffer in the following */
p = buf;
Expand Down Expand Up @@ -2478,7 +2484,7 @@ static int DoSnapshot(int moduletype)
{
GETIDENTITY
FILE *fd;
POSITION pos;
POSITION pos = {0};
int i, j;
LONG l;
WORD *w;
Expand All @@ -2495,10 +2501,16 @@ static int DoSnapshot(int moduletype)
if ( !(fd = fopen(intermedfile, "wb")) ) return(__LINE__);

/* reserve space in the file for a length field */
if ( fwrite(&pos, 1, sizeof(POSITION), fd) != sizeof(POSITION) ) return(__LINE__);
if ( fwrite(&pos, 1, sizeof(POSITION), fd) != sizeof(POSITION) ) {
fclose(fd);
return(__LINE__);
}

/* write moduletype */
if ( fwrite(&moduletype, 1, sizeof(int), fd) != sizeof(int) ) return(__LINE__);
if ( fwrite(&moduletype, 1, sizeof(int), fd) != sizeof(int) ) {
fclose(fd);
return(__LINE__);
}

/*#[ AM :*/

Expand Down
2 changes: 2 additions & 0 deletions sources/minos.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ DBASE *NewDbase(char *name,MLONG number)
if ( ( d->iblocks = (INDEXBLOCK **)Malloc1(numblocks*sizeof(INDEXBLOCK *),
"new database") ) == 0 ) {
NumTableBases--;
fclose(f);
return(0);
}
d->tablenames = 0;
Expand All @@ -635,6 +636,7 @@ DBASE *NewDbase(char *name,MLONG number)
"new database") ) == 0 ) {
M_free(d->iblocks,"new database");
NumTableBases--;
fclose(f);
return(0);
}
if ( ( f = fopen(name,"w+b") ) == 0 ) {
Expand Down
2 changes: 1 addition & 1 deletion sources/parallel.c
Original file line number Diff line number Diff line change
Expand Up @@ -4681,7 +4681,7 @@ static void PF_BroadcastRuntimeError(void)
{
assert(PF.me == MASTER);

int ret, dummy;
int ret, dummy = 0;
MPI_Request requests[PF.numtasks - 1];

/*
Expand Down
32 changes: 12 additions & 20 deletions sources/ratio.c
Original file line number Diff line number Diff line change
Expand Up @@ -3108,14 +3108,15 @@ char *TheErrorMessage[] = {
,"Irregular code in PolyRatFun encountered in ExpandRat."
,"Called from ExpandRat."
,"WorkSpace overflow. Change parameter WorkSpace in setup file?"
,"Illegal term in expanded polyratfun."
};

int ExpandRat(PHEAD WORD *fun)
{
WORD *r, *rr, *rrr, *tt, *tnext, *arg1, *arg2, *rmin = 0, *rmininv;
WORD *r, *rr, *rrr, *tt, *tnext, *arg1, *arg2, *rmin = NULL, *rmininv;
WORD *rcoef, rsize, rcopy, *ow = AT.WorkPointer;
WORD *numerator, *denominator, *rnext;
WORD *thecopy, *rc, ncoef, newcoef, *m, *mm, nco, *outarg = 0;
WORD *thecopy, *rc, ncoef, newcoef, *m, *mm, nco, *outarg = NULL;
UWORD co[2], co1[2], co2[2];
WORD OldPolyFunPow = AR.PolyFunPow;
int i, j, minpow = 0, eppow, first, error = 0, ipoly;
Expand All @@ -3127,7 +3128,7 @@ int ExpandRat(PHEAD WORD *fun)
We have to normalize the argument. This could make it shorter.
*/
NormArg:;
if ( outarg == 0 ) outarg = TermMalloc("ExpandRat")+ARGHEAD;
if ( outarg == NULL ) outarg = TermMalloc("ExpandRat")+ARGHEAD;
AT.TrimPower = 1;
NewSort(BHEAD0);
r = fun+FUNHEAD+ARGHEAD;
Expand All @@ -3145,10 +3146,7 @@ NormArg:;
if ( rrm[1] == SYMBOL && rrm[2] == 4 && rrm[3] == AR.PolyFunVar ) {
if ( rrm[4] < minpow2 ) minpow2 = rrm[4];
}
else {
MesPrint("Illegal term in expanded polyratfun.");
goto onerror;
}
else { error = 5; goto onerror; }
}
rrm += *rrm;
}
Expand Down Expand Up @@ -3185,23 +3183,23 @@ NormArg:;
First test whether we have only AR.PolyFunVar in the denominator
*/
tt = fun + FUNHEAD;
arg1 = arg2 = 0;
arg1 = arg2 = NULL;
if ( tt < tnext ) {
arg1 = tt; NEXTARG(tt);
if ( tt < tnext ) {
arg2 = tt; NEXTARG(tt);
if ( tt != tnext ) { arg1 = arg2 = 0; } /* more than two arguments */
if ( tt != tnext ) { arg1 = arg2 = NULL; } /* more than two arguments */
}
}
if ( arg2 == 0 ) {
} else { error = 5; goto onerror; }
if ( arg2 == NULL ) {
if ( *arg1 < 0 ) { fun[2] = CLEANFLAG; goto done; }
if ( fun[2] == CLEANFLAG ) goto done;
goto NormArg; /* Note: should not come here */
}
/*
Produce the output argument in outarg
*/
if ( outarg == 0 ) outarg = TermMalloc("ExpandRat")+ARGHEAD;
if ( outarg == NULL ) outarg = TermMalloc("ExpandRat")+ARGHEAD;

if ( *arg2 <= 0 ) {
/*
Expand Down Expand Up @@ -3256,10 +3254,7 @@ NormArg:;
if ( rrm[1] == SYMBOL && rrm[2] == 4 && rrm[3] == AR.PolyFunVar ) {
if ( rrm[4] < minpow2 ) minpow2 = rrm[4];
}
else {
MesPrint("Illegal term in expanded polyratfun.");
goto onerror;
}
else { error = 5; goto onerror; }
}
rrm += *rrm;
}
Expand Down Expand Up @@ -3336,10 +3331,7 @@ NormArg:;
if ( rrm[1] == SYMBOL && rrm[2] == 4 && rrm[3] == AR.PolyFunVar ) {
if ( rrm[4] < minpow2 ) minpow2 = rrm[4];
}
else {
MesPrint("Illegal term in expanded polyratfun.");
goto onerror;
}
else { error = 5; goto onerror; }
}
rrm += *rrm;
}
Expand Down
2 changes: 1 addition & 1 deletion sources/reken.c
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,7 @@ int RaisPow(PHEAD UWORD *a, WORD *na, UWORD b)
c /= 2;
}
i--;
c = 1 << i;
c = 1u << i;
while ( --i >= 0 ) {
c /= 2;
if(MulLong(is,ns,is,ns,it,&nt)) goto RaisOvl;
Expand Down
10 changes: 5 additions & 5 deletions sources/setfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,11 @@ restart:;
break;
case PATHVALUE:
if ( StrICmp(s1,(UBYTE *)"incdir") == 0 ) {
AM.IncDir = 0;
AM.IncDir = NULL;
}
else if ( StrICmp(s1,(UBYTE *)"path") == 0 ) {
if ( AM.Path ) M_free(AM.Path,"path");
AM.Path = 0;
AM.Path = NULL;
}
else {
MesPrint("Setups: %s not yet implemented",s1);
Expand Down Expand Up @@ -775,16 +775,16 @@ int AllocSetups(void)
/*
And now some order sensitive things
*/
if ( AM.Path == 0 ) {
if ( AM.Path == NULL ) {
sp = GetSetupPar((UBYTE *)"path");
AM.Path = strDup1((UBYTE *)(sp->value),"path");
}
if ( AM.IncDir == 0 ) {
if ( AM.IncDir == NULL ) {
sp = GetSetupPar((UBYTE *)"incdir");
AM.IncDir = strDup1((UBYTE *)(sp->value),"incdir");
}
/*
if ( AM.TempDir == 0 ) {
if ( AM.TempDir == NULL ) {
sp = GetSetupPar((UBYTE *)"tempdir");
AM.TempDir = strDup1((UBYTE *)(sp->value),"tempdir");
}
Expand Down
14 changes: 7 additions & 7 deletions sources/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ int DoTail(int argc, UBYTE **argv)
AM.LogType = -1;
AM.HoldFlag = AM.qError = AM.Interact = AM.FileOnlyFlag = 0;
AM.InputFileName = AM.LogFileName = AM.IncDir = AM.TempDir = AM.TempSortDir =
AM.SetupDir = AM.SetupFile = AM.Path = 0;
AM.SetupDir = AM.SetupFile = AM.Path = NULL;
AM.FromStdin = 0;
/* Always use MultiRun, "-M" option is now ignored. */
AM.MultiRun = 1;
Expand Down Expand Up @@ -538,7 +538,7 @@ printversion:;
while ( *s ) *t++ = *s++;
*t++ = '.'; *t++ = 'f'; *t++ = 'r'; *t++ = 'm'; *t = 0;
}
if ( AM.LogType >= 0 && AM.LogFileName == 0 ) {
if ( AM.LogType >= 0 && AM.LogFileName == NULL ) {
AM.LogFileName = strDup1(AM.InputFileName,"name of logfile");
s = AM.LogFileName;
while ( *s ) s++;
Expand Down Expand Up @@ -567,7 +567,7 @@ printversion:;
printf("No filename specified in call of FORM\n");
errorflag++;
}
if ( AM.Path == 0 ) AM.Path = (UBYTE *)getenv("FORMPATH");
if ( AM.Path == NULL ) AM.Path = (UBYTE *)getenv("FORMPATH");
if ( AM.Path ) {
/*
* AM.Path is taken from argv or getenv. Reallocate it to avoid invalid
Expand Down Expand Up @@ -718,22 +718,22 @@ void ReserveTempFiles(int par)
int i = 0;
WORD j;
if ( par == 0 || par == 1 ) {
if ( AM.TempDir == 0 ) {
if ( AM.TempDir == NULL ) {
sp = GetSetupPar((UBYTE *)"tempdir");
if ( ( sp->flags & USEDFLAG ) != USEDFLAG ) {
AM.TempDir = (UBYTE *)getenv("FORMTMP");
if ( AM.TempDir == 0 ) AM.TempDir = emptystring;
if ( AM.TempDir == NULL ) AM.TempDir = emptystring;
}
else AM.TempDir = (UBYTE *)(sp->value);
}
if ( AM.TempSortDir == 0 ) {
if ( AM.TempSortDir == NULL ) {
if ( AM.havesortdir ) {
sp = GetSetupPar((UBYTE *)"tempsortdir");
AM.TempSortDir = (UBYTE *)(sp->value);
}
else {
AM.TempSortDir = (UBYTE *)getenv("FORMTMPSORT");
if ( AM.TempSortDir == 0 ) AM.TempSortDir = AM.TempDir;
if ( AM.TempSortDir == NULL ) AM.TempSortDir = AM.TempDir;
}
}
/*
Expand Down
1 change: 1 addition & 0 deletions sources/tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,7 @@ int CopyFile(char *source, char *dest)
}
out = fopen(dest, "wb");
if ( out == NULL ) {
fclose(in);
perror("CopyFile: ");
return(2);
}
Expand Down
Loading