Fixed several incorrect printf format specifiers

pull/12599/head
Maksim Shabunin 6 years ago
parent d1c842cf29
commit e0f524d3b7
  1. 2
      apps/interactive-calibration/calibController.cpp
  2. 2
      apps/interactive-calibration/frameProcessor.cpp
  3. 11
      modules/core/include/opencv2/core/operations.hpp
  4. 2
      modules/core/src/ocl.cpp
  5. 2
      modules/core/test/test_io.cpp
  6. 2
      modules/dnn/src/dnn.cpp
  7. 2
      modules/dnn/src/layers/permute_layer.cpp
  8. 6
      modules/dnn/src/torch/THDiskFile.cpp
  9. 2
      modules/objdetect/src/hog.cpp
  10. 5
      modules/photo/src/fast_nlmeans_denoising_opencl.hpp
  11. 2
      modules/videoio/src/container_avi.cpp
  12. 4
      samples/dnn/segmentation.cpp

@ -210,7 +210,7 @@ void calib::calibDataController::filterFrames()
worstElemIndex = i;
}
}
showOverlayMessage(cv::format("Frame %d is worst", worstElemIndex + 1));
showOverlayMessage(cv::format("Frame %zu is worst", worstElemIndex + 1));
if(mCalibData->imagePoints.size()) {
mCalibData->imagePoints.erase(mCalibData->imagePoints.begin() + worstElemIndex);

@ -318,7 +318,7 @@ cv::Mat CalibProcessor::processFrame(const cv::Mat &frame)
saveFrameData();
bool isFrameBad = checkLastFrame();
if (!isFrameBad) {
std::string displayMessage = cv::format("Frame # %d captured", std::max(mCalibData->imagePoints.size(),
std::string displayMessage = cv::format("Frame # %zu captured", std::max(mCalibData->imagePoints.size(),
mCalibData->allCharucoCorners.size()));
if(!showOverlayMessage(displayMessage))
showCaptureMessage(frame, displayMessage);

@ -392,6 +392,17 @@ template<typename _Tp> static inline _Tp randu()
The function acts like sprintf but forms and returns an STL string. It can be used to form an error
message in the Exception constructor.
@param fmt printf-compatible formatting specifiers.
**Note**:
|Type|Specifier|
|-|-|
|`const char*`|`%s`|
|`char`|`%c`|
|`float` / `double`|`%f`,`%g`|
|`int`, `long`, `long long`|`%d`, `%ld`, ``%lld`|
|`unsigned`, `unsigned long`, `unsigned long long`|`%u`, `%lu`, `%llu`|
|`uint64` -> `uintmax_t`, `int64` -> `intmax_t`|`%ju`, `%jd`|
|`size_t`|`%zu`|
*/
CV_EXPORTS String format( const char* fmt, ... ) CV_FORMAT_PRINTF(1, 2);

@ -3317,7 +3317,7 @@ struct ProgramSource::Impl
default:
CV_Error(Error::StsInternal, "Internal error");
}
sourceHash_ = cv::format("%08jx", hash);
sourceHash_ = cv::format("%08jx", (uintmax_t)hash);
isHashUpdated = true;
}

@ -606,7 +606,7 @@ TEST(Core_InputOutput, FileStorageSpaces)
cv::FileStorage g3(fileName, cv::FileStorage::READ);
std::string valuesReadAppend[valueCount];
for (size_t i = 0; i < valueCount; i++) {
EXPECT_NO_THROW(g3[cv::format("key%d", i)] >> valuesReadAppend[i]);
EXPECT_NO_THROW(g3[cv::format("key%zu", i)] >> valuesReadAppend[i]);
ASSERT_STREQ(values[i].c_str(), valuesReadAppend[i].c_str());
}
g3.release();

@ -2347,7 +2347,7 @@ struct Net::Impl
LayerData &ld = layers[pin.lid];
if ((size_t)pin.oid >= ld.outputBlobs.size())
{
CV_Error(Error::StsOutOfRange, format("Layer \"%s\" produce only %d outputs, "
CV_Error(Error::StsOutOfRange, format("Layer \"%s\" produce only %zu outputs, "
"the #%d was requested", ld.name.c_str(),
ld.outputBlobs.size(), pin.oid));
}

@ -88,7 +88,7 @@ public:
{
CV_Error(Error::StsBadArg,
format("Orders of dimensions in Permute layer parameter"
"must be in [0...%d]", _numAxes - 1));
"must be in [0...%zu]", _numAxes - 1));
}
if (std::find(_order.begin(), _order.end(), currentOrder) != _order.end())
{

@ -69,7 +69,7 @@ static size_t fread__(void *ptr, size_t size, size_t nitems, FILE *stream)
{ \
dfself->file.hasError = 1; /* shouldn't we put hasError to 0 all the time ? */ \
if(!dfself->file.isQuiet) \
THError("read error: read %d blocks instead of %d", nread, n); \
THError("read error: read %ld blocks instead of %ld", nread, n);\
} \
\
return nread; \
@ -120,7 +120,7 @@ static void THDiskFile_seek(THFile *self, long position)
{
dfself->file.hasError = 1;
if(!dfself->file.isQuiet)
THError("unable to seek at position %d", position);
THError("unable to seek at position %ld", position);
}
}
@ -351,7 +351,7 @@ static long THDiskFile_readLong(THFile *self, int64 *data, long n)
{
dfself->file.hasError = 1; /* shouldn't we put hasError to 0 all the time ? */
if(!dfself->file.isQuiet)
THError("read error: read %d blocks instead of %d", nread, n);
THError("read error: read %ld blocks instead of %ld", nread, n);
}
return nread;

@ -1902,7 +1902,7 @@ static bool ocl_classify_hists(int win_height, int win_width, int block_stride_y
if(is_cpu)
opts = "-D CPU ";
else
opts = cv::format("-D WAVE_SIZE=%d", k.preferedWorkGroupSizeMultiple());
opts = cv::format("-D WAVE_SIZE=%zu", k.preferedWorkGroupSizeMultiple());
k.create("classify_hists_kernel", ocl::objdetect::objdetect_hog_oclsrc, opts);
if(k.empty())
return false;

@ -95,12 +95,13 @@ static bool ocl_fastNlMeansDenoising(InputArray _src, OutputArray _dst, const fl
int almostTemplateWindowSizeSqBinShift = -1;
char buf[4][40];
const unsigned psz = (depth == CV_8U ? sizeof(uchar) : sizeof(ushort)) * (cn == 3 ? 4 : cn);
String opts = format("-D OP_CALC_FASTNLMEANS -D TEMPLATE_SIZE=%d -D SEARCH_SIZE=%d"
" -D pixel_t=%s -D int_t=%s -D wlut_t=%s"
" -D weight_t=%s -D convert_weight_t=%s -D sum_t=%s -D convert_sum_t=%s"
" -D BLOCK_COLS=%d -D BLOCK_ROWS=%d"
" -D CTA_SIZE=%d -D TEMPLATE_SIZE2=%d -D SEARCH_SIZE2=%d"
" -D convert_int_t=%s -D cn=%d -D psz=%d -D convert_pixel_t=%s%s",
" -D convert_int_t=%s -D cn=%d -D psz=%u -D convert_pixel_t=%s%s",
templateWindowSize, searchWindowSize,
ocl::typeToStr(type), ocl::typeToStr(CV_32SC(cn)),
ocl::typeToStr(CV_32SC(hn)),
@ -115,7 +116,7 @@ static bool ocl_fastNlMeansDenoising(InputArray _src, OutputArray _dst, const fl
BLOCK_COLS, BLOCK_ROWS,
ctaSize, templateWindowHalfWize, searchWindowHalfSize,
ocl::convertTypeStr(depth, CV_32S, cn, buf[2]), cn,
(depth == CV_8U ? sizeof(uchar) : sizeof(ushort)) * (cn == 3 ? 4 : cn),
psz,
ocl::convertTypeStr(CV_32S, depth, cn, buf[3]),
normType == NORM_L1 ? " -D ABS" : "");

@ -22,7 +22,7 @@ inline D safe_int_cast(S val, const char * msg = 0)
if (!in_range_r || !in_range_l)
{
if (!msg)
CV_Error_(Error::StsOutOfRange, ("Can not convert integer values (%s -> %s), value 0x%jx is out of range", typeid(S).name(), typeid(D).name(), int64(val)));
CV_Error_(Error::StsOutOfRange, ("Can not convert integer values (%s -> %s), value 0x%jx is out of range", typeid(S).name(), typeid(D).name(), (uintmax_t)val));
else
CV_Error(Error::StsOutOfRange, msg);
}

@ -186,7 +186,7 @@ void colorizeSegmentation(const Mat &score, Mat &segm)
else if (chns != (int)colors.size())
{
CV_Error(Error::StsError, format("Number of output classes does not match "
"number of colors (%d != %d)", chns, colors.size()));
"number of colors (%d != %zu)", chns, colors.size()));
}
Mat maxCl = Mat::zeros(rows, cols, CV_8UC1);
@ -231,7 +231,7 @@ void showLegend()
if ((int)colors.size() != numClasses)
{
CV_Error(Error::StsError, format("Number of output classes does not match "
"number of labels (%d != %d)", colors.size(), classes.size()));
"number of labels (%zu != %zu)", colors.size(), classes.size()));
}
legend.create(kBlockHeight * numClasses, 200, CV_8UC3);
for (int i = 0; i < numClasses; i++)

Loading…
Cancel
Save