From 07ea15fe9ecb65ae8043869216fb5e98b2a9d332 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 8 Dec 2024 21:57:41 +0100 Subject: [PATCH] Fix MSVC warning about assignment in condition --- apps/gdalwarp_lib.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/gdalwarp_lib.cpp b/apps/gdalwarp_lib.cpp index 1c623cdc4bde..802281bc8e67 100644 --- a/apps/gdalwarp_lib.cpp +++ b/apps/gdalwarp_lib.cpp @@ -4714,16 +4714,18 @@ static GDALDatasetH GDALWarpCreateOutput( aosCreateOptions.SetNameValue("PHOTOMETRIC", "RGB"); // Preserve potential ALPHA=PREMULTIPLIED from source alpha band - const char *pszAlpha; if (aosCreateOptions.FetchNameValue("ALPHA") == nullptr && apeColorInterpretations.size() == 4 && apeColorInterpretations[3] == GCI_AlphaBand && - GDALGetRasterCount(pahSrcDS[0]) == 4 && - (pszAlpha = - GDALGetMetadataItem(GDALGetRasterBand(pahSrcDS[0], 4), - "ALPHA", "IMAGE_STRUCTURE"))) + GDALGetRasterCount(pahSrcDS[0]) == 4) { - aosCreateOptions.SetNameValue("ALPHA", pszAlpha); + const char *pszAlpha = + GDALGetMetadataItem(GDALGetRasterBand(pahSrcDS[0], 4), + "ALPHA", "IMAGE_STRUCTURE"); + if (pszAlpha) + { + aosCreateOptions.SetNameValue("ALPHA", pszAlpha); + } } }