Skip to content

Commit 294b21a

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 12c868b + c80c4c9 commit 294b21a

File tree

700 files changed

+26756
-4880
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

700 files changed

+26756
-4880
lines changed

.github/workflows/alpine/build.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,16 @@ $PYTHON_CMD -m venv myvenv
4848
source myvenv/bin/activate
4949
$PYTHON_CMD -m pip install -U check-jsonschema
5050
check-jsonschema --schemafile data/gdal_algorithm.schema.json out.json
51+
52+
# Check behavior when plugin not available
53+
mv gdalplugins/ogr_PG.so gdalplugins/ogr_PG.so.disabled
54+
export GDAL_DRIVER_PATH=$PWD/gdalplugins
55+
if apps/gdal vector convert -i autotest/ogr/data/poly.shp -o PG:dbname=autotest >/dev/null; then
56+
echo "Failure expected"
57+
exit 1
58+
fi
59+
if test -d PG:dbname=autotest; then
60+
echo "Directory PG:dbname=autotest should not have been created"
61+
exit 1
62+
fi
63+
mv gdalplugins/ogr_PG.so.disabled gdalplugins/ogr_PG.so

.github/workflows/code_checks.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ jobs:
128128
- name: Detect missing includes
129129
run: ./scripts/detect_missing_include.sh
130130

131+
- name: Detect (a+b-1)/b
132+
run: ./scripts/detect_a_plus_b_minus_1_div_b.sh
133+
131134
# Helps detecting updates of internal libjson-c where replacement
132135
# of strtod() -> CPLStrtod() is missing. The later function is not
133136
# locale sensitive. An alternative would be to make sure that HAVE_USELOCALE

.github/workflows/codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ jobs:
108108
# We do that after running CMake to avoid CodeQL to trigger during CMake time,
109109
# in particular during HDF5 detection which is terribly slow (https://github.com/OSGeo/gdal/issues/9549)
110110
- name: Initialize CodeQL
111-
uses: github/codeql-action/init@28deaeda66b76a05916b6923827895f2b14ab387 # v3.28.16
111+
uses: github/codeql-action/init@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
112112
with:
113113
languages: ${{ matrix.language }}
114114
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -128,6 +128,6 @@ jobs:
128128
cmake --build build -j$(nproc)
129129
130130
- name: Perform CodeQL Analysis
131-
uses: github/codeql-action/analyze@28deaeda66b76a05916b6923827895f2b14ab387 # v3.28.16
131+
uses: github/codeql-action/analyze@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
132132
with:
133133
category: "/language:${{matrix.language}}"

.github/workflows/scorecard.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
persist-credentials: false
4242

4343
- name: "Run analysis"
44-
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
44+
uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
4545
with:
4646
results_file: results.sarif
4747
results_format: sarif
@@ -71,6 +71,6 @@ jobs:
7171

7272
# Upload the results to GitHub's code scanning dashboard.
7373
- name: "Upload to code-scanning"
74-
uses: github/codeql-action/upload-sarif@28deaeda66b76a05916b6923827895f2b14ab387 # v3.28.16
74+
uses: github/codeql-action/upload-sarif@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
7575
with:
7676
sarif_file: results.sarif

.github/workflows/ubuntu_20.04/Dockerfile.ci

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ RUN wget -q https://github.com/Esri/file-geodatabase-api/raw/master/FileGDB_API_
164164
&& echo "/usr/local/FileGDB_API/lib" > /etc/ld.so.conf.d/filegdbapi.conf
165165

166166
# Build and install GEOS
167-
ENV GEOS_VERSION=3.11.0
167+
ENV GEOS_VERSION=main
168168
RUN mkdir geos \
169169
&& wget -q https://github.com/libgeos/geos/archive/${GEOS_VERSION}.tar.gz -O - \
170170
| tar xz -C geos --strip-components=1 \

alg/gdal_simplesurf.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class GDALFeaturePoint
175175
};
176176

