OSDN Git Service

bootctl: Return<T> is non-copyable.
authorYifan Hong <elsk@google.com>
Fri, 17 Feb 2017 22:35:07 +0000 (14:35 -0800)
committerYifan Hong <elsk@google.com>
Fri, 17 Feb 2017 22:49:38 +0000 (22:49 +0000)
By copying the Return<T> in handl_return, the original
Return<T> object is left status unchecked when it is destroyed.

Test: compiles
Change-Id: I7bf21370e8323374deb9a8d3f252e9742357f000

bootctl/bootctl.cpp

index 2b3865e..6dda28f 100644 (file)
@@ -83,7 +83,7 @@ static std::function<void(CommandResult)> generate_callback(CommandResult *crp)
     };
 }
 
-static int handle_return(Return<void> ret, CommandResult cr, const char* errStr) {
+static int handle_return(const Return<void> &ret, CommandResult cr, const char* errStr) {
     if (!ret.isOk()) {
         fprintf(stderr, errStr, ret.description().c_str());
         return EX_SOFTWARE;
@@ -117,7 +117,7 @@ static int do_set_slot_as_unbootable(sp<IBootControl> module,
     return handle_return(ret, cr, "Error setting slot as unbootable: %s\n");
 }
 
-static int handle_return(Return<BoolResult> ret, const char* errStr) {
+static int handle_return(const Return<BoolResult> &ret, const char* errStr) {
     if (!ret.isOk()) {
         fprintf(stderr, errStr, ret.description().c_str());
         return EX_SOFTWARE;