Commit c22e6eed authored by Monty's avatar Monty

Fix compiler warnings in connect engine

- Removed not used variables
- Added /* fall through */ to switches
- Removed not used static variable 'slash' from header file
- Removed test of fp->field_length >= 0 as it is always true
parent 93bb755d
......@@ -83,7 +83,7 @@ BDOC::BDOC(PGLOBAL G) : BJSON(G, NULL)
PBVAL BDOC::ParseJson(PGLOBAL g, char* js, size_t lng)
{
size_t i;
bool b = false, ptyp = (bool *)pty;
bool b = false;
PBVAL bvp = NULL;
s = js;
......@@ -145,7 +145,7 @@ PBVAL BDOC::ParseJson(PGLOBAL g, char* js, size_t lng)
b = false;
break;
} // endif b
/* fall through */
default:
if (bvp->Type != TYPE_UNKNOWN) {
bvp->To_Val = ParseAsArray(i);
......@@ -683,7 +683,7 @@ bool BDOC::SerializeArray(OFFSET arp, bool b)
} else if (jp->WriteChr('['))
return true;
for (vp; vp; vp = MVP(vp->Next)) {
for (; vp; vp = MVP(vp->Next)) {
if (first)
first = false;
else if ((!b || jp->Prty()) && jp->WriteChr(','))
......@@ -718,7 +718,7 @@ bool BDOC::SerializeObject(OFFSET obp)
if (jp->WriteChr('{'))
return true;
for (prp; prp; prp = GetNext(prp)) {
for (; prp; prp = GetNext(prp)) {
if (first)
first = false;
else if (jp->WriteChr(','))
......
......@@ -87,6 +87,7 @@ static PBSON BbinAlloc(PGLOBAL g, ulong len, PBVAL jsp)
/*********************************************************************************/
/* SubAlloc a new BJNX class with protection against memory exhaustion. */
/*********************************************************************************/
#ifdef NOT_USED
static PBJNX BjnxNew(PGLOBAL g, PBVAL vlp, int type, int len)
{
PBJNX bjnx;
......@@ -103,7 +104,7 @@ static PBJNX BjnxNew(PGLOBAL g, PBVAL vlp, int type, int len)
return bjnx;
} /* end of BjnxNew */
#endif
/* ----------------------------------- BSNX ------------------------------------ */
/*********************************************************************************/
......@@ -320,7 +321,7 @@ my_bool BJNX::ParseJpath(PGLOBAL g)
{
char* p, * p1 = NULL, * p2 = NULL, * pbuf = NULL;
int i;
my_bool a, mul = false;
my_bool a;
if (Parsed)
return false; // Already done
......@@ -529,6 +530,7 @@ void BJNX::SetJsonValue(PGLOBAL g, PVAL vp, PBVAL vlp)
break;
case TYPE_NULL:
vp->SetNull(true);
/* fall through */
default:
vp->Reset();
} // endswitch Type
......@@ -572,7 +574,6 @@ PVAL BJNX::GetColumnValue(PGLOBAL g, PBVAL row, int i)
/*********************************************************************************/
PBVAL BJNX::GetRowValue(PGLOBAL g, PBVAL row, int i)
{
my_bool expd = false;
PBVAL bap;
PBVAL vlp = NULL;
......@@ -1115,7 +1116,7 @@ my_bool BJNX::CheckPath(PGLOBAL g, UDF_ARGS *args, PBVAL jsp, PBVAL& jvp, int n)
PSZ BJNX::Locate(PGLOBAL g, PBVAL jsp, PBVAL jvp, int k)
{
PSZ str = NULL;
my_bool b = false, err = true;
my_bool err = true;
g->Message[0] = 0;
......@@ -1236,7 +1237,7 @@ my_bool BJNX::LocateValue(PGLOBAL g, PBVAL jvp)
PSZ BJNX::LocateAll(PGLOBAL g, PBVAL jsp, PBVAL bvp, int mx)
{
PSZ str = NULL;
my_bool b = false, err = true;
my_bool err = true;
PJPN jnp;
if (!jsp) {
......@@ -2926,7 +2927,7 @@ my_bool bson_array_grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
return true;
PGLOBAL g = (PGLOBAL)initid->ptr;
PBJNX bxp = new(g) BJNX(g);
(void) new(g) BJNX(g);
JsonMemSave(g);
return false;
......@@ -2999,7 +3000,7 @@ my_bool bson_object_grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
return true;
PGLOBAL g = (PGLOBAL)initid->ptr;
PBJNX bxp = new(g) BJNX(g);
(void) new(g) BJNX(g);
JsonMemSave(g);
return false;
......@@ -3069,7 +3070,7 @@ my_bool bson_test_init(UDF_INIT* initid, UDF_ARGS* args, char* message) {
char* bson_test(UDF_INIT* initid, UDF_ARGS* args, char* result,
unsigned long* res_length, char* is_null, char* error) {
char* str = NULL, * sap = NULL, * fn = NULL;
char* str = NULL, * fn = NULL;
int pretty = 1;
PBVAL bvp;
PGLOBAL g = (PGLOBAL)initid->ptr;
......@@ -5067,7 +5068,7 @@ char* bbin_array_add_values(UDF_INIT* initid, UDF_ARGS* args, char* result,
if (!CheckMemory(g, initid, args, args->arg_count, true)) {
uint i = 0;
BJNX bnx(g);
PBVAL arp, top, jvp = NULL;
PBVAL arp, top;
PBVAL bvp = bnx.MakeValue(args, 0, true, &top);
if (bvp->Type == TYPE_JAR) {
......@@ -5691,7 +5692,7 @@ char *bbin_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
if (g->Xchk) {
bsp = (PBSON)g->Xchk;
} else if (!CheckMemory(g, initid, args, 1, true, true)) {
char *path = MakePSZ(g, args, 1);
// char *path = MakePSZ(g, args, 1);
BJNX bnx(g, NULL, TYPE_STRING, initid->max_length);
PBVAL top, jvp = NULL;
PBVAL jsp = bnx.MakeValue(args, 0, true, &top);
......
......@@ -1609,15 +1609,15 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf)
pcf->Scale= 0;
pcf->Opt= (fop) ? (int)fop->opt : 0;
if (fp->field_length >= 0) {
// if (fp->field_length >= 0) {
pcf->Length = fp->field_length;
// length is bytes for Connect, not characters
if (!strnicmp(chset, "utf8", 4))
pcf->Length /= 3;
} else
pcf->Length= 256; // BLOB?
// } else
// pcf->Length= 256; // BLOB?
pcf->Precision= pcf->Length;
......
......@@ -117,7 +117,7 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v)
else
len = MY_MIN(abs(len), GetConvSize());
// Pass through
/* fall through */
case 12: // VARCHAR
if (tn && !stricmp(tn, "TEXT"))
// Postgresql returns 12 for TEXT
......@@ -128,14 +128,14 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v)
if (len == 0x7FFFFFFF)
len = GetConvSize();
// Pass through
/* fall through */
case -9: // NVARCHAR (unicode)
// Postgresql can return this when size is unknown
if (len == 0x7FFFFFFF)
len = GetConvSize();
v = 'V';
// Pass through
/* fall through */
case 1: // CHAR
case -15: // NCHAR (unicode)
case -8: // ROWID
......@@ -194,7 +194,7 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v)
break;
} // endif tn
// Pass through
/* fall through */
case 0: // NULL
case -2: // BINARY
case -4: // LONGVARBINARY
......@@ -766,7 +766,6 @@ void JDBConn::AddJars(PSTRG jpop, char sep)
/***********************************************************************/
bool JDBConn::Connect(PJPARM sop)
{
int irc = RC_FX;
bool err = false;
jint rc;
PGLOBAL& g = m_G;
......@@ -1087,7 +1086,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
break;
case 0: // NULL
val->SetNull(true);
// passthru
/* fall through */
default:
val->Reset();
} // endswitch Type
......
......@@ -1001,7 +1001,7 @@ int JOBJECT::GetSize(bool b) {
for (PJPR jpp = First; jpp; jpp = jpp->Next)
// If b return only non null pairs
if (!b || jpp->Val && !jpp->Val->IsNull())
if (!b || (jpp->Val && !jpp->Val->IsNull()))
n++;
return n;
......@@ -1530,10 +1530,12 @@ PVAL JVALUE::GetValue(PGLOBAL g)
PVAL valp = NULL;
if (DataType != TYPE_JSON)
{
if (DataType == TYPE_STRG)
valp = AllocateValue(g, Strp, DataType, Nd);
else
valp = AllocateValue(g, &LLn, DataType, Nd);
}
return valp;
} // end of GetValue
......@@ -1704,6 +1706,7 @@ void JVALUE::SetValue(PGLOBAL g, PVAL valp)
case TYPE_TINY:
B = valp->GetTinyValue() != 0;
DataType = TYPE_BOOL;
break;
case TYPE_INT:
N = valp->GetIntValue();
DataType = TYPE_INTG;
......
......@@ -508,7 +508,7 @@ PTABDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am)
tdp = new(g) MGODEF;
break;
} // endif enabled
// fall through
/* fall through */
#endif // JAVA_SUPPORT || CMGO_SUPPORT
default:
sprintf(g->Message, MSG(BAD_TABLE_TYPE), am, name);
......
......@@ -125,17 +125,20 @@ int TranslateSQLType(int stp, int prec, int& len, char& v, bool& w)
switch (stp) {
case SQL_WVARCHAR: // (-9)
w = true;
/* fall through */
case SQL_VARCHAR: // 12
v = 'V';
type = TYPE_STRING;
break;
case SQL_WCHAR: // (-8)
w = true;
/* fall through */
case SQL_CHAR: // 1
type = TYPE_STRING;
break;
case SQL_WLONGVARCHAR: // (-10)
w = true;
/* fall through */
case SQL_LONGVARCHAR: // (-1)
if (GetTypeConv() == TPC_YES || GetTypeConv() == TPC_FORCE) {
v = 'V';
......@@ -2344,6 +2347,7 @@ int ODBConn::GetCatInfo(CATPARM *cap)
break;
case CAT_SPC:
ThrowDBX("SQLSpecialColumns not available yet");
break;
default:
ThrowDBX("Invalid SQL function id");
} // endswitch infotype
......
......@@ -824,7 +824,7 @@ PBVAL BCUTIL::MakeBson(PGLOBAL g, PBVAL jsp, int n)
/***********************************************************************/
PBVAL BCUTIL::GetRowValue(PGLOBAL g, PBVAL row, int i)
{
int nod = Cp->Nod, n = nod - 1;
int nod = Cp->Nod;
JNODE *nodes = Cp->Nodes;
PBVAL arp;
PBVAL bvp = NULL;
......@@ -1956,6 +1956,7 @@ PSZ BSONCOL::GetJpath(PGLOBAL g, bool proj)
return NULL;
for (p1 = p2 = mgopath; *p1; p1++)
{
if (i) { // Inside []
if (isdigit(*p1)) {
if (!proj)
......@@ -1993,12 +1994,12 @@ PSZ BSONCOL::GetJpath(PGLOBAL g, bool proj)
p2--; // Suppress last :*
break;
} // endif p2
/* fall through */
default:
*p2++ = *p1;
break;
} // endswitch p1;
}
*p2 = 0;
return mgopath;
} else
......
......@@ -1023,7 +1023,6 @@ bool TDBJSN::OpenDB(PGLOBAL g)
/*********************************************************************/
/* Lrecl is Ok. */
/*********************************************************************/
size_t linelen = Lrecl;
MODE mode = Mode;
// Buffer must be allocated in g->Sarea
......@@ -1732,7 +1731,6 @@ void JSONCOL::ReadColumn(PGLOBAL g)
/***********************************************************************/
PVAL JSONCOL::GetColumnValue(PGLOBAL g, PJSON row, int i)
{
int n = Nod - 1;
PJAR arp;
PJVAL val = NULL;
......
......@@ -6,9 +6,7 @@
#pragma once
#if defined(__WIN__)
static PCSZ slash = "\\";
#else // !__WIN__
static PCSZ slash = "/";
#define stricmp strcasecmp
#endif // !__WIN__
......
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