Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coverity fixes (backport #2696) #2977

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading