Commit 7c1af793 authored by Olivier Bertrand's avatar Olivier Bertrand

- Initialise min/max buffer to 0 to avoid valgrind complaining

  that uninitialised characters be written in op file.
modified:
  storage/connect/tabdos.cpp

- Typo
modified:
  storage/connect/filamap.cpp
  storage/connect/filamdbf.cpp
  storage/connect/filamdbf.h
  storage/connect/valblk.cpp
  storage/connect/xindex.cpp
parent 16de3511
...@@ -129,9 +129,9 @@ bool MAPFAM::OpenTableFile(PGLOBAL g) ...@@ -129,9 +129,9 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
&& fp->Count && fp->Mode == mode) && fp->Count && fp->Mode == mode)
break; break;
#ifdef DEBTRACE if (trace)
htrc("Mapping file, fp=%p\n", fp); htrc("Mapping file, fp=%p\n", fp);
#endif
} else } else
fp = NULL; fp = NULL;
...@@ -347,11 +347,12 @@ int MAPFAM::ReadBuffer(PGLOBAL g) ...@@ -347,11 +347,12 @@ int MAPFAM::ReadBuffer(PGLOBAL g)
return RC_EF; return RC_EF;
case RC_NF: case RC_NF:
// Skip this record // Skip this record
if ((rc = SkipRecord(g, FALSE)) != RC_OK) if ((rc = SkipRecord(g, false)) != RC_OK)
return rc; return rc;
goto next; goto next;
} // endswitch rc } // endswitch rc
} else } else
Placed = false; Placed = false;
...@@ -415,9 +416,9 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc) ...@@ -415,9 +416,9 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
/*******************************************************************/ /*******************************************************************/
Tpos = Spos = Fpos; Tpos = Spos = Fpos;
} else if ((n = Fpos - Spos) > 0) { } else if ((n = Fpos - Spos) > 0) {
/*****************************************************************/ /*******************************************************************/
/* Non consecutive line to delete. Move intermediate lines. */ /* Non consecutive line to delete. Move intermediate lines. */
/*****************************************************************/ /*******************************************************************/
memmove(Tpos, Spos, n); memmove(Tpos, Spos, n);
Tpos += n; Tpos += n;
......
...@@ -176,7 +176,7 @@ static int dbfhead(PGLOBAL g, FILE *file, PSZ fn, DBFHEADER *buf) ...@@ -176,7 +176,7 @@ static int dbfhead(PGLOBAL g, FILE *file, PSZ fn, DBFHEADER *buf)
/* DBFColumns: constructs the result blocks containing the description */ /* DBFColumns: constructs the result blocks containing the description */
/* of all the columns of a DBF file that will be retrieved by #GetData. */ /* of all the columns of a DBF file that will be retrieved by #GetData. */
/****************************************************************************/ /****************************************************************************/
PQRYRES DBFColumns(PGLOBAL g, char *dp, const char *fn, BOOL info) PQRYRES DBFColumns(PGLOBAL g, char *dp, const char *fn, bool info)
{ {
int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING,
TYPE_INT, TYPE_INT, TYPE_SHORT}; TYPE_INT, TYPE_INT, TYPE_SHORT};
...@@ -186,7 +186,7 @@ PQRYRES DBFColumns(PGLOBAL g, char *dp, const char *fn, BOOL info) ...@@ -186,7 +186,7 @@ PQRYRES DBFColumns(PGLOBAL g, char *dp, const char *fn, BOOL info)
char buf[2], filename[_MAX_PATH]; char buf[2], filename[_MAX_PATH];
int ncol = sizeof(buftyp) / sizeof(int); int ncol = sizeof(buftyp) / sizeof(int);
int rc, type, len, field, fields; int rc, type, len, field, fields;
BOOL bad; bool bad;
DBFHEADER mainhead; DBFHEADER mainhead;
DESCRIPTOR thisfield; DESCRIPTOR thisfield;
FILE *infile = NULL; FILE *infile = NULL;
......
...@@ -19,7 +19,7 @@ typedef class DBMFAM *PDBMFAM; ...@@ -19,7 +19,7 @@ typedef class DBMFAM *PDBMFAM;
/****************************************************************************/ /****************************************************************************/
/* Functions used externally. */ /* Functions used externally. */
/****************************************************************************/ /****************************************************************************/
PQRYRES DBFColumns(PGLOBAL g, char *dp, const char *fn, BOOL info); PQRYRES DBFColumns(PGLOBAL g, char *dp, const char *fn, bool info);
/****************************************************************************/ /****************************************************************************/
/* This is the base class for dBASE file access methods. */ /* This is the base class for dBASE file access methods. */
......
...@@ -664,6 +664,13 @@ int TDBDOS::MakeBlockValues(PGLOBAL g) ...@@ -664,6 +664,13 @@ int TDBDOS::MakeBlockValues(PGLOBAL g)
cdp->SetMin(PlugSubAlloc(g, NULL, block * lg)); cdp->SetMin(PlugSubAlloc(g, NULL, block * lg));
cdp->SetMax(PlugSubAlloc(g, NULL, block * lg)); cdp->SetMax(PlugSubAlloc(g, NULL, block * lg));
// Valgrind complains if there are uninitialised bytes
// after the null character ending
if (IsTypeChar(cdp->GetType())) {
memset(cdp->GetMin(), 0, block * lg);
memset(cdp->GetMax(), 0, block * lg);
} // endif Type
if (trace) if (trace)
htrc("min(%p) max(%p) col(%d) %s Block=%d lg=%d\n", htrc("min(%p) max(%p) col(%d) %s Block=%d lg=%d\n",
cdp->GetMin(), cdp->GetMax(), i, cdp->GetName(), block, lg); cdp->GetMin(), cdp->GetMax(), i, cdp->GetName(), block, lg);
......
...@@ -827,12 +827,12 @@ void CHRBLK::SetValue(PVBLK pv, int n1, int n2) ...@@ -827,12 +827,12 @@ void CHRBLK::SetValue(PVBLK pv, int n1, int n2)
longjmp(g->jumper[g->jump_level], Type); longjmp(g->jumper[g->jump_level], Type);
} // endif Type } // endif Type
if (!(b = pv->IsNull(n2) && Nullable)) if (!(b = pv->IsNull(n2)))
memcpy(Chrp + n1 * Long, ((CHRBLK*)pv)->Chrp + n2 * Long, Long); memcpy(Chrp + n1 * Long, ((CHRBLK*)pv)->Chrp + n2 * Long, Long);
else else
Reset(n1); Reset(n1);
SetNull(n1, b); SetNull(n1, b && Nullable);
} // end of SetValue } // end of SetValue
/***********************************************************************/ /***********************************************************************/
......
...@@ -544,7 +544,7 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp) ...@@ -544,7 +544,7 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
if ((Ndif = Qsort(g, Num_K)) < 0) if ((Ndif = Qsort(g, Num_K)) < 0)
goto err; // Error during sort goto err; // Error during sort
// if (trace) if (trace)
htrc("Make: Nk=%d n=%d Num_K=%d Ndif=%d addcolp=%p BlkFil=%p X=%p\n", htrc("Make: Nk=%d n=%d Num_K=%d Ndif=%d addcolp=%p BlkFil=%p X=%p\n",
Nk, n, Num_K, Ndif, addcolp, Tdbp->To_BlkFil, X); Nk, n, Num_K, Ndif, addcolp, Tdbp->To_BlkFil, X);
...@@ -817,11 +817,11 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp) ...@@ -817,11 +817,11 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp)
bool sep, rc = false; bool sep, rc = false;
PXCOL kcp = To_KeyCol; PXCOL kcp = To_KeyCol;
PDOSDEF defp = (PDOSDEF)Tdbp->To_Def; PDOSDEF defp = (PDOSDEF)Tdbp->To_Def;
PDBUSER dup = PlgGetUser(g); //PDBUSER dup = PlgGetUser(g);
dup->Step = STEP(SAVING_INDEX); //dup->Step = STEP(SAVING_INDEX);
dup->ProgMax = 15 + 16 * Nk; //dup->ProgMax = 15 + 16 * Nk;
dup->ProgCur = 0; //dup->ProgCur = 0;
switch (Tdbp->Ftype) { switch (Tdbp->Ftype) {
case RECFM_VAR: ftype = ".dnx"; break; case RECFM_VAR: ftype = ".dnx"; break;
...@@ -881,17 +881,17 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp) ...@@ -881,17 +881,17 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp)
} // endif trace } // endif trace
size = X->Write(g, n, NZ, sizeof(int), rc); size = X->Write(g, n, NZ, sizeof(int), rc);
dup->ProgCur = 1; //dup->ProgCur = 1;
if (Mul) // Write the offset array if (Mul) // Write the offset array
size += X->Write(g, Pof, nof, sizeof(int), rc); size += X->Write(g, Pof, nof, sizeof(int), rc);
dup->ProgCur = 5; //dup->ProgCur = 5;
if (!Incr) // Write the record position array(s) if (!Incr) // Write the record position array(s)
size += X->Write(g, To_Rec, Num_K, sizeof(int), rc); size += X->Write(g, To_Rec, Num_K, sizeof(int), rc);
dup->ProgCur = 15; //dup->ProgCur = 15;
for (; kcp; kcp = kcp->Next) { for (; kcp; kcp = kcp->Next) {
n[0] = kcp->Ndf; // Number of distinct sub-values n[0] = kcp->Ndf; // Number of distinct sub-values
...@@ -901,20 +901,20 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp) ...@@ -901,20 +901,20 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp)
n[4] = kcp->Type; // To be checked later n[4] = kcp->Type; // To be checked later
size += X->Write(g, n, NW, sizeof(int), rc); size += X->Write(g, n, NW, sizeof(int), rc);
dup->ProgCur += 1; // dup->ProgCur += 1;
if (n[2]) if (n[2])
size += X->Write(g, kcp->To_Bkeys, Nblk, kcp->Klen, rc); size += X->Write(g, kcp->To_Bkeys, Nblk, kcp->Klen, rc);
dup->ProgCur += 5; // dup->ProgCur += 5;
size += X->Write(g, kcp->To_Keys, n[0], kcp->Klen, rc); size += X->Write(g, kcp->To_Keys, n[0], kcp->Klen, rc);
dup->ProgCur += 5; // dup->ProgCur += 5;
if (n[1]) if (n[1])
size += X->Write(g, kcp->Kof, n[1], sizeof(int), rc); size += X->Write(g, kcp->Kof, n[1], sizeof(int), rc);
dup->ProgCur += 5; // dup->ProgCur += 5;
} // endfor kcp } // endfor kcp
if (trace) if (trace)
...@@ -2834,6 +2834,7 @@ void *XHUGE::FileView(PGLOBAL g, char *fn) ...@@ -2834,6 +2834,7 @@ void *XHUGE::FileView(PGLOBAL g, char *fn)
/***********************************************************************/ /***********************************************************************/
XXROW::XXROW(PTDBDOS tdbp) : XXBASE(tdbp, false) XXROW::XXROW(PTDBDOS tdbp) : XXBASE(tdbp, false)
{ {
Srtd = true;
Tdbp = tdbp; Tdbp = tdbp;
Valp = NULL; Valp = NULL;
} // end of XXROW constructor } // end of XXROW constructor
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment