From 57c5d061dc787b6d47320ea1ada0ae673aa07552 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Mon, 19 May 2014 05:54:22 -0700 Subject: [PATCH] Fix a bunch of warnings on Windows Most of them involve difference operations between 64b pointers with casting into 32b integers... --- connection.c | 6 +++--- convert.c | 24 ++++++++++++------------ info.c | 2 +- parse.c | 6 +++--- pgtypes.c | 4 ++-- setup.c | 4 ++-- statement.c | 4 ++-- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/connection.c b/connection.c index 86bf237..166f0dd 100644 --- a/connection.c +++ b/connection.c @@ -3208,9 +3208,9 @@ inolog("Discarded the first SAVEPOINT\n"); size_t alsize = 256, pos, len; char *buf = malloc(alsize), *tmpbuf, tchar; - for (pos = 0; NULL != fgets(buf + pos, alsize - pos, stdin);) + for (pos = 0; NULL != fgets(buf + pos, (int) (alsize - pos), stdin);) { - len = strlen(buf); + len = (int) strlen(buf); mylog("get copydata len=%d %02x%02x\n", len, ((UCHAR *) buf)[0], ((UCHAR *) buf)[1]); tchar = buf[len - 1]; @@ -3238,7 +3238,7 @@ mylog("get copydata len=%d %02x%02x\n", len, ((UCHAR *) buf)[0], ((UCHAR *) buf) } } SOCK_put_char(self->sock, 'd'); /* CopyData */ - SOCK_put_int(self->sock, 4 + len, 4); + SOCK_put_int(self->sock, (int) (4 + len), 4); SOCK_put_n_char(self->sock, buf, len); pos = 0; } diff --git a/convert.c b/convert.c index 1fef061..f7dd80e 100644 --- a/convert.c +++ b/convert.c @@ -1177,7 +1177,7 @@ inolog("2stime fr=%d\n", std_time.fr); /* sprintf(rgbValueBindRow, "%.4d-%.2d-%.2d %.2d:%.2d:%.2d", std_time.y, std_time.m, std_time.d, std_time.hh, std_time.mm, std_time.ss); */ stime2timestamp(&std_time, rgbValueBindRow, FALSE, - PG_VERSION_GE(conn, 7.2) ? (int) cbValueMax - len - 2 : 0); + PG_VERSION_GE(conn, 7.2) ? (int) (cbValueMax - len - 2) : 0); len = strlen(rgbValueBindRow); } break; @@ -3183,7 +3183,7 @@ Int4 findTag(const char *tag, char dollar_quote, int ccsc) continue; if (dollar_quote == tchar) { - taglen = sptr - tag + 1; + taglen = (Int4) (sptr - tag + 1); break; } if (isspace(tchar)) @@ -3230,7 +3230,7 @@ Int4 findIdentifier(const char *str, int ccsc, const char **nextdel) sptr++; continue; } - strlen = sptr - str + 1; + strlen = (Int4) (sptr - str + 1); sptr++; break; } @@ -3241,7 +3241,7 @@ Int4 findIdentifier(const char *str, int ccsc, const char **nextdel) continue; if (isspace(tchar)) { - strlen = sptr - str; + strlen = (Int4) (sptr - str); break; } switch (tchar) @@ -3250,7 +3250,7 @@ Int4 findIdentifier(const char *str, int ccsc, const char **nextdel) case '$': continue; } - strlen = sptr - str; + strlen = (Int4) (sptr - str); *nextdel = sptr; break; } @@ -3653,7 +3653,7 @@ BOOL BuildBindRequest(StatementClass *stmt, const char *plan_name) CSTR func = "BuildBindRequest"; QueryBuild qb; size_t leng, plen; - UInt4 netleng; + Int4 netleng; SQLSMALLINT num_p; Int2 netnum_p; int i, num_params; @@ -3681,13 +3681,13 @@ BOOL BuildBindRequest(StatementClass *stmt, const char *plan_name) * sure there's enough space for all the fields before the parameter * values, without enlarging. */ - plen = strlen(plan_name); - netleng = sizeof(netleng) /* length fields */ + plen = strlen(plan_name); + netleng = (Int4) (sizeof(netleng) /* length fields */ + 2 * (plen + 1) /* portal and plan name */ + sizeof(Int2) /* number of param format codes */ + sizeof(Int2) * num_params /* parameter types (max) */ + sizeof(Int2) /* result format */ - + 1; + + 1); if (QB_initialize(&qb, netleng > MIN_ALC_SIZE ? netleng : MIN_ALC_SIZE, stmt, NULL) < 0) { return FALSE; @@ -4052,7 +4052,7 @@ inolog("ipara=%p paramType=%d %d proc_return=%d\n", ipara, ipara ? ipara->paramT } if (outputDiscard) { - for (npos = qb->npos - 1; npos >= 0 && isspace((unsigned char) qb->query_statement[npos]) ; npos--) ; + for (npos = (int) (qb->npos) - 1; npos >= 0 && isspace((unsigned char) qb->query_statement[npos]) ; npos--) ; if (npos >= 0) { switch (qb->query_statement[npos]) @@ -4064,7 +4064,7 @@ inolog("ipara=%p paramType=%d %d proc_return=%d\n", ipara, ipara ? ipara->paramT case '(': if (!qp) break; - for (npos = qp->opos + 1; isspace((unsigned char) qp->statement[npos]); npos++) ; + for (npos = (int) (qp->opos) + 1; isspace((unsigned char) qp->statement[npos]); npos++) ; if (qp->statement[npos] == ',') qp->opos = npos; break; @@ -4160,7 +4160,7 @@ inolog("ipara=%p paramType=%d %d proc_return=%d\n", ipara, ipara ? ipara->paramT } */ if (req_bind) { - npos = qb->npos; + npos = (int) qb->npos; ENLARGE_NEWSTATEMENT(qb, npos + 4); qb->npos += 4; } diff --git a/info.c b/info.c index 81bfe6d..e8410ff 100644 --- a/info.c +++ b/info.c @@ -1501,7 +1501,7 @@ allow_public_schema(ConnectionClass *conn, const SQLCHAR *szSchemaName, SQLSMALL return FALSE; if (SQL_NTS == cbSchemaName) - cbSchemaName = strlen((char *) szSchemaName); + cbSchemaName = (SQLSMALLINT) strlen((char *) szSchemaName); return (cbSchemaName == (SQLSMALLINT) userlen && strnicmp((char *) szSchemaName, user, userlen) == 0 && diff --git a/parse.c b/parse.c index 5aa7723..8d8dba6 100644 --- a/parse.c +++ b/parse.c @@ -141,7 +141,7 @@ getNextToken( tag = s + i; taglen = 1; if (tagend = strchr(s + i + 1, dollar_quote), NULL != tagend) - taglen = tagend - s - i + 1; + taglen = (int) (tagend - s - i + 1); i += (taglen - 1); encoded_position_shift(&encstr, taglen - 1); if (quote) @@ -1339,7 +1339,7 @@ parse_the_statement(StatementClass *stmt, BOOL check_hasoids, BOOL sqlsvr_check) (!strnicmp(pptr, "from", 4))) { mylog("First "); - stmt->from_pos = pptr - stmt->statement; + stmt->from_pos = (int) (pptr - stmt->statement); } mylog("FROM\n"); @@ -1358,7 +1358,7 @@ parse_the_statement(StatementClass *stmt, BOOL check_hasoids, BOOL sqlsvr_check) in_where = TRUE; if (stmt->where_pos < 0) - stmt->where_pos = pptr - stmt->statement; + stmt->where_pos = (int) (pptr - stmt->statement); mylog("%s...\n", token); if (stricmp(token, "where") && stricmp(token, "order")) diff --git a/pgtypes.c b/pgtypes.c index d7bde0a..07dc223 100644 --- a/pgtypes.c +++ b/pgtypes.c @@ -1482,7 +1482,7 @@ getAtttypmodEtc(const StatementClass *stmt, int col, int *adtsize_or_longestlen) atttypmod < 0 && *adtsize_or_longestlen > 0) { - int i, sval, maxscale = 0; + size_t i, sval, maxscale = 0; const char *tval, *sptr; for (i = 0; i < res->num_cached_rows; i++) @@ -1494,7 +1494,7 @@ getAtttypmodEtc(const StatementClass *stmt, int col, int *adtsize_or_longestlen) maxscale = sval; } } - *adtsize_or_longestlen += (maxscale << 16); + *adtsize_or_longestlen += (int) (maxscale << 16); } } } diff --git a/setup.c b/setup.c index 408f0e8..d9e768b 100644 --- a/setup.c +++ b/setup.c @@ -390,7 +390,7 @@ ConfigDlgProc(HWND hdlg, CC_get_error(conn, &errnum, &emsg); } #ifdef UNICODE_SUPPORT - tlen = strlen(emsg); + tlen = (int) strlen(emsg); wermsg = (SQLWCHAR *) malloc(sizeof(SQLWCHAR) * (tlen + 1)); ulen = utf8_to_ucs2_lf(emsg, SQL_NTS, FALSE, wermsg, tlen + 1, TRUE); if (ulen != (SQLULEN) -1) @@ -487,7 +487,7 @@ ParseAttributes(LPCSTR lpszAttributes, LPSETUPDLG lpsetupdlg) break; /* Valid key found */ } /* Determine the key's index in the key table (-1 if not found) */ - cbKey = lpsz - lpszStart; + cbKey = (int) (lpsz - lpszStart); if (cbKey < sizeof(aszKey)) { _fmemcpy(aszKey, lpszStart, cbKey); diff --git a/statement.c b/statement.c index 0aa31ce..7f97512 100644 --- a/statement.c +++ b/statement.c @@ -1042,7 +1042,7 @@ SC_scanQueryAndCountParams(const char *query, const ConnectionClass *conn, { del_found = TRUE; if (next_cmd) - *next_cmd = sptr - query; + *next_cmd = (int) (sptr - query); } else if (tchar == dollar_quote) { @@ -2866,7 +2866,7 @@ SendParseRequest(StatementClass *stmt, const char *plan_name, const char *query, mylog("sta_pidx=%d end_pidx=%d num_p=%d\n", sta_pidx, end_pidx, num_params); pileng += (sizeof(UInt4) * num_params); } - qlen = (SQL_NTS == qlen) ? strlen(query) : qlen; + qlen = (SQL_NTS == qlen) ? (Int4) strlen(query) : qlen; leng = strlen(plan_name) + 1 + qlen + 1 + pileng; SOCK_put_int(sock, (Int4) (leng + 4), 4); /* length */ inolog("parse leng=" FORMAT_SIZE_T "\n", leng); -- 1.9.3