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