Skip to content

Commit edc7783

Browse files
committed
textlayout: declare variables when they are used
Fixes various -Wunused warnings.
1 parent ecb47d4 commit edc7783

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

mapogcfilter.c

+10-16
Original file line numberDiff line numberDiff line change
@@ -2176,10 +2176,6 @@ const char* FLTGetDuring(FilterEncodingNode *psFilterNode, const char** ppszTime
21762176
char *FLTGetSQLExpression(FilterEncodingNode *psFilterNode, layerObj *lp)
21772177
{
21782178
char *pszExpression = NULL;
2179-
const char *pszAttribute = NULL;
2180-
char szTmp[256];
2181-
char **tokens = NULL;
2182-
int nTokens = 0, i=0, bString=0;
21832179

21842180
if (psFilterNode == NULL || lp == NULL)
21852181
return NULL;
@@ -2218,12 +2214,13 @@ char *FLTGetSQLExpression(FilterEncodingNode *psFilterNode, layerObj *lp)
22182214
} else if (psFilterNode->eType == FILTER_NODE_TYPE_FEATUREID) {
22192215
#if defined(USE_WMS_SVR) || defined (USE_WFS_SVR) || defined (USE_WCS_SVR) || defined(USE_SOS_SVR)
22202216
if (psFilterNode->pszValue) {
2221-
pszAttribute = msOWSLookupMetadata(&(lp->metadata), "OFG", "featureid");
2217+
const char *pszAttribute = msOWSLookupMetadata(&(lp->metadata), "OFG", "featureid");
22222218
if (pszAttribute) {
2223-
tokens = msStringSplit(psFilterNode->pszValue,',', &nTokens);
2224-
bString = 0;
2219+
int nTokens = 0;
2220+
char **tokens = msStringSplit(psFilterNode->pszValue,',', &nTokens);
2221+
int bString = 0;
22252222
if (tokens && nTokens > 0) {
2226-
for (i=0; i<nTokens; i++) {
2223+
for (int i=0; i<nTokens; i++) {
22272224
char *pszEscapedStr = NULL;
22282225
const char* pszId = tokens[i];
22292226
const char* pszDot = strchr(pszId, '.');
@@ -2237,6 +2234,7 @@ char *FLTGetSQLExpression(FilterEncodingNode *psFilterNode, layerObj *lp)
22372234
bString = 1;
22382235

22392236
pszEscapedStr = msLayerEscapeSQLParam(lp, pszId);
2237+
char szTmp[256];
22402238
if (bString)
22412239
{
22422240
if( lp->connectiontype == MS_OGR || lp->connectiontype == MS_POSTGIS )
@@ -3128,19 +3126,14 @@ static void FLTRemoveGroupName(FilterEncodingNode *psFilterNode,
31283126
void FLTPreParseFilterForAliasAndGroup(FilterEncodingNode *psFilterNode,
31293127
mapObj *map, int i, const char *namespaces)
31303128
{
3131-
layerObj *lp=NULL;
3132-
char szTmp[256];
3133-
const char *pszFullName = NULL;
3134-
int layerWasOpened = MS_FALSE;
3135-
31363129
#if defined(USE_WMS_SVR) || defined (USE_WFS_SVR) || defined (USE_WCS_SVR) || defined(USE_SOS_SVR)
31373130

31383131
if (psFilterNode && map && i>=0 && i<map->numlayers) {
31393132
/*strip name spaces before hand*/
31403133
FLTStripNameSpacesFromPropertyName(psFilterNode);
31413134

3142-
lp = GET_LAYER(map, i);
3143-
layerWasOpened = msLayerIsOpen(lp);
3135+
layerObj *lp = GET_LAYER(map, i);
3136+
int layerWasOpened = msLayerIsOpen(lp);
31443137
if (msLayerOpen(lp) == MS_SUCCESS && msLayerGetItems(lp) == MS_SUCCESS) {
31453138

31463139
/* Remove group names from property names if using groupname/itemname syntax */
@@ -3152,8 +3145,9 @@ void FLTPreParseFilterForAliasAndGroup(FilterEncodingNode *psFilterNode,
31523145
for(i=0; i<lp->numitems; i++) {
31533146
if (!lp->items[i] || strlen(lp->items[i]) <= 0)
31543147
continue;
3148+
char szTmp[256];
31553149
snprintf(szTmp, sizeof(szTmp), "%s_alias", lp->items[i]);
3156-
pszFullName = msOWSLookupMetadata(&(lp->metadata), namespaces, szTmp);
3150+
const char *pszFullName = msOWSLookupMetadata(&(lp->metadata), namespaces, szTmp);
31573151
if (pszFullName) {
31583152
FLTReplacePropertyName(psFilterNode, pszFullName,
31593153
lp->items[i]);

mapogcfiltercommon.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -579,24 +579,23 @@ char *FLTGetSpatialComparisonCommonExpression(FilterEncodingNode *psNode, layerO
579579
char *FLTGetFeatureIdCommonExpression(FilterEncodingNode *psFilterNode, layerObj *lp)
580580
{
581581
char *pszExpression = NULL;
582-
int nTokens = 0, i=0, bString=0;
583-
char **tokens = NULL;
584-
const char *pszAttribute=NULL;
585582

586583
#if defined(USE_WMS_SVR) || defined(USE_WFS_SVR) || defined(USE_WCS_SVR) || defined(USE_SOS_SVR)
587584
if (psFilterNode->pszValue) {
588-
pszAttribute = msOWSLookupMetadata(&(lp->metadata), "OFG", "featureid");
585+
const char *pszAttribute = msOWSLookupMetadata(&(lp->metadata), "OFG", "featureid");
589586
if (pszAttribute) {
590-
tokens = msStringSplit(psFilterNode->pszValue,',', &nTokens);
587+
int nTokens = 0;
588+
char **tokens = msStringSplit(psFilterNode->pszValue,',', &nTokens);
591589
if (tokens && nTokens > 0) {
592-
for (i=0; i<nTokens; i++) {
590+
for (int i=0; i<nTokens; i++) {
593591
char *pszTmp = NULL;
594592
int bufferSize = 0;
595593
const char* pszId = tokens[i];
596594
const char* pszDot = strrchr(pszId, '.');
597595
if( pszDot )
598596
pszId = pszDot + 1;
599597

598+
int bString=0;
600599
if (i == 0) {
601600
if(FLTIsNumeric(pszId) == MS_FALSE)
602601
bString = 1;

textlayout.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,6 @@ int msLayoutTextSymbol(mapObj *map, textSymbolObj *ts, textPathObj *tgret) {
696696

697697

698698
for(i=0;i<nruns;i++) {
699-
unsigned int glyph_count,j;
700699
if(!runs[i].face) continue;
701700
peny = (1 - tgret->numlines + runs[i].line_number) * tgret->line_height;
702701
if(peny != oldpeny) {
@@ -714,7 +713,7 @@ int msLayoutTextSymbol(mapObj *map, textSymbolObj *ts, textPathObj *tgret) {
714713
unsigned int *codepoint = glyphs.codepoints + runs[i].offset;
715714
alloc_glyphs += runs[i].length;
716715
tgret->glyphs = msSmallRealloc(tgret->glyphs, alloc_glyphs * sizeof(glyphObj));
717-
for(j=0;j<runs[i].length;j++) {
716+
for(unsigned int j=0;j<runs[i].length;j++) {
718717
glyphObj *g = &tgret->glyphs[tgret->numglyphs + j];
719718
g->glyph = msGetGlyphByIndex(runs[i].face,tgret->glyph_size, *codepoint);
720719
g->face = runs[i].face;
@@ -746,11 +745,13 @@ int msLayoutTextSymbol(mapObj *map, textSymbolObj *ts, textPathObj *tgret) {
746745
hb_buffer_set_direction(buf, (runs[i].rtl%2) ? HB_DIRECTION_RTL :HB_DIRECTION_LTR);
747746
hb_buffer_add_utf32(buf,glyphs.unicodes + runs[i].offset, runs[i].length, 0, runs[i].length);
748747
hb_shape(font,buf,hbfeatures,2);
748+
749+
unsigned int glyph_count;
749750
glyph_info = hb_buffer_get_glyph_infos(buf, &glyph_count);
750751
glyph_pos = hb_buffer_get_glyph_positions(buf, &glyph_count);
751752
alloc_glyphs += glyph_count;
752753
tgret->glyphs = msSmallRealloc(tgret->glyphs, alloc_glyphs * sizeof(glyphObj));
753-
for(j=0;j<glyph_count;j++) {
754+
for(unsigned int j=0;j<glyph_count;j++) {
754755
glyphObj *g = &tgret->glyphs[tgret->numglyphs + j];
755756
g->glyph = msGetGlyphByIndex(runs[i].face,tgret->glyph_size,glyph_info[j].codepoint);
756757
g->face = runs[i].face;

0 commit comments

Comments
 (0)