MCPcopy Create free account
hub / github.com/OSGeo/gdal / GDALCheckBandCount

Function GDALCheckBandCount

gcore/gdal_misc.cpp:4792–4813  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4790 */
4791
4792int GDALCheckBandCount(int nBands, int bIsZeroAllowed)
4793{
4794 if (nBands < 0 || (!bIsZeroAllowed && nBands == 0))
4795 {
4796 CPLError(CE_Failure, CPLE_AppDefined, "Invalid band count : %d",
4797 nBands);
4798 return FALSE;
4799 }
4800 const char *pszMaxBandCount =
4801 CPLGetConfigOption("GDAL_MAX_BAND_COUNT", "65536");
4802 int nMaxBands = std::clamp(atoi(pszMaxBandCount), 0, INT_MAX - 1);
4803 if (nBands > nMaxBands)
4804 {
4805 CPLError(CE_Failure, CPLE_AppDefined,
4806 "Invalid band count : %d. Maximum allowed currently is %d. "
4807 "Define GDAL_MAX_BAND_COUNT to a higher level if it is a "
4808 "legitimate number.",
4809 nBands, nMaxBands);
4810 return FALSE;
4811 }
4812 return TRUE;
4813}
4814
4815CPL_C_END
4816

Callers 15

OpenRasterSubDatasetMethod · 0.85
OpenRasterMethod · 0.85
OpenMethod · 0.85
OpenInternalMethod · 0.85
OpenMethod · 0.85
OpenMethod · 0.85
OpenMethod · 0.85
OpenMethod · 0.85
OpenMethod · 0.85
OpenMethod · 0.85
OpenMethod · 0.85

Calls 1

CPLErrorFunction · 0.85

Tested by

no test coverage detected