From f6e65e3f80e59866bfe74f4d82a9850216a65234 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Tue, 17 Nov 2015 14:08:20 -0800 Subject: [PATCH] adb: don't use adb_dirname in between getting and printing errno. adb_dirname might trample over the errno value we want to print. Move the adb_dirname call out to a local to prevent this. Change-Id: I8a62cb2e1be8704225a9c3b72dd01259c7eaaae4 --- adb/file_sync_client.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adb/file_sync_client.cpp b/adb/file_sync_client.cpp index a2d2a66bf..ad3836989 100644 --- a/adb/file_sync_client.cpp +++ b/adb/file_sync_client.cpp @@ -403,9 +403,9 @@ static bool sync_recv(SyncConnection& sc, const char* rpath, const char* lpath) if (!sc.SendRequest(ID_RECV, rpath)) return false; adb_unlink(lpath); - if (!mkdirs(adb_dirname(lpath))) { - sc.Error("failed to create parent directory '%s': %s", - adb_dirname(lpath).c_str(), strerror(errno)); + const std::string dirpath = adb_dirname(lpath); + if (!mkdirs(dirpath.c_str())) { + sc.Error("failed to create parent directory '%s': %s", dirpath.c_str(), strerror(errno)); return false; }