Skip to content

Commit

Permalink
coverity fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Rosen Penev <[email protected]>
(cherry picked from commit d4f6c9c)
  • Loading branch information
neheb committed May 22, 2024
1 parent ca35182 commit 7e382e7
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 17 deletions.
9 changes: 1 addition & 8 deletions samples/geotag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,6 @@ std::string makePath(const std::string& dir, const std::string& 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
bool readDir(const char* path, Options& options) {
bool bResult = false;
Expand All @@ -451,7 +444,7 @@ bool readDir(const char* path, Options& options) {
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
// _tprintf(TEXT(" %s <DIR>\n"), ffd.cFileName);
} else {
std::string pathName = makePath(path, std::string(ffd.cFileName));
std::string pathName = makePath(path, ffd.cFileName);
if (getFileType(pathName, options) == typeImage) {
gFiles.push_back(pathName);
}
Expand Down
5 changes: 1 addition & 4 deletions src/basicio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,7 @@ int FileIo::Impl::switchMode(OpMode opMode) {
if (offset == -1)
return -1;
// 'Manual' open("r+b") to avoid munmap()
if (fp_) {
std::fclose(fp_);
fp_ = nullptr;
}
std::fclose(fp_);
openMode_ = "r+b";
opMode_ = opSeek;
fp_ = std::fopen(path_.c_str(), openMode_.c_str());
Expand Down
4 changes: 1 addition & 3 deletions src/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ ImageType ImageFactory::getType(BasicIo& io) {
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);

#ifdef EXV_USE_CURL
Expand All @@ -789,8 +789,6 @@ BasicIo::UniquePtr ImageFactory::createIo(const std::string& path, bool useCurl)
return std::make_unique<XPathIo>(path); // may throw

return std::make_unique<FileIo>(path);

(void)(useCurl);
} // ImageFactory::createIo

Image::UniquePtr ImageFactory::open(const std::string& path, bool useCurl) {
Expand Down
2 changes: 1 addition & 1 deletion src/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ std::string CommentValue::comment(const char* encoding) const {
if (charsetId() == unicode) {
const char* from = !encoding || *encoding == '\0' ? detectCharset(c) : encoding;
if (!convertStringCharset(c, from, "UTF-8"))
throw Error(ErrorCode::kerInvalidIconvEncoding, encoding, "UTF-8");
throw Error(ErrorCode::kerInvalidIconvEncoding, from, "UTF-8");
}

// # 1266 Remove trailing nulls
Expand Down
1 change: 0 additions & 1 deletion src/xmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,6 @@ int XmpParser::decode(XmpData& xmpData, const std::string& xmpPacket) {
printNode(schemaNs, propPath, propValue, opt);
if (XMP_PropIsAlias(opt)) {
throw Error(ErrorCode::kerAliasesNotSupported, schemaNs, propPath, propValue);
continue;
}
if (XMP_NodeIsSchema(opt)) {
// Register unknown namespaces with Exiv2
Expand Down

0 comments on commit 7e382e7

Please sign in to comment.