Make AIDL forbid return values/out parameters for oneway methods
Change-Id: I1a648eea272c826cab45947b2f63c552fa787d6d
Test: Full android build
Bug: 25118670
Signed-off-by: Casey Dahlin <sadmac@google.com>
diff --git a/aidl.cpp b/aidl.cpp
index d50a1c2..be22f9f 100644
--- a/aidl.cpp
+++ b/aidl.cpp
@@ -192,17 +192,33 @@
// Has to be a pointer due to deleting copy constructor. No idea why.
map<string, const AidlMethod*> method_names;
for (const auto& m : c->GetMethods()) {
+ bool oneway = m->IsOneway() || c->IsOneway();
+
if (!types->AddContainerType(m->GetType().GetName()) ||
!types->IsValidReturnType(m->GetType(), filename)) {
err = 1; // return type is invalid
}
+ if (oneway && m->GetType().GetName() != "void") {
+ cerr << filename << ":" << m->GetLine()
+ << "oneway method cannot return a value: "
+ << m->GetName() << endl;
+ err = 1;
+ }
+
int index = 1;
for (const auto& arg : m->GetArguments()) {
if (!types->AddContainerType(arg->GetType().GetName()) ||
!types->IsValidArg(*arg, index, filename)) {
err = 1;
}
+
+ if (oneway && arg->IsOut()) {
+ cerr << filename << ":" << m->GetLine()
+ << "oneway method cannot have out parameters: "
+ << m->GetName() << endl;
+ err = 1;
+ }
}
auto it = method_names.find(m->GetName());