coverity fixes

Signed-off-by: Rosen Penev <rosenp@gmail.com>
main
Rosen Penev 2 years ago
parent 7473b4a715
commit d4f6c9cf40

@ -420,13 +420,6 @@ std::string makePath(const std::string& dir, const std::string& file) {
return dir + std::string(EXV_SEPARATOR_STR) + file; return dir + std::string(EXV_SEPARATOR_STR) + file;
} }
const char* makePath(const char* dir, const char* file) {
static char result[_MAX_PATH];
std::string r = makePath(std::string(dir), std::string(file));
strcpy(result, r.c_str());
return result;
}
// file utilities // file utilities
bool readDir(const char* path, Options& options) { bool readDir(const char* path, Options& options) {
bool bResult = false; bool bResult = false;
@ -452,7 +445,7 @@ bool readDir(const char* path, Options& options) {
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
// _tprintf(TEXT(" %s <DIR>\n"), ffd.cFileName); // _tprintf(TEXT(" %s <DIR>\n"), ffd.cFileName);
} else { } else {
std::string pathName = makePath(path, std::string(ffd.cFileName)); std::string pathName = makePath(path, ffd.cFileName);
if (getFileType(pathName, options) == typeImage) { if (getFileType(pathName, options) == typeImage) {
gFiles.push_back(pathName); gFiles.push_back(pathName);
} }

@ -167,10 +167,7 @@ int FileIo::Impl::switchMode(OpMode opMode) {
if (offset == -1) if (offset == -1)
return -1; return -1;
// 'Manual' open("r+b") to avoid munmap() // 'Manual' open("r+b") to avoid munmap()
if (fp_) {
std::fclose(fp_); std::fclose(fp_);
fp_ = nullptr;
}
openMode_ = "r+b"; openMode_ = "r+b";
opMode_ = opSeek; opMode_ = opSeek;
fp_ = std::fopen(path_.c_str(), openMode_.c_str()); fp_ = std::fopen(path_.c_str(), openMode_.c_str());

@ -786,7 +786,7 @@ ImageType ImageFactory::getType(BasicIo& io) {
return ImageType::none; return ImageType::none;
} }
BasicIo::UniquePtr ImageFactory::createIo(const std::string& path, bool useCurl) { BasicIo::UniquePtr ImageFactory::createIo(const std::string& path, [[maybe_unused]] bool useCurl) {
Protocol fProt = fileProtocol(path); Protocol fProt = fileProtocol(path);
#ifdef EXV_USE_CURL #ifdef EXV_USE_CURL
@ -803,8 +803,6 @@ BasicIo::UniquePtr ImageFactory::createIo(const std::string& path, bool useCurl)
return std::make_unique<XPathIo>(path); // may throw return std::make_unique<XPathIo>(path); // may throw
return std::make_unique<FileIo>(path); return std::make_unique<FileIo>(path);
(void)(useCurl);
} // ImageFactory::createIo } // ImageFactory::createIo
Image::UniquePtr ImageFactory::open(const std::string& path, bool useCurl) { Image::UniquePtr ImageFactory::open(const std::string& path, bool useCurl) {

@ -371,7 +371,7 @@ std::string CommentValue::comment(const char* encoding) const {
if (charsetId() == unicode) { if (charsetId() == unicode) {
const char* from = !encoding || *encoding == '\0' ? detectCharset(c) : encoding; const char* from = !encoding || *encoding == '\0' ? detectCharset(c) : encoding;
if (!convertStringCharset(c, from, "UTF-8")) if (!convertStringCharset(c, from, "UTF-8"))
throw Error(ErrorCode::kerInvalidIconvEncoding, encoding, "UTF-8"); throw Error(ErrorCode::kerInvalidIconvEncoding, from, "UTF-8");
} }
// # 1266 Remove trailing nulls // # 1266 Remove trailing nulls

@ -693,7 +693,6 @@ int XmpParser::decode(XmpData& xmpData, const std::string& xmpPacket) {
printNode(schemaNs, propPath, propValue, opt); printNode(schemaNs, propPath, propValue, opt);
if (XMP_PropIsAlias(opt)) { if (XMP_PropIsAlias(opt)) {
throw Error(ErrorCode::kerAliasesNotSupported, schemaNs, propPath, propValue); throw Error(ErrorCode::kerAliasesNotSupported, schemaNs, propPath, propValue);
continue;
} }
if (XMP_NodeIsSchema(opt)) { if (XMP_NodeIsSchema(opt)) {
// Register unknown namespaces with Exiv2 // Register unknown namespaces with Exiv2

Loading…
Cancel
Save