dbus: Clang format files
Clang format message logic files.
BUG=None
TEST=Compile.
Change-Id: Ia13728381fd16705fba8091236622a42e7e59f0e
Reviewed-on: https://chromium-review.googlesource.com/1069685
Reviewed-by: Ryo Hashimoto <hashimoto@chromium.org>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560989}
CrOS-Libchrome-Original-Commit: 34928ece67a926e85d2969282edc701e89a6e646
diff --git a/dbus/message.cc b/dbus/message.cc
index 8d8c9b7..a971eab 100644
--- a/dbus/message.cc
+++ b/dbus/message.cc
@@ -218,8 +218,8 @@
base::ScopedFD file_descriptor;
if (!reader->PopFileDescriptor(&file_descriptor))
return kBrokenMessage;
- output += indent + "fd#" +
- base::IntToString(file_descriptor.get()) + "\n";
+ output +=
+ indent + "fd#" + base::IntToString(file_descriptor.get()) + "\n";
break;
}
default:
@@ -428,9 +428,8 @@
const std::string& error_name,
const std::string& error_message) {
std::unique_ptr<ErrorResponse> response(new ErrorResponse());
- response->Init(dbus_message_new_error(method_call->raw_message(),
- error_name.c_str(),
- error_message.c_str()));
+ response->Init(dbus_message_new_error(
+ method_call->raw_message(), error_name.c_str(), error_message.c_str()));
return response;
}
@@ -439,8 +438,7 @@
//
MessageWriter::MessageWriter(Message* message)
- : message_(message),
- container_is_open_(false) {
+ : message_(message), container_is_open_(false) {
memset(&raw_message_iter_, 0, sizeof(raw_message_iter_));
if (message)
dbus_message_iter_init_append(message_->raw_message(), &raw_message_iter_);
@@ -519,9 +517,7 @@
DCHECK(!container_is_open_);
const bool success = dbus_message_iter_open_container(
- &raw_message_iter_,
- DBUS_TYPE_ARRAY,
- signature.c_str(),
+ &raw_message_iter_, DBUS_TYPE_ARRAY, signature.c_str(),
&writer->raw_message_iter_);
CHECK(success) << "Unable to allocate memory";
container_is_open_ = true;
@@ -532,9 +528,7 @@
DCHECK(!container_is_open_);
const bool success = dbus_message_iter_open_container(
- &raw_message_iter_,
- DBUS_TYPE_VARIANT,
- signature.c_str(),
+ &raw_message_iter_, DBUS_TYPE_VARIANT, signature.c_str(),
&writer->raw_message_iter_);
CHECK(success) << "Unable to allocate memory";
container_is_open_ = true;
@@ -576,9 +570,7 @@
MessageWriter array_writer(message_);
OpenArray("y", &array_writer);
const bool success = dbus_message_iter_append_fixed_array(
- &(array_writer.raw_message_iter_),
- DBUS_TYPE_BYTE,
- &values,
+ &(array_writer.raw_message_iter_), DBUS_TYPE_BYTE, &values,
static_cast<int>(length));
CHECK(success) << "Unable to allocate memory";
CloseContainer(&array_writer);
@@ -589,9 +581,7 @@
MessageWriter array_writer(message_);
OpenArray("d", &array_writer);
const bool success = dbus_message_iter_append_fixed_array(
- &(array_writer.raw_message_iter_),
- DBUS_TYPE_DOUBLE,
- &values,
+ &(array_writer.raw_message_iter_), DBUS_TYPE_DOUBLE, &values,
static_cast<int>(length));
CHECK(success) << "Unable to allocate memory";
CloseContainer(&array_writer);
@@ -682,8 +672,8 @@
void MessageWriter::AppendBasic(int dbus_type, const void* value) {
DCHECK(!container_is_open_);
- const bool success = dbus_message_iter_append_basic(
- &raw_message_iter_, dbus_type, value);
+ const bool success =
+ dbus_message_iter_append_basic(&raw_message_iter_, dbus_type, value);
// dbus_message_iter_append_basic() fails only when there is not enough
// memory. We don't return this error as there is nothing we can do when
// it fails to allocate memory for a byte etc.
@@ -708,8 +698,7 @@
// MessageReader implementation.
//
-MessageReader::MessageReader(Message* message)
- : message_(message) {
+MessageReader::MessageReader(Message* message) : message_(message) {
memset(&raw_message_iter_, 0, sizeof(raw_message_iter_));
if (message)
dbus_message_iter_init(message_->raw_message(), &raw_message_iter_);
@@ -799,7 +788,7 @@
bool MessageReader::PopArrayOfBytes(const uint8_t** bytes, size_t* length) {
MessageReader array_reader(message_);
if (!PopArray(&array_reader))
- return false;
+ return false;
// An empty array is allowed.
if (!array_reader.HasMoreData()) {
*length = 0;
@@ -809,8 +798,7 @@
if (!array_reader.CheckDataType(DBUS_TYPE_BYTE))
return false;
int int_length = 0;
- dbus_message_iter_get_fixed_array(&array_reader.raw_message_iter_,
- bytes,
+ dbus_message_iter_get_fixed_array(&array_reader.raw_message_iter_, bytes,
&int_length);
*length = static_cast<size_t>(int_length);
return true;
@@ -828,15 +816,13 @@
if (!array_reader.CheckDataType(DBUS_TYPE_DOUBLE))
return false;
int int_length = 0;
- dbus_message_iter_get_fixed_array(&array_reader.raw_message_iter_,
- doubles,
+ dbus_message_iter_get_fixed_array(&array_reader.raw_message_iter_, doubles,
&int_length);
*length = static_cast<size_t>(int_length);
return true;
}
-bool MessageReader::PopArrayOfStrings(
- std::vector<std::string> *strings) {
+bool MessageReader::PopArrayOfStrings(std::vector<std::string>* strings) {
strings->clear();
MessageReader array_reader(message_);
if (!PopArray(&array_reader))
@@ -851,7 +837,7 @@
}
bool MessageReader::PopArrayOfObjectPaths(
- std::vector<ObjectPath> *object_paths) {
+ std::vector<ObjectPath>* object_paths) {
object_paths->clear();
MessageReader array_reader(message_);
if (!PopArray(&array_reader))
@@ -956,8 +942,7 @@
bool MessageReader::CheckDataType(int dbus_type) {
const int actual_type = dbus_message_iter_get_arg_type(&raw_message_iter_);
if (actual_type != dbus_type) {
- VLOG(1) << "Type " << dbus_type << " is expected but got "
- << actual_type;
+ VLOG(1) << "Type " << dbus_type << " is expected but got " << actual_type;
return false;
}
return true;
@@ -980,8 +965,7 @@
if (!CheckDataType(dbus_type))
return false;
- dbus_message_iter_recurse(&raw_message_iter_,
- &sub_reader->raw_message_iter_);
+ dbus_message_iter_recurse(&raw_message_iter_, &sub_reader->raw_message_iter_);
dbus_message_iter_next(&raw_message_iter_);
return true;
}
diff --git a/dbus/message.h b/dbus/message.h
index c9eca43..7b00d40 100644
--- a/dbus/message.h
+++ b/dbus/message.h
@@ -26,7 +26,6 @@
} // namespace protobuf
} // namespace google
-
namespace dbus {
class MessageWriter;
@@ -34,7 +33,7 @@
// DBUS_TYPE_UNIX_FD was added in D-Bus version 1.4
#if !defined(DBUS_TYPE_UNIX_FD)
-#define DBUS_TYPE_UNIX_FD ((int) 'h')
+#define DBUS_TYPE_UNIX_FD ((int)'h')
#endif
// Returns true if Unix FD passing is supported in libdbus.
@@ -61,7 +60,7 @@
MESSAGE_METHOD_RETURN = DBUS_MESSAGE_TYPE_METHOD_RETURN,
MESSAGE_SIGNAL = DBUS_MESSAGE_TYPE_SIGNAL,
MESSAGE_ERROR = DBUS_MESSAGE_TYPE_ERROR,
- };
+ };
// The data type used in the D-Bus type system. See the comment at
// MessageType for why we are redefining data types here.
@@ -154,8 +153,7 @@
// MethodCall method_call(DBUS_INTERFACE_INTROSPECTABLE, "Get");
//
// The constructor creates the internal raw message.
- MethodCall(const std::string& interface_name,
- const std::string& method_name);
+ MethodCall(const std::string& interface_name, const std::string& method_name);
// Returns a newly created MethodCall from the given raw message of the
// type DBUS_MESSAGE_TYPE_METHOD_CALL. Takes the ownership of |raw_message|.
@@ -182,8 +180,7 @@
// Signal signal(DBUS_INTERFACE_INTROSPECTABLE, "PropertiesChanged");
//
// The constructor creates the internal raw_message_.
- Signal(const std::string& interface_name,
- const std::string& method_name);
+ Signal(const std::string& interface_name, const std::string& method_name);
// Returns a newly created SIGNAL from the given raw message of the type
// DBUS_MESSAGE_TYPE_SIGNAL. Takes the ownership of |raw_message|.
@@ -224,7 +221,7 @@
// ErrorResponse is a type of message used to return an error to the
// caller of a method.
-class CHROME_DBUS_EXPORT ErrorResponse: public Response {
+class CHROME_DBUS_EXPORT ErrorResponse : public Response {
public:
// Returns a newly created Response from the given raw message of the
// type DBUS_MESSAGE_TYPE_METHOD_RETURN. Takes the ownership of |raw_message|.
@@ -485,7 +482,7 @@
bool CheckDataType(int dbus_type);
// Helper function used to implement PopByte() etc.
- bool PopBasic(int dbus_type, void *value);
+ bool PopBasic(int dbus_type, void* value);
// Helper function used to implement PopArray() etc.
bool PopContainer(int dbus_type, MessageReader* sub_reader);
diff --git a/dbus/message_unittest.cc b/dbus/message_unittest.cc
index b75f2fd..ef2a6d0 100644
--- a/dbus/message_unittest.cc
+++ b/dbus/message_unittest.cc
@@ -35,7 +35,7 @@
uint8_t byte_value = 0;
ASSERT_TRUE(reader.PopByte(&byte_value));
- EXPECT_EQ(123, byte_value); // Should match with the input.
+ EXPECT_EQ(123, byte_value); // Should match with the input.
ASSERT_FALSE(reader.HasMoreData()); // Should not have more data to read.
// Try to get another byte. Should fail.
@@ -335,7 +335,6 @@
EXPECT_EQ(receive_message.number(), send_message.number());
}
-
// Test that an array can be properly written and read. We only have this
// test for array, as repeating this for other container types is too
// redundant.
@@ -512,15 +511,16 @@
MessageWriter writer(&method_call);
writer.AppendString("payload");
- EXPECT_EQ("message_type: MESSAGE_METHOD_CALL\n"
- "destination: com.example.Service\n"
- "path: /com/example/Object\n"
- "interface: com.example.Interface\n"
- "member: SomeMethod\n"
- "signature: s\n"
- "\n"
- "string \"payload\"\n",
- method_call.ToString());
+ EXPECT_EQ(
+ "message_type: MESSAGE_METHOD_CALL\n"
+ "destination: com.example.Service\n"
+ "path: /com/example/Object\n"
+ "interface: com.example.Interface\n"
+ "member: SomeMethod\n"
+ "signature: s\n"
+ "\n"
+ "string \"payload\"\n",
+ method_call.ToString());
}
TEST(MessageTest, MethodCall_FromRawMessage) {
@@ -544,14 +544,15 @@
MessageWriter writer(&signal);
writer.AppendString("payload");
- EXPECT_EQ("message_type: MESSAGE_SIGNAL\n"
- "path: /com/example/Object\n"
- "interface: com.example.Interface\n"
- "member: SomeSignal\n"
- "signature: s\n"
- "\n"
- "string \"payload\"\n",
- signal.ToString());
+ EXPECT_EQ(
+ "message_type: MESSAGE_SIGNAL\n"
+ "path: /com/example/Object\n"
+ "interface: com.example.Interface\n"
+ "member: SomeSignal\n"
+ "signature: s\n"
+ "\n"
+ "string \"payload\"\n",
+ signal.ToString());
}
TEST(MessageTest, Signal_FromRawMessage) {
@@ -585,7 +586,7 @@
TEST(MessageTest, ErrorResponse_FromMethodCall) {
const uint32_t kSerial = 123;
-const char kErrorMessage[] = "error message";
+ const char kErrorMessage[] = "error message";
MethodCall method_call("com.example.Interface", "SomeMethod");
method_call.SetSerial(kSerial);
@@ -672,12 +673,13 @@
MessageWriter writer(message.get());
writer.AppendString(kLongString);
- ASSERT_EQ("message_type: MESSAGE_METHOD_RETURN\n"
- "signature: s\n\n"
- "string \"oooooooooooooooooooooooooooooooooooooooooooooooo"
- "oooooooooooooooooooooooooooooooooooooooooooooooooooo... "
- "(1000 bytes in total)\"\n",
- message->ToString());
+ ASSERT_EQ(
+ "message_type: MESSAGE_METHOD_RETURN\n"
+ "signature: s\n\n"
+ "string \"oooooooooooooooooooooooooooooooooooooooooooooooo"
+ "oooooooooooooooooooooooooooooooooooooooooooooooooooo... "
+ "(1000 bytes in total)\"\n",
+ message->ToString());
}
} // namespace dbus