From fa1a494f560f57c1a0f4c3028c04d6be78b0c7bc Mon Sep 17 00:00:00 2001 From: Ningyuan Wang Date: Wed, 30 Nov 2016 15:20:04 -0800 Subject: [PATCH] Create parcelable_utils.h for helper macros This creates a new file parceable_utils.h for helper macros used in C++ binder parcelable classes. Currently this only includes macro RETURN_IF_FAILED. Bug: None Change-Id: I02b1e7feecb9c3879961f1bf6ac50458332c1a91 Test: compile, unit tests --- parcelable_utils.h | 39 +++++++++++++++++++++++++++++++++++++++ scanning/scan_result.cpp | 12 ++---------- 2 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 parcelable_utils.h diff --git a/parcelable_utils.h b/parcelable_utils.h new file mode 100644 index 0000000..d3ac566 --- /dev/null +++ b/parcelable_utils.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WIFICOND_PARCELABLE_UTILS_H_ +#define WIFICOND_PARCELABLE_UTILS_H_ + +namespace android { +namespace wificond { +namespace parcelable_utils { + +#define RETURN_IF_FAILED(expression_to_evaluate) \ + { \ + status_t return_status = expression_to_evaluate; \ + if (return_status) { \ + LOG(ERROR) << "Failed to parse binder parcelable object at " \ + << __FILE__ << ":" << __LINE__; \ + return return_status; \ + } \ + } + + +} // namespace parcelable_utils +} // namespace wificond +} // namespace android + +#endif // WIFICOND_PARCELABLE_UTILS_H_ diff --git a/scanning/scan_result.cpp b/scanning/scan_result.cpp index 8bc6b24..b6080ae 100644 --- a/scanning/scan_result.cpp +++ b/scanning/scan_result.cpp @@ -21,6 +21,8 @@ #include +#include "wificond/parcelable_utils.h" + using android::status_t; using android::OK; using std::string; @@ -32,16 +34,6 @@ namespace server { namespace wifi { namespace wificond { -#define RETURN_IF_FAILED(calledOnce) \ - { \ - status_t returnStatus = calledOnce; \ - if (returnStatus) { \ - LOG(ERROR) << "Failed to parse binder parcelable object at " \ - << __FILE__ << ":" << __LINE__; \ - return returnStatus; \ - } \ - } - NativeScanResult::NativeScanResult(std::vector& ssid_, std::vector& bssid_, std::vector& info_element_,