177177
/**
178-
* @author Andrew Migal migal.drew@gmail.com
178+
* @author Andrew Migal migal.drew at gmail.com
179179
* @brief Integral image class (summed area table).
180180
* @details Integral image is a table for fast computing the sum of
181181
* values in rectangular subarea. In more detail, for 2-dimensional array
@@ -267,7 +267,7 @@ class GDALIntegralImage
267267
};
268268

269269
/**
270-
* @author Andrew Migal migal.drew@gmail.com
270+
* @author Andrew Migal migal.drew at gmail.com
271271
* @brief Class for computation and storage of Hessian values in SURF-based
272272
* algorithm.
273273
*
@@ -339,7 +339,7 @@ class GDALOctaveLayer
339339
};
340340

341341
/**
342-
* @author Andrew Migal migal.drew@gmail.com
342+
* @author Andrew Migal migal.drew at gmail.com
343343
* @brief Class for handling octave layers in SURF-based algorithm.
344344
* @details Class contains OctaveLayers and provides capability to construct
345345
* octave space and distinguish feature points. Normally this class is used only
@@ -414,7 +414,7 @@ class GDALOctaveMap
414414
};
415415

416416
/**
417-
* @author Andrew Migal migal.drew@gmail.com
417+
* @author Andrew Migal migal.drew at gmail.com
418418
* @brief Class for searching corresponding points on images.
419419
* @details Provides capability for detection feature points
420420
* and finding equal points on different images.

alg/gdalchecksum.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ int CPL_STDCALL GDALChecksumImage(GDALRasterBandH hBand, int nXOff, int nYOff,
151151
"Checksum value could not be computed due to I/O "
152152
"read error.");
153153
nChecksum = -1;
154-
iYBlock = nYBlocks;
155154
break;
156155
}
157156
const size_t xIters =
@@ -176,6 +175,9 @@ int CPL_STDCALL GDALChecksumImage(GDALRasterBandH hBand, int nXOff, int nYOff,
176175
nChecksum &= 0xffff;
177176
}
178177
}
178+
179+
if (nChecksum < 0)
180+
break;
179181
}
180182

181183
CPLFree(padfLineData);
@@ -285,7 +287,6 @@ int CPL_STDCALL GDALChecksumImage(GDALRasterBandH hBand, int nXOff, int nYOff,
285287
"Checksum value could not be computed due to I/O "
286288
"read error.");
287289
nChecksum = -1;
288-
iYBlock = nYBlocks;
289290
break;
290291
}
291292
const size_t xIters =
@@ -310,6 +311,9 @@ int CPL_STDCALL GDALChecksumImage(GDALRasterBandH hBand, int nXOff, int nYOff,
310311
nChecksum &= 0xffff;
311312
}
312313
}
314+
315+
if (nChecksum < 0)
316+
break;
313317
}
314318

315319
CPLFree(panChunkData);

alg/gdalgrid.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2560,6 +2560,7 @@ struct _GDALGridJob
25602560
GDALDataType eType;
25612561

25622562
int *pnCounter;
2563+
int nCounterSingleThreaded;
25632564
volatile int *pbStop;
25642565
CPLCond *hCond;
25652566
CPLMutex *hCondMutex;
@@ -2591,8 +2592,7 @@ static int GDALGridProgressMultiThread(GDALGridJob *psJob)
25912592
// Return TRUE if the computation must be interrupted.
25922593
static int GDALGridProgressMonoThread(GDALGridJob *psJob)
25932594
{
2594-
// coverity[missing_lock]
2595-
const int nCounter = ++(*psJob->pnCounter);
2595+
const int nCounter = ++(psJob->nCounterSingleThreaded);
25962596
if (!psJob->pfnRealProgress(nCounter / static_cast<double>(psJob->nYSize),
25972597
"", psJob->pRealProgressArg))
25982598
{
@@ -3509,6 +3509,7 @@ CPLErr GDALGridContextProcess(GDALGridContext *psContext, double dfXMin,
35093509
sJob.eType = eType;
35103510
sJob.pfnRealProgress = pfnProgress;
35113511
sJob.pRealProgressArg = pProgressArg;
3512+
sJob.nCounterSingleThreaded = 0;
35123513
sJob.pnCounter = &nCounter;
35133514
sJob.pbStop = &bStop;
35143515
sJob.hCond = nullptr;

alg/gdalrasterize.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ static CPLErr GDALRasterizeGeometriesInternal(
11811181
nYChunkSize = poDS->GetRasterYSize();
11821182

11831183
CPLDebug("GDAL", "Rasterizer operating on %d swaths of %d scanlines.",
1184-
(poDS->GetRasterYSize() + nYChunkSize - 1) / nYChunkSize,
1184+
DIV_ROUND_UP(poDS->GetRasterYSize(), nYChunkSize),
11851185
nYChunkSize);
11861186

11871187
pabyChunkBuf = static_cast<unsigned char *>(VSI_MALLOC2_VERBOSE(
@@ -1259,10 +1259,8 @@ static CPLErr GDALRasterizeGeometriesInternal(
12591259
/* the block size of the output file. */
12601260
/* --------------------------------------------------------------------
12611261
*/
1262-
const int nXBlocks =
1263-
(poBand->GetXSize() + nXBlockSize - 1) / nXBlockSize;
1264-
const int nYBlocks =
1265-
(poBand->GetYSize() + nYBlockSize - 1) / nYBlockSize;
1262+
const int nXBlocks = DIV_ROUND_UP(poBand->GetXSize(), nXBlockSize);
1263+
const int nYBlocks = DIV_ROUND_UP(poBand->GetYSize(), nYBlockSize);
12661264

