diff options
| author | 2019-10-08 07:19:09 +0000 | |
|---|---|---|
| committer | 2019-10-08 07:19:09 +0000 | |
| commit | 463b7bd2e77d19fd33ce8e02aa79df441c11eb9f (patch) | |
| tree | 167b666933aca793157407f1c7bac226090cf0d0 | |
| parent | 5bcceefd3c190c49655db6b8227f9eb4e841d7b8 (diff) | |
| parent | b2c0255f13ebc922a66595622dbea400937f3f26 (diff) | |
Merge "[installd] fix -Wdangling-gsl in test"
| -rw-r--r-- | cmds/installd/tests/installd_cache_test.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/cmds/installd/tests/installd_cache_test.cpp b/cmds/installd/tests/installd_cache_test.cpp index db0907017c..5a5cb53431 100644 --- a/cmds/installd/tests/installd_cache_test.cpp +++ b/cmds/installd/tests/installd_cache_test.cpp @@ -67,29 +67,29 @@ bool create_cache_path(char path[PKG_PATH_MAX] ATTRIBUTE_UNUSED, } static void mkdir(const char* path) { - const char* fullPath = StringPrintf("/data/local/tmp/user/0/%s", path).c_str(); - ::mkdir(fullPath, 0755); + const std::string fullPath = StringPrintf("/data/local/tmp/user/0/%s", path); + ::mkdir(fullPath.c_str(), 0755); } static void touch(const char* path, int len, int time) { - const char* fullPath = StringPrintf("/data/local/tmp/user/0/%s", path).c_str(); - int fd = ::open(fullPath, O_RDWR | O_CREAT, 0644); + const std::string fullPath = StringPrintf("/data/local/tmp/user/0/%s", path); + int fd = ::open(fullPath.c_str(), O_RDWR | O_CREAT, 0644); ::fallocate(fd, 0, 0, len); ::close(fd); struct utimbuf times; times.actime = times.modtime = std::time(0) + time; - ::utime(fullPath, ×); + ::utime(fullPath.c_str(), ×); } static int exists(const char* path) { - const char* fullPath = StringPrintf("/data/local/tmp/user/0/%s", path).c_str(); - return ::access(fullPath, F_OK); + const std::string fullPath = StringPrintf("/data/local/tmp/user/0/%s", path); + return ::access(fullPath.c_str(), F_OK); } static int64_t size(const char* path) { - const char* fullPath = StringPrintf("/data/local/tmp/user/0/%s", path).c_str(); + const std::string fullPath = StringPrintf("/data/local/tmp/user/0/%s", path); struct stat buf; - if (!stat(fullPath, &buf)) { + if (!stat(fullPath.c_str(), &buf)) { return buf.st_size; } else { return -1; @@ -107,8 +107,8 @@ static int64_t free() { } static void setxattr(const char* path, const char* key) { - const char* fullPath = StringPrintf("/data/local/tmp/user/0/%s", path).c_str(); - ::setxattr(fullPath, key, "", 0, 0); + const std::string fullPath = StringPrintf("/data/local/tmp/user/0/%s", path); + ::setxattr(fullPath.c_str(), key, "", 0, 0); } class CacheTest : public testing::Test { |