add .clang-format
Add .clang-format for automatic style.
Change-Id: I91e9acb28ca4218eba58dc13d10773bcb39c338f
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/file.hpp b/file.hpp
index 33df65f..7596db1 100644
--- a/file.hpp
+++ b/file.hpp
@@ -1,6 +1,9 @@
#pragma once
#include <unistd.h>
+
+#include <sstream>
+
namespace openpower
{
namespace sbe
@@ -13,58 +16,57 @@
*/
class FileDescriptor
{
- private:
- /** @brief File descriptor for the SBE FIFO device */
- int fd = -1;
+ private:
+ /** @brief File descriptor for the SBE FIFO device */
+ int fd = -1;
- public:
- FileDescriptor() = delete;
- FileDescriptor(const FileDescriptor&) = delete;
- FileDescriptor& operator=(const FileDescriptor&) = delete;
- FileDescriptor(FileDescriptor&&) = delete;
- FileDescriptor& operator=(FileDescriptor&&) = delete;
+ public:
+ FileDescriptor() = delete;
+ FileDescriptor(const FileDescriptor&) = delete;
+ FileDescriptor& operator=(const FileDescriptor&) = delete;
+ FileDescriptor(FileDescriptor&&) = delete;
+ FileDescriptor& operator=(FileDescriptor&&) = delete;
- /** @brief Opens the input file and saves the file descriptor
- *
- * @param[in] devPath - Path of the file
- * @para,[in] accessModes - File access modes
- */
- FileDescriptor(const char* devPath, int accessModes)
+ /** @brief Opens the input file and saves the file descriptor
+ *
+ * @param[in] devPath - Path of the file
+ * @para,[in] accessModes - File access modes
+ */
+ FileDescriptor(const char* devPath, int accessModes)
+ {
+ fd = open(devPath, accessModes);
+ if (fd < 0)
{
- fd = open(devPath, accessModes);
- if (fd < 0)
- {
- //TODO:use elog infrastructure
- std::ostringstream errMsg;
- errMsg << "Opening the device with device path:" <<
- devPath << " and access modes:" << accessModes <<
- ",Failed with errno" << errno;
- throw std::runtime_error(errMsg.str().c_str());
- }
-
+ // TODO:use elog infrastructure
+ std::ostringstream errMsg;
+ errMsg << "Opening the device with device path:" << devPath
+ << " and access modes:" << accessModes
+ << ",Failed with errno" << errno;
+ throw std::runtime_error(errMsg.str().c_str());
}
+ }
- /** @brief Saves File descriptor and uses it to do file operation
- *
- * @param[in] fd - File descriptor
- */
- FileDescriptor(int fd) : fd(fd)
+ /** @brief Saves File descriptor and uses it to do file operation
+ *
+ * @param[in] fd - File descriptor
+ */
+ FileDescriptor(int fd) : fd(fd)
+ {
+ // Nothing
+ }
+
+ ~FileDescriptor()
+ {
+ if (fd >= 0)
{
- // Nothing
+ close(fd);
}
+ }
- ~FileDescriptor()
- {
- if (fd >= 0)
- {
- close(fd);
- }
- }
-
- int operator()()
- {
- return fd;
- }
+ int operator()()
+ {
+ return fd;
+ }
};
} // namespace internal