From c51548d6b4234d1b9bf7548125f63c5975f37d35 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sun, 11 Jun 2017 17:22:56 +0200 Subject: [PATCH] Fix unhandled exception: Force type int for ENUMs. Replace remaining longjmp. modified: storage/connect/array.cpp modified: storage/connect/colblk.cpp modified: storage/connect/connect.cc modified: storage/connect/filter.cpp modified: storage/connect/jdbconn.cpp modified: storage/connect/plgdbutl.cpp modified: storage/connect/tabdos.cpp modified: storage/connect/tabvir.cpp modified: storage/connect/tabxml.cpp modified: storage/connect/value.cpp modified: storage/connect/xobject.cpp --- storage/connect/array.cpp | 8 ++++---- storage/connect/colblk.cpp | 6 +++--- storage/connect/connect.cc | 2 +- storage/connect/filter.cpp | 6 +++--- storage/connect/jdbconn.cpp | 6 +++--- storage/connect/plgdbutl.cpp | 4 ++-- storage/connect/tabdos.cpp | 2 +- storage/connect/tabmgo.cpp | 4 ++-- storage/connect/tabvir.cpp | 2 +- storage/connect/tabxml.cpp | 40 ++++++++++++++++++------------------ storage/connect/value.cpp | 4 ++-- storage/connect/xobject.cpp | 6 +++--- 12 files changed, 45 insertions(+), 45 deletions(-) diff --git a/storage/connect/array.cpp b/storage/connect/array.cpp index 4b6e1df8e32..285469462fa 100644 --- a/storage/connect/array.cpp +++ b/storage/connect/array.cpp @@ -519,7 +519,7 @@ bool ARRAY::FilTest(PGLOBAL g, PVAL valp, OPVAL opc, int opm) } else if (opc != OP_EXIST) { sprintf(g->Message, MSG(MISSING_ARG), opc); - throw TYPE_ARRAY; + throw (int)TYPE_ARRAY; } else // OP_EXIST return Nval > 0; @@ -681,14 +681,14 @@ void ARRAY::SetPrecision(PGLOBAL g, int p) { if (Vblp == NULL) { strcpy(g->Message, MSG(PREC_VBLP_NULL)); - throw TYPE_ARRAY; + throw (int)TYPE_ARRAY; } // endif Vblp bool was = Vblp->IsCi(); if (was && !p) { strcpy(g->Message, MSG(BAD_SET_CASE)); - throw TYPE_ARRAY; + throw (int)TYPE_ARRAY; } // endif Vblp if (was || !p) @@ -699,7 +699,7 @@ void ARRAY::SetPrecision(PGLOBAL g, int p) if (!was && Type == TYPE_STRING) // Must be resorted to eliminate duplicate strings if (Sort(g)) - throw TYPE_ARRAY; + throw (int)TYPE_ARRAY; } // end of SetPrecision diff --git a/storage/connect/colblk.cpp b/storage/connect/colblk.cpp index e34c2a7252d..2ffe51d2009 100644 --- a/storage/connect/colblk.cpp +++ b/storage/connect/colblk.cpp @@ -197,7 +197,7 @@ int COLBLK::GetLengthEx(void) void COLBLK::ReadColumn(PGLOBAL g) { sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn"); - throw TYPE_COLBLK; + throw (int)TYPE_COLBLK; } // end of ReadColumn /***********************************************************************/ @@ -208,7 +208,7 @@ void COLBLK::ReadColumn(PGLOBAL g) void COLBLK::WriteColumn(PGLOBAL g) { sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn"); - throw TYPE_COLBLK; + throw (int)TYPE_COLBLK; } // end of WriteColumn /***********************************************************************/ @@ -262,7 +262,7 @@ SPCBLK::SPCBLK(PCOLUMN cp) void SPCBLK::WriteColumn(PGLOBAL g) { sprintf(g->Message, MSG(SPCOL_READONLY), Name); - throw TYPE_COLBLK; + throw (int)TYPE_COLBLK; } // end of WriteColumn /***********************************************************************/ diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc index e15cc724b85..00a2a0d16b6 100644 --- a/storage/connect/connect.cc +++ b/storage/connect/connect.cc @@ -188,7 +188,7 @@ PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h) PTDB tdbp; PTABLE tabp; PDBUSER dup = PlgGetUser(g); - volatile PCATLG cat = (dup) ? dup->Catalog : NULL; // Safe over longjmp + volatile PCATLG cat = (dup) ? dup->Catalog : NULL; // Safe over throw if (trace) printf("CntGetTDB: name=%s mode=%d cat=%p\n", name, mode, cat); diff --git a/storage/connect/filter.cpp b/storage/connect/filter.cpp index d1cf8909917..d4026f39c67 100644 --- a/storage/connect/filter.cpp +++ b/storage/connect/filter.cpp @@ -94,7 +94,7 @@ BYTE OpBmp(PGLOBAL g, OPVAL opc) case OP_EXIST: bt = 0x00; break; default: sprintf(g->Message, MSG(BAD_FILTER_OP), opc); - throw TYPE_ARRAY; + throw (int)TYPE_ARRAY; } // endswitch opc return bt; @@ -1804,7 +1804,7 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having) break; // Remove eventual ending separator(s) // if (fp->Convert(g, having)) -// throw TYPE_ARRAY; +// (int)throw TYPE_ARRAY; filp = fp; fp = fp->Next; @@ -1837,7 +1837,7 @@ DllExport bool ApplyFilter(PGLOBAL g, PFIL filp) // return TRUE; if (filp->Eval(g)) - throw TYPE_FILTER; + throw (int)TYPE_FILTER; if (trace > 1) htrc("PlugFilter filp=%p result=%d\n", diff --git a/storage/connect/jdbconn.cpp b/storage/connect/jdbconn.cpp index f077cd2182b..22e89a41efb 100644 --- a/storage/connect/jdbconn.cpp +++ b/storage/connect/jdbconn.cpp @@ -1215,7 +1215,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val) if (rank == 0) if (!name || (jn = env->NewStringUTF(name)) == nullptr) { sprintf(g->Message, "Fail to allocate jstring %s", SVP(name)); - throw TYPE_AM_JDBC; + throw (int)TYPE_AM_JDBC; } // endif name // Returns 666 is case of error @@ -1223,7 +1223,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val) if (Check((ctyp == 666) ? -1 : 1)) { sprintf(g->Message, "Getting ctyp: %s", Msg); - throw TYPE_AM_JDBC; + throw (int)TYPE_AM_JDBC; } // endif Check if (val->GetNullable()) @@ -1334,7 +1334,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val) env->DeleteLocalRef(jn); sprintf(g->Message, "SetColumnValue: %s rank=%d ctyp=%d", Msg, rank, (int)ctyp); - throw TYPE_AM_JDBC; + throw (int)TYPE_AM_JDBC; } // endif Check if (rank == 0) diff --git a/storage/connect/plgdbutl.cpp b/storage/connect/plgdbutl.cpp index c02c435baed..8acda9e3992 100644 --- a/storage/connect/plgdbutl.cpp +++ b/storage/connect/plgdbutl.cpp @@ -473,7 +473,7 @@ bool PlugEvalLike(PGLOBAL g, LPCSTR strg, LPCSTR pat, bool ci) tp = g->Message; else if (!(tp = new char[strlen(pat) + strlen(strg) + 2])) { strcpy(g->Message, MSG(NEW_RETURN_NULL)); - throw OP_LIKE; + throw (int)OP_LIKE; } /* endif tp */ sp = tp + strlen(pat) + 1; @@ -484,7 +484,7 @@ bool PlugEvalLike(PGLOBAL g, LPCSTR strg, LPCSTR pat, bool ci) tp = g->Message; /* Use this as temporary work space. */ else if (!(tp = new char[strlen(pat) + 1])) { strcpy(g->Message, MSG(NEW_RETURN_NULL)); - throw OP_LIKE; + throw (int)OP_LIKE; } /* endif tp */ strcpy(tp, pat); /* Make a copy to be worked into */ diff --git a/storage/connect/tabdos.cpp b/storage/connect/tabdos.cpp index ea7c07fbe96..e192ef202a9 100644 --- a/storage/connect/tabdos.cpp +++ b/storage/connect/tabdos.cpp @@ -2736,7 +2736,7 @@ void DOSCOL::WriteColumn(PGLOBAL g) if (Value->GetBinValue(p, Long, Status)) { sprintf(g->Message, MSG(BIN_F_TOO_LONG), Name, Value->GetSize(), Long); - longjmp(g->jumper[g->jump_level], 31); + throw 31; } // endif } // end of WriteColumn diff --git a/storage/connect/tabmgo.cpp b/storage/connect/tabmgo.cpp index 5a804a749e8..639affaac1c 100644 --- a/storage/connect/tabmgo.cpp +++ b/storage/connect/tabmgo.cpp @@ -1265,7 +1265,7 @@ char *MGOCOL::Mini(PGLOBAL g, const bson_t *bson, bool b) if (i >= Long) { sprintf(g->Message, "Value too long for column %s", Name); - throw(TYPE_AM_MGO); + throw (int)TYPE_AM_MGO; } // endif i Mbuf[k] = 0; @@ -1351,7 +1351,7 @@ void MGOCOL::ReadColumn(PGLOBAL g) bson_destroy(doc); } else { //strcpy(g->Message, "bson_iter_array failed (data is null)"); - //throw(TYPE_AM_MGO); + //throw (int)TYPE_AM_MGO; Value->Reset(); } // endif data diff --git a/storage/connect/tabvir.cpp b/storage/connect/tabvir.cpp index 84b3dd1787b..c78a8f531f6 100644 --- a/storage/connect/tabvir.cpp +++ b/storage/connect/tabvir.cpp @@ -289,7 +289,7 @@ void VIRCOL::ReadColumn(PGLOBAL g) { // This should never be called sprintf(g->Message, "ReadColumn: Column %s is not virtual", Name); - throw TYPE_COLBLK; + throw (int)TYPE_COLBLK; } // end of ReadColumn /* ---------------------------TDBVICL class -------------------------- */ diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp index 80d4395058e..6402f48e090 100644 --- a/storage/connect/tabxml.cpp +++ b/storage/connect/tabxml.cpp @@ -1319,7 +1319,7 @@ void TDBXML::CloseDB(PGLOBAL g) Docp->CloseDoc(g, To_Xb); // This causes a crash in Diagnostics_area::set_error_status -// throw TYPE_AM_XML; +// throw (int)TYPE_AM_XML; } // endif DumpDoc } // endif Changed @@ -1642,7 +1642,7 @@ void XMLCOL::ReadColumn(PGLOBAL g) if (ValNode->GetType() != XML_ELEMENT_NODE && ValNode->GetType() != XML_ATTRIBUTE_NODE) { sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name); - throw TYPE_AM_XML; + throw (int)TYPE_AM_XML; } // endif type // Get the Xname value from the XML file @@ -1653,7 +1653,7 @@ void XMLCOL::ReadColumn(PGLOBAL g) PushWarning(g, Tdbp); break; default: - throw TYPE_AM_XML; + throw (int)TYPE_AM_XML; } // endswitch Value->SetValue_psz(Valbuf); @@ -1704,7 +1704,7 @@ void XMLCOL::WriteColumn(PGLOBAL g) /* For columns having an Xpath, the Clist must be updated. */ /*********************************************************************/ if (Tdbp->CheckRow(g, Nod || Tdbp->Colname)) - throw TYPE_AM_XML; + throw (int)TYPE_AM_XML; /*********************************************************************/ /* Null values are represented by no node. */ @@ -1776,7 +1776,7 @@ void XMLCOL::WriteColumn(PGLOBAL g) if (ColNode == NULL) { strcpy(g->Message, MSG(COL_ALLOC_ERR)); - throw TYPE_AM_XML; + throw (int)TYPE_AM_XML; } // endif ColNode } // endif ColNode @@ -1795,7 +1795,7 @@ void XMLCOL::WriteColumn(PGLOBAL g) if (ValNode == NULL && AttNode == NULL) { strcpy(g->Message, MSG(VAL_ALLOC_ERR)); - longjmp(g->jumper[g->jump_level], TYPE_AM_XML); + throw (int)TYPE_AM_XML; } // endif ValNode /*********************************************************************/ @@ -1805,7 +1805,7 @@ void XMLCOL::WriteColumn(PGLOBAL g) if (strlen(p) > (unsigned)Long) { sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long); - throw TYPE_AM_XML; + throw (int)TYPE_AM_XML; } else strcpy(Valbuf, p); @@ -1855,7 +1855,7 @@ void XMULCOL::ReadColumn(PGLOBAL g) if (ValNode->GetType() != XML_ELEMENT_NODE && ValNode->GetType() != XML_ATTRIBUTE_NODE) { sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name); - throw TYPE_AM_XML; + throw (int)TYPE_AM_XML; } // endif type // Get the Xname value from the XML file @@ -1866,7 +1866,7 @@ void XMULCOL::ReadColumn(PGLOBAL g) PushWarning(g, Tdbp); break; default: - longjmp(g->jumper[g->jump_level], TYPE_AM_XML); + throw (int)TYPE_AM_XML; } // endswitch if (!b) { @@ -1941,7 +1941,7 @@ void XMULCOL::WriteColumn(PGLOBAL g) /* For columns having an Xpath, the Clist must be updated. */ /*********************************************************************/ if (Tdbp->CheckRow(g, Nod)) - throw TYPE_AM_XML; + throw (int)TYPE_AM_XML; /*********************************************************************/ /* Find the column and value nodes to update or insert. */ @@ -1990,7 +1990,7 @@ void XMULCOL::WriteColumn(PGLOBAL g) if (len > 1 && !Tdbp->Xpand) { sprintf(g->Message, MSG(BAD_VAL_UPDATE), Name); - throw TYPE_AM_XML; + throw (int)TYPE_AM_XML; } else ValNode = Nlx->GetItem(g, Tdbp->Nsub, Vxnp); @@ -2032,7 +2032,7 @@ void XMULCOL::WriteColumn(PGLOBAL g) if (ColNode == NULL) { strcpy(g->Message, MSG(COL_ALLOC_ERR)); - throw TYPE_AM_XML; + throw (int)TYPE_AM_XML; } // endif ColNode } // endif ColNode @@ -2051,8 +2051,8 @@ void XMULCOL::WriteColumn(PGLOBAL g) if (ValNode == NULL && AttNode == NULL) { strcpy(g->Message, MSG(VAL_ALLOC_ERR)); - longjmp(g->jumper[g->jump_level], TYPE_AM_XML); - } // endif ValNode + throw (int)TYPE_AM_XML; + } // endif ValNode /*********************************************************************/ /* Get the string representation of Value according to column type. */ @@ -2061,7 +2061,7 @@ void XMULCOL::WriteColumn(PGLOBAL g) if (strlen(p) > (unsigned)Long) { sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long); - throw TYPE_AM_XML; + throw (int)TYPE_AM_XML; } else strcpy(Valbuf, p); @@ -2093,7 +2093,7 @@ void XPOSCOL::ReadColumn(PGLOBAL g) if (Tdbp->Clist == NULL) { strcpy(g->Message, MSG(MIS_TAG_LIST)); - throw TYPE_AM_XML; + throw (int)TYPE_AM_XML; } // endif Clist if ((ValNode = Tdbp->Clist->GetItem(g, Rank, Vxnp))) { @@ -2105,7 +2105,7 @@ void XPOSCOL::ReadColumn(PGLOBAL g) PushWarning(g, Tdbp); break; default: - throw TYPE_AM_XML; + throw (int)TYPE_AM_XML; } // endswitch Value->SetValue_psz(Valbuf); @@ -2156,14 +2156,14 @@ void XPOSCOL::WriteColumn(PGLOBAL g) /* For all columns the Clist must be updated. */ /*********************************************************************/ if (Tdbp->CheckRow(g, true)) - throw TYPE_AM_XML; + throw (int)TYPE_AM_XML; /*********************************************************************/ /* Find the column and value nodes to update or insert. */ /*********************************************************************/ if (Tdbp->Clist == NULL) { strcpy(g->Message, MSG(MIS_TAG_LIST)); - throw TYPE_AM_XML; + throw (int)TYPE_AM_XML; } // endif Clist n = Tdbp->Clist->GetLength(); @@ -2188,7 +2188,7 @@ void XPOSCOL::WriteColumn(PGLOBAL g) if (strlen(p) > (unsigned)Long) { sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long); - throw TYPE_AM_XML; + throw (int)TYPE_AM_XML; } else strcpy(Valbuf, p); diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index b488f7aa061..236c8eaba1b 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -1451,7 +1451,7 @@ void TYPVAL::SetValue(uint n) if (k > Len) { sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len); - longjmp(g->jumper[g->jump_level], 138); + throw 138; } else SetValue_psz(buf); @@ -1505,7 +1505,7 @@ void TYPVAL::SetValue(ulonglong n) if (k > Len) { sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len); - longjmp(g->jumper[g->jump_level], 138); + throw 138; } else SetValue_psz(buf); diff --git a/storage/connect/xobject.cpp b/storage/connect/xobject.cpp index 6df3cee14bc..eca60561b92 100644 --- a/storage/connect/xobject.cpp +++ b/storage/connect/xobject.cpp @@ -84,7 +84,7 @@ double XOBJECT::GetFloatValue(void) CONSTANT::CONSTANT(PGLOBAL g, void *value, short type) { if (!(Value = AllocateValue(g, value, (int)type))) - throw TYPE_CONST; + throw (int)TYPE_CONST; Constant = true; } // end of CONSTANT constructor @@ -95,7 +95,7 @@ CONSTANT::CONSTANT(PGLOBAL g, void *value, short type) CONSTANT::CONSTANT(PGLOBAL g, int n) { if (!(Value = AllocateValue(g, &n, TYPE_INT))) - throw TYPE_CONST; + throw (int)TYPE_CONST; Constant = true; } // end of CONSTANT constructor @@ -117,7 +117,7 @@ void CONSTANT::Convert(PGLOBAL g, int newtype) { if (Value->GetType() != newtype) if (!(Value = AllocateValue(g, Value, newtype))) - throw TYPE_CONST; + throw (int)TYPE_CONST; } // end of Convert