Skip to content

Commit dd90bae

Browse files
committed
Fix compiler warnings in mapmssql2008.c
1 parent 91ef9a6 commit dd90bae

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,6 @@ if(ORACLE_FOUND AND WITH_ORACLE_PLUGIN)
544544
endif(ORACLE_FOUND AND WITH_ORACLE_PLUGIN)
545545

546546
if(WITH_MSSQL2008)
547-
# Temporarily suppress warnings for mapmssql2008.c
548-
set_source_files_properties(mapmssql2008.c PROPERTIES COMPILE_FLAGS /w)
549547
find_package(ODBC)
550548
if(ODBC_FOUND)
551549
add_library(msplugin_mssql2008 MODULE mapmssql2008.c)

mapmssql2008.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ void setMSSQL2008LayerInfo(layerObj *layer, msMSSQL2008LayerInfo *MSSQL2008layer
639639
void handleSQLError(layerObj *layer)
640640
{
641641
SQLCHAR SqlState[6], Msg[SQL_MAX_MESSAGE_LENGTH];
642-
SQLLEN NativeError;
642+
SQLINTEGER NativeError;
643643
SQLSMALLINT i, MsgLen;
644644
SQLRETURN rc;
645645
msMSSQL2008LayerInfo *layerinfo = getMSSQL2008LayerInfo(layer);
@@ -662,7 +662,7 @@ void handleSQLError(layerObj *layer)
662662
/* dont send in empty strings or strings with just " " in them! */
663663
static char* removeWhite(char *str)
664664
{
665-
int initial;
665+
size_t initial;
666666
char *orig, *loc;
667667

668668
initial = strspn(str, " ");
@@ -690,10 +690,10 @@ static char *strstrIgnoreCase(const char *haystack, const char *needle)
690690
{
691691
char *hay_lower;
692692
char *needle_lower;
693-
int len_hay,len_need;
693+
size_t len_hay,len_need, match;
694+
int found = -1;
694695
int t;
695696
char *loc;
696-
int match = -1;
697697

698698
len_hay = strlen(haystack);
699699
len_need = strlen(needle);
@@ -715,12 +715,13 @@ static char *strstrIgnoreCase(const char *haystack, const char *needle)
715715
loc = strstr(hay_lower, needle_lower);
716716
if(loc) {
717717
match = loc - hay_lower;
718+
found = 1;
718719
}
719720

720721
msFree(hay_lower);
721722
msFree(needle_lower);
722723

723-
return (char *) (match < 0 ? NULL : haystack + match);
724+
return (char *) (found < 0 ? NULL : haystack + match);
724725
}
725726

726727
static int msMSSQL2008LayerParseData(layerObj *layer, char **geom_column_name, char **geom_column_type, char **table_name, char **urid_name, char **user_srid, char **index_name, char **sort_spec, int debug);
@@ -759,7 +760,7 @@ static void setConnError(msODBCconn *conn)
759760
}
760761

761762
/* Connect to db */
762-
static msODBCconn * mssql2008Connect(const char * connString)
763+
static msODBCconn * mssql2008Connect(char * connString)
763764
{
764765
SQLCHAR outConnString[1024];
765766
SQLSMALLINT outConnStringLen;
@@ -906,7 +907,7 @@ static int columnName(msODBCconn *conn, int index, char *buffer, int bufferLengt
906907
}
907908

908909
if( columnSize > 0 )
909-
sprintf( gml_width, "%d", columnSize );
910+
sprintf( gml_width, "%u", (unsigned int)columnSize );
910911

911912
snprintf( md_item_name, sizeof(md_item_name), "gml_%s_type", buffer );
912913
if( msOWSLookupMetadata(&(layer->metadata), "G", "type") == NULL )
@@ -1352,7 +1353,6 @@ static int prepare_database(layerObj *layer, rectObj rect, char **query_string)
13521353
int t;
13531354

13541355
char *pos_from, *pos_ftab, *pos_space, *pos_paren;
1355-
rectObj extent;
13561356
int hasFilter = MS_FALSE;
13571357

13581358
layerinfo = getMSSQL2008LayerInfo(layer);
@@ -2289,7 +2289,7 @@ int msMSSQL2008LayerGetShapeRandom(layerObj *layer, shapeObj *shape, long *recor
22892289

22902290
if (layerinfo->geometry_format == MSSQLGEOMETRY_NATIVE) {
22912291
layerinfo->gpi.pszData = (unsigned char*)wkbBuffer;
2292-
layerinfo->gpi.nLen = retLen;
2292+
layerinfo->gpi.nLen = (int)retLen;
22932293

22942294
if (!ParseSqlGeometry(layerinfo, shape)) {
22952295
switch(layer->type) {
@@ -2559,7 +2559,7 @@ int msMSSQL2008LayerGetShapeCount(layerObj *layer, rectObj rect, projectionObj *
25592559
{
25602560
// If we cannot guess the EPSG code of the rectProjection, fallback on slow implementation
25612561
if (rectProjection->numargs < 1 ||
2562-
strncasecmp(rectProjection->args[0], "init=epsg:", strlen("init=epsg:")) != 0)
2562+
strncasecmp(rectProjection->args[0], "init=epsg:", (int)strlen("init=epsg:")) != 0)
25632563
{
25642564
if (layer->debug) {
25652565
msDebug("msMSSQL2008LayerGetShapeCount(): cannot find EPSG code of rectProjection. Falling back on client-side feature count.\n");
@@ -2655,9 +2655,9 @@ int msMSSQL2008LayerGetItems(layerObj *layer)
26552655
{
26562656
msMSSQL2008LayerInfo *layerinfo;
26572657
char *sql = NULL;
2658-
int t, sqlSize;
2658+
size_t sqlSize;
26592659
char found_geom = 0;
2660-
int item_num;
2660+
int t, item_num;
26612661
SQLSMALLINT cols = 0;
26622662
const char *value;
26632663
/*
@@ -2826,7 +2826,7 @@ int msMSSQL2008LayerRetrievePK(layerObj *layer, char **urid_name, char* table_na
28262826
static int msMSSQL2008LayerParseData(layerObj *layer, char **geom_column_name, char **geom_column_type, char **table_name, char **urid_name, char **user_srid, char **index_name, char **sort_spec, int debug)
28272827
{
28282828
char *pos_opt, *pos_scn, *tmp, *pos_srid, *pos_urid, *pos_geomtype, *pos_geomtype2, *pos_indexHint, *data, *pos_order;
2829-
int slength;
2829+
size_t slength;
28302830

28312831
data = msStrdup(layer->data);
28322832
/* replace tabs with spaces */
@@ -2965,7 +2965,7 @@ char *msMSSQL2008LayerEscapePropertyName(layerObj *layer, const char* pszString)
29652965
int i, j = 0;
29662966

29672967
if (pszString && strlen(pszString) > 0) {
2968-
int nLength = strlen(pszString);
2968+
size_t nLength = strlen(pszString);
29692969

29702970
pszEscapedStr = (char*) msSmallMalloc( 1 + nLength + 1 + 1);
29712971
pszEscapedStr[j++] = '[';

0 commit comments

Comments
 (0)