aidl: lift options.Ok into aidl_entry
This way aidl_entry can handle it for all callers (notably, for the
fuzzer).
Note: corpus entry not added because this is very low-hanging fruit.
Fixes: 196155232
Test: aidl_unittest, fuzzer
Change-Id: Icff2e8e16338bd6ff3b2245b1eedd46220391b18
diff --git a/aidl.cpp b/aidl.cpp
index 5e1bbbd..ffddce1 100644
--- a/aidl.cpp
+++ b/aidl.cpp
@@ -774,28 +774,32 @@
AidlErrorLog::clearError();
bool success = false;
- switch (options.GetTask()) {
- case Options::Task::HELP:
- success = true;
- break;
- case Options::Task::COMPILE:
- success = android::aidl::compile_aidl(options, io_delegate);
- break;
- case Options::Task::PREPROCESS:
- success = android::aidl::Preprocess(options, io_delegate);
- break;
- case Options::Task::DUMP_API:
- success = android::aidl::dump_api(options, io_delegate);
- break;
- case Options::Task::CHECK_API:
- success = android::aidl::check_api(options, io_delegate);
- break;
- case Options::Task::DUMP_MAPPINGS:
- success = android::aidl::dump_mappings(options, io_delegate);
- break;
- default:
- AIDL_FATAL(AIDL_LOCATION_HERE)
- << "Unrecognized task: " << static_cast<size_t>(options.GetTask());
+ if (options.Ok()) {
+ switch (options.GetTask()) {
+ case Options::Task::HELP:
+ success = true;
+ break;
+ case Options::Task::COMPILE:
+ success = android::aidl::compile_aidl(options, io_delegate);
+ break;
+ case Options::Task::PREPROCESS:
+ success = android::aidl::Preprocess(options, io_delegate);
+ break;
+ case Options::Task::DUMP_API:
+ success = android::aidl::dump_api(options, io_delegate);
+ break;
+ case Options::Task::CHECK_API:
+ success = android::aidl::check_api(options, io_delegate);
+ break;
+ case Options::Task::DUMP_MAPPINGS:
+ success = android::aidl::dump_mappings(options, io_delegate);
+ break;
+ default:
+ AIDL_FATAL(AIDL_LOCATION_HERE)
+ << "Unrecognized task: " << static_cast<size_t>(options.GetTask());
+ }
+ } else {
+ AIDL_ERROR(options.GetErrorMessage()) << options.GetUsage();
}
const bool reportedError = AidlErrorLog::hadError();
diff --git a/main.cpp b/main.cpp
index 69ba060..c0078ba 100644
--- a/main.cpp
+++ b/main.cpp
@@ -31,10 +31,6 @@
int main(int argc, char* argv[]) {
Options options(argc, argv, kDefaultLang);
- if (!options.Ok()) {
- AIDL_ERROR(options.GetErrorMessage()) << options.GetUsage();
- return 1;
- }
// Only minimal functionality should go here, so that as much of possible of
// the aidl compiler is mocked with the single function `aidl_entry`