Fix warnings reported by cpplint.
This CL fixes the warnings reported by cpplint and converts the code to
use PLOG() instead of calling LOG() with strerror(errno).
BUG=chromium:385849
TEST=Tested the following:
1. `FEATURES=test emerge-$BOARD chromeos-imageburner`
2. `cpplint.py --filter=-build/header_guard,-build/include_order *.h *.cc`
Change-Id: Id0285430747d323a63bbc85df11dd05e06bb32f7
Reviewed-on: https://chromium-review.googlesource.com/204463
Reviewed-by: Toni Barzic <tbarzic@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
diff --git a/image_burn_service.cc b/image_burn_service.cc
index 9fab946..d6da1b4 100644
--- a/image_burn_service.cc
+++ b/image_burn_service.cc
@@ -4,18 +4,16 @@
#include "image-burner/image_burn_service.h"
-#include <cstring>
#include <ctype.h>
#include <glib.h>
+#include <string>
+
#include <base/logging.h>
#include <dbus/dbus-glib-lowlevel.h>
-#include <fstream>
-#include <string>
-
-#include "image_burner.h"
-#include "marshal.h"
+#include "image-burner/image_burner.h"
+#include "image-burner/marshal.h"
namespace imageburn {
#include "image-burner/bindings/server.h"
diff --git a/image_burn_service.h b/image_burn_service.h
index 8cb84b8..31fed4d 100644
--- a/image_burn_service.h
+++ b/image_burn_service.h
@@ -5,14 +5,15 @@
#ifndef IMAGE_BURN_SERVICE_H_
#define IMAGE_BURN_SERVICE_H_
+#include <string>
+
#include <base/basictypes.h>
#include <base/memory/scoped_ptr.h>
#include <chromeos/dbus/abstract_dbus_service.h>
#include <chromeos/dbus/dbus.h>
#include <chromeos/dbus/service_constants.h>
-#include <string>
-#include "image_burner_impl.h"
+#include "image-burner/image_burner_impl.h"
namespace imageburn {
@@ -33,7 +34,7 @@
class ImageBurnService : public chromeos::dbus::AbstractDbusService,
public SignalSender {
public:
- ImageBurnService(BurnerImpl* burner_impl);
+ explicit ImageBurnService(BurnerImpl* burner_impl);
virtual ~ImageBurnService();
// chromeos::dbus::AbstractDbusService implementation.
diff --git a/image_burner.cc b/image_burner.cc
index 97387dc..3f112f4 100644
--- a/image_burner.cc
+++ b/image_burner.cc
@@ -4,11 +4,9 @@
#include "image-burner/image_burner.h"
-#include <iostream>
-
namespace imageburn {
-// Register with the glib type system.
+// Register with the glib type system.
// This macro automatically defines a number of functions and variables
// which are required to make session_manager functional as a GObject:
// - image_burner_parent_class
diff --git a/image_burner.h b/image_burner.h
index c011336..58b5e93 100644
--- a/image_burner.h
+++ b/image_burner.h
@@ -28,7 +28,7 @@
gchar *from_path,
gchar *to_path,
DBusGMethodInvocation* context);
-} // namespace imageburn.
+} // namespace imageburn
#endif // IMAGE_BURNER_INTERFACE_H_
diff --git a/image_burner_impl.cc b/image_burner_impl.cc
index f8ffc12..ab6c77f 100644
--- a/image_burner_impl.cc
+++ b/image_burner_impl.cc
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "image_burner_impl.h"
+#include "image-burner/image_burner_impl.h"
-#include <cstring>
#include <ctype.h>
#include <regex.h>
+
#include <base/basictypes.h>
#include <base/logging.h>
@@ -65,7 +65,7 @@
for (int i = 0; i < kFilePathPatternCount; ++i) {
regex_t re;
int status = regcomp(&re, kFilePathPatterns[i], REG_EXTENDED);
- DCHECK(status == 0);
+ DCHECK_EQ(0, status);
status = regexec(&re, path, 0, NULL, 0);
regfree(&re);
if (status == 0) {
@@ -153,4 +153,4 @@
return success;
}
-} // namespace imageburn.
+} // namespace imageburn
diff --git a/image_burner_impl.h b/image_burner_impl.h
index 2285819..faa1214 100644
--- a/image_burner_impl.h
+++ b/image_burner_impl.h
@@ -6,9 +6,10 @@
#define IMAGE_BURNER_IMPL_H_
#include <string>
+
#include <base/memory/scoped_ptr.h>
-#include "image_burner_utils_interfaces.h"
+#include "image-burner/image_burner_utils_interfaces.h"
namespace imageburn {
@@ -58,5 +59,5 @@
int data_block_size_;
};
-} // namespace imageburn.
+} // namespace imageburn
#endif // IMAGE_BURNER_IMPL_H_
diff --git a/image_burner_impl_unittest.cc b/image_burner_impl_unittest.cc
index 74dbced..1703886 100644
--- a/image_burner_impl_unittest.cc
+++ b/image_burner_impl_unittest.cc
@@ -2,10 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <cstring>
-
-#include "image_burner_impl.h"
-#include "image_burner_test_utils.h"
+#include "image-burner/image_burner_impl.h"
+#include "image-burner/image_burner_test_utils.h"
namespace imageburn {
@@ -379,7 +377,6 @@
EXPECT_EQ(burner_->BurnImage("some_path", "/dev/sdb"),
imageburn::IMAGEBURN_ERROR_FAILED_WRITING_TO_TARGET);
-
}
TEST_F(ImageBurnerImplTest, ErrorWritingWrongReturn) {
@@ -603,4 +600,4 @@
imageburn::IMAGEBURN_OK);
}
-} // namespace imageburn.
+} // namespace imageburn
diff --git a/image_burner_main.cc b/image_burner_main.cc
index 31b69a1..86d2496 100644
--- a/image_burner_main.cc
+++ b/image_burner_main.cc
@@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "image_burner.h"
-#include "image_burner_impl.h"
-#include "image_burner_utils.h"
#include <base/command_line.h>
#include <base/files/file_path.h>
#include <base/logging.h>
+#include "image-burner/image_burner.h"
+#include "image-burner/image_burner_impl.h"
+#include "image-burner/image_burner_utils.h"
+
int main(int argc, char* argv[]) {
CommandLine::Init(argc, argv);
diff --git a/image_burner_test_utils.h b/image_burner_test_utils.h
index 8add842..e76d862 100644
--- a/image_burner_test_utils.h
+++ b/image_burner_test_utils.h
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-#include <iostream>
#include <string>
-#include "image_burner_utils_interfaces.h"
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include "image-burner/image_burner_utils_interfaces.h"
namespace imageburn {
@@ -37,5 +37,5 @@
MOCK_METHOD1(GetRootPath, bool(std::string*));
};
-} // namespace imageburn.
+} // namespace imageburn
diff --git a/image_burner_utils.cc b/image_burner_utils.cc
index 1d67a5f..c0261e3 100644
--- a/image_burner_utils.cc
+++ b/image_burner_utils.cc
@@ -2,14 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "image_burner_utils.h"
+#include "image-burner/image_burner_utils.h"
-#include <cstring>
-#include <errno.h>
#include <fcntl.h>
-#include <rootdev/rootdev.h>
+#include <stdio.h>
#include <base/logging.h>
+#include <rootdev/rootdev.h>
namespace imageburn {
@@ -34,8 +33,7 @@
if (fd >= 0)
file_ = fdopen(fd, "wb");
if (!file_) {
- LOG(ERROR) << "Couldn't open target path " << path << ": "
- << strerror(errno);
+ PLOG(ERROR) << "Couldn't open target path " << path;
return false;
} else {
LOG(INFO) << path << " opened";
@@ -46,7 +44,7 @@
bool BurnWriter::Close() {
if (file_) {
if (fclose(file_) != 0) {
- LOG(ERROR) << "Couldn't close target file: " << strerror(errno);
+ PLOG(ERROR) << "Couldn't close target file";
return false;
} else {
LOG(INFO) << "Target file closed";
@@ -59,12 +57,12 @@
int BurnWriter::Write(char* data_block, int data_size) {
size_t written = fwrite(data_block, sizeof(char), data_size, file_);
if (written != static_cast<size_t>(data_size)) {
- LOG(ERROR) << "Error writing to target file: " << strerror(errno);
+ PLOG(ERROR) << "Error writing to target file";
return written;
}
if (!writes_count_ && fsync(fileno(file_))) {
- LOG(ERROR) << "Error syncing target file: " << strerror(errno);
+ PLOG(ERROR) << "Error syncing target file";
return -1;
}
writes_count_++;
@@ -87,8 +85,7 @@
Close();
file_ = fopen(path, "rb");
if (!file_) {
- LOG(ERROR) << "Couldn't open source path " << path << ": "
- << strerror(errno);
+ PLOG(ERROR) << "Couldn't open source path " << path;
return false;
} else {
LOG(INFO) << path << " opened";
@@ -99,7 +96,7 @@
bool BurnReader::Close() {
if (file_) {
if (fclose(file_) != 0) {
- LOG(ERROR) << "Couldn't close source file: " << strerror(errno);
+ PLOG(ERROR) << "Couldn't close source file";
return false;
} else {
LOG(INFO) << "Source file closed";
@@ -112,7 +109,7 @@
int BurnReader::Read(char* data_block, int data_size) {
int read = fread(data_block, sizeof(char), data_size, file_);
if (read < 0)
- LOG(ERROR) << "Error reading from source file: " << strerror(errno);
+ PLOG(ERROR) << "Error reading from source file";
return read;
}
@@ -134,5 +131,5 @@
return true;
}
-} // namespace imageburn.
+} // namespace imageburn
diff --git a/image_burner_utils.h b/image_burner_utils.h
index 58969e5..d6648e8 100644
--- a/image_burner_utils.h
+++ b/image_burner_utils.h
@@ -5,11 +5,11 @@
#ifndef IMAGE_BURNER_UTILS_H_
#define IMAGE_BURNER_UTILS_H_
-#include <fstream>
-#include <string>
#include <unistd.h>
-#include "image_burner_utils_interfaces.h"
+#include <string>
+
+#include "image-burner/image_burner_utils_interfaces.h"
namespace imageburn {
@@ -23,8 +23,8 @@
virtual int Write(char* data_block, int data_size);
private:
- FILE* file_;
- int writes_count_;
+ FILE* file_;
+ int writes_count_;
};
class BurnReader : public FileSystemReader {
@@ -46,7 +46,6 @@
virtual bool GetRootPath(std::string* path);
};
-} // namespace imageburn.
+} // namespace imageburn
#endif // IMAGE_BURNER_UTLS_H_
-
diff --git a/image_burner_utils_interfaces.h b/image_burner_utils_interfaces.h
index aed7df2..d1efb56 100644
--- a/image_burner_utils_interfaces.h
+++ b/image_burner_utils_interfaces.h
@@ -13,7 +13,7 @@
class FileSystemWriter {
public:
- virtual ~FileSystemWriter() {};
+ virtual ~FileSystemWriter() {}
virtual int Write(char* data_block, int data_size) = 0;
virtual bool Open(const char* path) = 0;
virtual bool Close() = 0;
@@ -21,7 +21,7 @@
class FileSystemReader {
public:
- virtual ~FileSystemReader() {};
+ virtual ~FileSystemReader() {}
virtual bool Open(const char* path) = 0;
virtual bool Close() = 0;
virtual int Read(char* data_block, int data_size) = 0;
@@ -30,19 +30,19 @@
class RootPathGetter {
public:
- virtual ~RootPathGetter() {};
+ virtual ~RootPathGetter() {}
virtual bool GetRootPath(std::string* path) = 0;
};
class SignalSender {
public:
- virtual ~SignalSender() {};
+ virtual ~SignalSender() {}
virtual void SendFinishedSignal(const char* target_path, bool success,
const char* error_message) = 0;
virtual void SendProgressSignal(int64 amount_burnt, int64 total_size,
const char* target_path) = 0;
};
-} // namespace imageburn.
-#endif // IMAGE_BURNER_UTILS_INTERFACES_H_
+} // namespace imageburn
+#endif // IMAGE_BURNER_UTILS_INTERFACES_H_