Skip to content

Commit

Permalink
Merge pull request #127 from thbeu/fix-cppcheck-issues
Browse files Browse the repository at this point in the history
Fix issues reported by cppcheck 2.14.0
  • Loading branch information
rouault authored May 21, 2024
2 parents 7741112 + c94eaec commit f948af2
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
11 changes: 5 additions & 6 deletions contrib/Shape_PointInPoly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ static loopDir LoopDirection(DPoint2d *vertices, int vertsize)

static DPoint2d CreatePointInPoly(SHPObject *psShape, int quality)
{
int i, j, k, end, vert, pointpos;
double part, dx, xmin, xmax, ymin, ymax, y, x3, x4, y3, y4, len, maxlen = 0;
int i, j, k, end, vert;
double part, dx, xmin, xmax, ymin, ymax, x3, x4, y3, y4, len, maxlen = 0;
DPoint2d *vertices;
loopDir direction;
IntersectPoint mp1, mp2, point1, point2, points[MAXINTERSECTIONPOINTS];
Expand All @@ -86,8 +86,8 @@ static DPoint2d CreatePointInPoly(SHPObject *psShape, int quality)
dx = xmax - xmin;
for (i = 0; i < quality; i++)
{
y = ymin + part * (i + 1);
pointpos = 0;
const double y = ymin + part * (i + 1);
int pointpos = 0;
for (j = 0; j < psShape->nParts; j++)
{
if (j == psShape->nParts - 1)
Expand Down Expand Up @@ -196,7 +196,6 @@ int main(int argc, char *argv[])

int i, nEntities, quality;
SHPHandle hSHP;
SHPObject *psShape;
DPoint2d pt;
quality = atoi(argv[2]);
hSHP = SHPOpen(argv[1], "rb");
Expand All @@ -205,7 +204,7 @@ int main(int argc, char *argv[])
printf("PointInPoly v1.0, by Marko Podgorsek\n----------------\n");
for (i = 0; i < nEntities; i++)
{
psShape = SHPReadObject(hSHP, i);
SHPObject *psShape = SHPReadObject(hSHP, i);
if (psShape->nSHPType == SHPT_POLYGON)
{
pt = CreatePointInPoly(psShape, quality);
Expand Down
2 changes: 1 addition & 1 deletion contrib/dbfcat.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ int main(int argc, char **argv)
if (verbose)
{
const int ncRecords = DBFGetRecordCount(cDBF) - nRecords;
printf(" %u record%s appended\n\n", ncRecords,
printf(" %d record%s appended\n\n", ncRecords,
ncRecords == 1 ? "" : "s");
}
DBFClose(hDBF);
Expand Down
2 changes: 1 addition & 1 deletion contrib/shpsort.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ static void copy_related(const char *inName, const char *outName,
}

#ifdef DEBUG
static void PrintDataStruct(struct DataStruct *data)
static void PrintDataStruct(const struct DataStruct *data)
{
for (int i = 0; i < nShapes; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion dbfdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int main(int argc, char **argv)
bool bHeader = false;
bool bRaw = false;
bool bMultiLine = false;
char *pszFilename = NULL;
const char *pszFilename = NULL;

for (int i = 1; i < argc; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion dbfopen.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ DBFHandle SHPAPI_CALL DBFOpenLL(const char *pszFilename, const char *pszAccess,

for (int iField = 0; iField < nFields; iField++)
{
unsigned char *pabyFInfo = pabyBuf + iField * XBASE_FLDHDR_SZ;
const unsigned char *pabyFInfo = pabyBuf + iField * XBASE_FLDHDR_SZ;
if (pabyFInfo[0] == HEADER_RECORD_TERMINATOR)
{
psDBF->nFields = iField;
Expand Down

0 comments on commit f948af2

Please sign in to comment.