From debf5d373ae98ce8c864bebb9bd2e8dd4f0cd733 Mon Sep 17 00:00:00 2001
From: Piotr Kosko
Date: Tue, 2 Oct 2018 13:25:19 +0200
Subject: [PATCH] [Archive][Exif] Added missing error checking
[Verification] Code compiles without errors.
Change-Id: I588a1d08f4dea4a19038653b2889a1daa5b45673
Signed-off-by: Piotr Kosko
---
src/archive/zip_add_request.cc | 6 +++++-
src/exif/jpeg_file.cc | 6 +++++-
src/humanactivitymonitor/humanactivitymonitor_manager.cc | 4 ++--
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/archive/zip_add_request.cc b/src/archive/zip_add_request.cc
index d8cb38d..d6e862f 100644
--- a/src/archive/zip_add_request.cc
+++ b/src/archive/zip_add_request.cc
@@ -360,7 +360,11 @@ PlatformResult ZipAddRequest::addToZipArchive(filesystem::NodePtr src_file_node)
// Get file length
fseek(m_input_file, 0, SEEK_END);
const size_t in_file_size = ftell(m_input_file);
- fseek(m_input_file, 0, SEEK_SET);
+ int res = fseek(m_input_file, 0, SEEK_SET);
+ if (0 != res) {
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Reading input file failed",
+ ("fseek failed with error! [%d]", res));
+ }
LoggerD("Source file: [%s] size: %d - %s", src_file_path.c_str(), in_file_size,
bytesToReadableString(in_file_size).c_str());
diff --git a/src/exif/jpeg_file.cc b/src/exif/jpeg_file.cc
index aefd179..39bf00c 100644
--- a/src/exif/jpeg_file.cc
+++ b/src/exif/jpeg_file.cc
@@ -148,7 +148,11 @@ PlatformResult JpegFile::load(const std::string& path) {
("Couldn't open Jpeg file: [%s]", path.c_str()));
}
- fseek(m_in_file, 0, SEEK_END);
+ int res = fseek(m_in_file, 0, SEEK_END);
+ if (0 != res) {
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Reading JPEG file failed",
+ ("fseek failed with error! [%d]", res));
+ }
long ftell_val = ftell(m_in_file);
if (0 > ftell_val) {
diff --git a/src/humanactivitymonitor/humanactivitymonitor_manager.cc b/src/humanactivitymonitor/humanactivitymonitor_manager.cc
index 1dc5779..13f3a0c 100644
--- a/src/humanactivitymonitor/humanactivitymonitor_manager.cc
+++ b/src/humanactivitymonitor/humanactivitymonitor_manager.cc
@@ -1523,8 +1523,8 @@ HumanActivityMonitorManager::HumanActivityMonitorManager()
return ConvertRecordedTime(data, obj);
};
- monitors_.insert(std::make_pair(kActivityTypePedometer,
- std::make_shared()));
+ monitors_.insert(
+ std::make_pair(kActivityTypePedometer, std::make_shared()));
monitors_.insert(std::make_pair(kActivityTypeWristUp,
std::make_shared(kActivityTypeWristUp)));
monitors_.insert(std::make_pair(
--
2.7.4