summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2017-04-20 04:31:47 +0200
committerandroid-build-merger <android-build-merger@google.com>2017-04-20 04:31:47 +0200
commit7a004a840213f2760694e031504e7f8a37a5a8a7 (patch)
tree8dd6a3289d3e0445bb5506e9d8505daa043834fb
parentMerge "Call libvintf to verify package compatibility." am: b0945e1a23 am: 8e7884abcc am: d7a065eb1c (diff)
parentMerge "Minor clean up to minadbd_services.cpp" am: fa7d55a7e3 am: 235a2cc1c7 (diff)
downloadandroid_bootable_recovery-7a004a840213f2760694e031504e7f8a37a5a8a7.tar
android_bootable_recovery-7a004a840213f2760694e031504e7f8a37a5a8a7.tar.gz
android_bootable_recovery-7a004a840213f2760694e031504e7f8a37a5a8a7.tar.bz2
android_bootable_recovery-7a004a840213f2760694e031504e7f8a37a5a8a7.tar.lz
android_bootable_recovery-7a004a840213f2760694e031504e7f8a37a5a8a7.tar.xz
android_bootable_recovery-7a004a840213f2760694e031504e7f8a37a5a8a7.tar.zst
android_bootable_recovery-7a004a840213f2760694e031504e7f8a37a5a8a7.zip
-rw-r--r--minadbd/minadbd_services.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/minadbd/minadbd_services.cpp b/minadbd/minadbd_services.cpp
index a6aa321ca..61c06cc0a 100644
--- a/minadbd/minadbd_services.cpp
+++ b/minadbd/minadbd_services.cpp
@@ -21,6 +21,7 @@
#include <string.h>
#include <unistd.h>
+#include <string>
#include <thread>
#include "adb.h"
@@ -28,33 +29,30 @@
#include "fuse_adb_provider.h"
#include "sysdeps.h"
-static void sideload_host_service(int sfd, void* data) {
- char* args = reinterpret_cast<char*>(data);
+static void sideload_host_service(int sfd, const std::string& args) {
int file_size;
int block_size;
- if (sscanf(args, "%d:%d", &file_size, &block_size) != 2) {
- printf("bad sideload-host arguments: %s\n", args);
+ if (sscanf(args.c_str(), "%d:%d", &file_size, &block_size) != 2) {
+ printf("bad sideload-host arguments: %s\n", args.c_str());
exit(1);
}
- free(args);
printf("sideload-host file size %d block size %d\n", file_size, block_size);
int result = run_adb_fuse(sfd, file_size, block_size);
printf("sideload_host finished\n");
- sleep(1);
exit(result == 0 ? 0 : 1);
}
-static int create_service_thread(void (*func)(int, void *), void *cookie) {
+static int create_service_thread(void (*func)(int, const std::string&), const std::string& args) {
int s[2];
if (adb_socketpair(s)) {
printf("cannot create service socket pair\n");
return -1;
}
- std::thread([s, func, cookie]() { func(s[1], cookie); }).detach();
+ std::thread([s, func, args]() { func(s[1], args); }).detach();
VLOG(SERVICES) << "service thread started, " << s[0] << ":" << s[1];
return s[0];
@@ -69,7 +67,7 @@ int service_to_fd(const char* name, const atransport* transport) {
// sideload-host).
exit(3);
} else if (!strncmp(name, "sideload-host:", 14)) {
- char* arg = strdup(name + 14);
+ std::string arg(name + 14);
ret = create_service_thread(sideload_host_service, arg);
}
if (ret >= 0) {