Fixed part coverity issues in samples (#8744)
This commit is contained in:
@@ -223,6 +223,7 @@ public:
|
||||
*/
|
||||
void show() {
|
||||
/** Print the result iterating over each batch **/
|
||||
std::ios::fmtflags fmt(std::cout.flags());
|
||||
std::cout << std::endl << "Top " << _nTop << " results:" << std::endl << std::endl;
|
||||
for (unsigned int image_id = 0; image_id < _batchSize; ++image_id) {
|
||||
std::wstring out(_imageNames[image_id].begin(), _imageNames[image_id].end());
|
||||
@@ -248,10 +249,12 @@ public:
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
std::cout.flags(fmt);
|
||||
}
|
||||
|
||||
void print() {
|
||||
/** Print the result iterating over each batch **/
|
||||
std::ios::fmtflags fmt(std::cout.flags());
|
||||
std::cout << std::endl << "Top " << _nTop << " results:" << std::endl << std::endl;
|
||||
for (unsigned int image_id = 0; image_id < _batchSize; ++image_id) {
|
||||
std::wstring out(_imageNames[image_id].begin(), _imageNames[image_id].end());
|
||||
@@ -287,6 +290,7 @@ public:
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
std::cout.flags(fmt);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -593,6 +593,7 @@ static UNUSED void printPerformanceCounts(
|
||||
if (bshowHeader) {
|
||||
stream << std::endl << "performance counts:" << std::endl << std::endl;
|
||||
}
|
||||
std::ios::fmtflags fmt(std::cout.flags());
|
||||
|
||||
auto performanceMapSorted = perfCountersSorted(performanceMap);
|
||||
|
||||
@@ -629,6 +630,7 @@ static UNUSED void printPerformanceCounts(
|
||||
std::cout << std::endl;
|
||||
std::cout << "Full device name: " << deviceName << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout.flags(fmt);
|
||||
}
|
||||
|
||||
static UNUSED void printPerformanceCounts(InferenceEngine::InferRequest request,
|
||||
|
||||
@@ -307,6 +307,9 @@ void printPerformanceCounters(
|
||||
std::string fullDeviceName,
|
||||
const uint64_t numberOfFramesOnHw) {
|
||||
#if !defined(__arm__) && !defined(_M_ARM) && !defined(__aarch64__) && !defined(_M_ARM64)
|
||||
if (numberOfFrames == 0)
|
||||
throw std::runtime_error("printPerformanceCounters: numberOfFrames=0, incorrect input");
|
||||
std::ios::fmtflags fmt(std::cout.flags());
|
||||
stream << std::endl << "Performance counts:" << std::endl;
|
||||
stream << std::setw(10) << std::right << ""
|
||||
<< "Counter descriptions";
|
||||
@@ -340,6 +343,7 @@ void printPerformanceCounters(
|
||||
stream << "Number of frames delivered to GNA HW: " << numberOfFramesOnHw;
|
||||
stream << "/" << numberOfFrames;
|
||||
stream << std::endl;
|
||||
std::cout.flags(fmt);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
5
thirdparty/cnpy/cnpy.cpp
vendored
5
thirdparty/cnpy/cnpy.cpp
vendored
@@ -224,6 +224,7 @@ cnpy::NpyArray load_the_npz_array(FILE* fp, uint32_t compr_bytes, uint32_t uncom
|
||||
d_stream.opaque = Z_NULL;
|
||||
d_stream.avail_in = 0;
|
||||
d_stream.next_in = Z_NULL;
|
||||
d_stream.total_in = 0;
|
||||
d_stream.total_out = 0;
|
||||
err = inflateInit2(&d_stream, -MAX_WBITS);
|
||||
|
||||
@@ -332,8 +333,8 @@ cnpy::NpyArray cnpy::npz_load(std::string fname, std::string varname) {
|
||||
|
||||
//read in the extra field
|
||||
uint16_t extra_field_len = *(uint16_t*) &local_header[28];
|
||||
fseek(fp,extra_field_len,SEEK_CUR); //skip past the extra field
|
||||
|
||||
if (fseek(fp,extra_field_len,SEEK_CUR) != 0) //skip past the extra field
|
||||
throw std::runtime_error("npz_load: failed fseek");
|
||||
uint16_t compr_method = *reinterpret_cast<uint16_t*>(&local_header[0]+8);
|
||||
uint32_t compr_bytes = *reinterpret_cast<uint32_t*>(&local_header[0]+18);
|
||||
uint32_t uncompr_bytes = *reinterpret_cast<uint32_t*>(&local_header[0]+22);
|
||||
|
||||
3
thirdparty/cnpy/cnpy.h
vendored
3
thirdparty/cnpy/cnpy.h
vendored
@@ -163,7 +163,8 @@ namespace cnpy {
|
||||
fclose(fp);
|
||||
throw std::runtime_error("npz_save: header read error while adding to existing zip");
|
||||
}
|
||||
fseek(fp,global_header_offset,SEEK_SET);
|
||||
if(fseek(fp,global_header_offset,SEEK_SET) != 0)
|
||||
throw std::runtime_error("npz_save: failed fseek");
|
||||
}
|
||||
else {
|
||||
fp = fopen(zipname.c_str(),"wb");
|
||||
|
||||
Reference in New Issue
Block a user