coverity: remove dead code

Found with: CID 1521533
Unsigned compared against 0 (NO_EFFECT)

Signed-off-by: Rosen Penev <rosenp@gmail.com>
main
Rosen Penev 2 years ago
parent 03d34bee04
commit b9d94e61fe

@ -383,8 +383,6 @@ void Image::printIFDStructure(BasicIo& io, std::ostream& out, Exiv2::PrintStruct
if (allocate64 > io.size()) {
throw Error(ErrorCode::kerInvalidMalloc);
}
// Overflow check
Internal::enforce(allocate64 <= std::numeric_limits<size_t>::max(), ErrorCode::kerCorruptedMetadata);
DataBuf buf(allocate64); // allocate a buffer
std::copy_n(dir.c_data(8), 4, buf.begin()); // copy dir[8:11] into buffer (short strings)

@ -520,9 +520,6 @@ DataBuf PngChunk::readRawProfile(const DataBuf& text, bool iTXt) {
while ('0' <= *sp && *sp <= '9') {
// Compute the new length using unsigned long, so that we can check for overflow.
const size_t newlength = (10 * length) + (*sp - '0');
if (newlength > std::numeric_limits<size_t>::max()) {
return {}; // Integer overflow.
}
length = newlength;
sp++;
if (sp == eot) {

@ -874,8 +874,6 @@ DataBuf decodeBase64(const std::string& src) {
const unsigned long destSize = (validSrcSize * 3) / 4;
// allocate dest buffer
if (destSize > LONG_MAX)
return {}; // avoid integer overflow
DataBuf dest(destSize);
// decode

@ -245,11 +245,6 @@ void RafImage::readMetadata() {
Internal::enforce(Safe::add(jpg_img_off_u32, jpg_img_len_u32) <= io_->size(), ErrorCode::kerCorruptedMetadata);
#if LONG_MAX < UINT_MAX
Internal::enforce(jpg_img_off_u32 <= std::numeric_limits<uint32_t>::max(), ErrorCode::kerCorruptedMetadata);
Internal::enforce(jpg_img_len_u32 <= std::numeric_limits<uint32_t>::max(), ErrorCode::kerCorruptedMetadata);
#endif
auto jpg_img_off = static_cast<long>(jpg_img_off_u32);
auto jpg_img_len = static_cast<long>(jpg_img_len_u32);

@ -1456,7 +1456,7 @@ static const TagInfo* findTagInfo(uint16_t tag, IfdId group) {
const TagInfo* result = nullptr;
const TagInfo* tags = [=] {
if (group == IfdId::gpsId)
return group == IfdId::exifId ? Internal::exifTagList() : Internal::gpsTagList();
return Internal::gpsTagList();
return group == IfdId::exifId ? Internal::exifTagList() : nullptr;
}();
if (tags) {

@ -977,7 +977,7 @@ std::ostream& TimeValue::write(std::ostream& os) const {
int64_t TimeValue::toInt64(size_t /*n*/) const {
// Returns number of seconds in the day in UTC.
auto result = static_cast<int64_t>(time_.hour - time_.tzHour) * 60 * 60;
result += (time_.minute - time_.tzMinute) * 60;
result += static_cast<int64_t>(time_.minute - time_.tzMinute) * 60;
result += time_.second;
if (result < 0) {
result += 86400;

Loading…
Cancel
Save