12671265
const GDALDataType eType =
12681266
poBand->GetRasterDataType() == GDT_Byte ? GDT_Byte : GDT_Float64;
@@ -1589,8 +1587,7 @@ CPLErr GDALRasterizeLayers(GDALDatasetH hDS, int nBandCount, int *panBandList,
15891587
nYChunkSize = poDS->GetRasterYSize();
15901588

15911589
CPLDebug("GDAL", "Rasterizer operating on %d swaths of %d scanlines.",
1592-
(poDS->GetRasterYSize() + nYChunkSize - 1) / nYChunkSize,
1593-
nYChunkSize);
1590+
DIV_ROUND_UP(poDS->GetRasterYSize(), nYChunkSize), nYChunkSize);
15941591
unsigned char *pabyChunkBuf = static_cast<unsigned char *>(
15951592
VSI_MALLOC2_VERBOSE(nYChunkSize, nScanlineBytes));
15961593
if (pabyChunkBuf == nullptr)

alg/gdalwarper.h

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -499,15 +499,28 @@ void GWKThreadsEnd(void *psThreadDataIn);
499499
/*! @cond Doxygen_Suppress */
500500
typedef struct _GDALWarpChunk GDALWarpChunk;
501501

502+
struct GDALTransformerUniquePtrReleaser
503+
{
504+
void operator()(void *p)
505+
{
506+
GDALDestroyTransformer(p);
507+
}
508+
};
509+
502510
/*! @endcond */
503511

504-
class CPL_DLL GDALWarpOperation
512+
/** Unique pointer for the argument of a GDALTransformerFunc */
513+
using GDALTransformerArgUniquePtr =
514+
std::unique_ptr<void, GDALTransformerUniquePtrReleaser>;
515+
516+
class CPL_DLL GDALWarpOperation final
505517
{
506518

507519
CPL_DISALLOW_COPY_ASSIGN(GDALWarpOperation)
508520

509521
private:
510-
GDALWarpOptions *psOptions;
522+
GDALWarpOptions *psOptions = nullptr;
523+
GDALTransformerArgUniquePtr m_psOwnedTransformerArg{nullptr};
511524

512525
void WipeOptions();
513526
int ValidateOptions();
@@ -528,17 +541,17 @@ class CPL_DLL GDALWarpOperation
528541
static CPLErr CreateKernelMask(GDALWarpKernel *, int iBand,
529542
const char *pszType);
530543

531-
CPLMutex *hIOMutex;
532-
CPLMutex *hWarpMutex;
544+
CPLMutex *hIOMutex = nullptr;
545+
CPLMutex *hWarpMutex = nullptr;
533546

534-
int nChunkListCount;
535-
int nChunkListMax;
536-
GDALWarpChunk *pasChunkList;
547+
int nChunkListCount = 0;
548+
int nChunkListMax = 0;
549+
GDALWarpChunk *pasChunkList = nullptr;
537550

538-
int bReportTimings;
539-
unsigned long nLastTimeReported;
551+
bool bReportTimings = false;
552+
unsigned long nLastTimeReported = 0;
540553

541-
void *psThreadData;
554+
void *psThreadData = nullptr;
542555

543556
// Coordinates a few special points in target image space, to determine
544557
// if ComputeSourceWindow() must use a grid based sampling.
@@ -555,9 +568,12 @@ class CPL_DLL GDALWarpOperation
555568

556569
public:
557570
GDALWarpOperation();
558-
virtual ~GDALWarpOperation();
571+
~GDALWarpOperation();
559572

560-
CPLErr Initialize(const GDALWarpOptions *psNewOptions);
573+
CPLErr Initialize(const GDALWarpOptions *psNewOptions,
574+
GDALTransformerFunc pfnTransformer = nullptr,
575+
GDALTransformerArgUniquePtr psOwnedTransformerArg =
576+
GDALTransformerArgUniquePtr{nullptr});
561577
void *CreateDestinationBuffer(int nDstXSize, int nDstYSize,
562578
int *pbWasInitialized = nullptr);
563579
CPLErr InitializeDestinationBuffer(void *pDstBuffer, int nDstXSize,

0 commit comments

Comments
 (0)