summaryrefslogtreecommitdiffstats
path: root/uncrypt
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-11-13 17:37:44 +0100
committerandroid-build-merger <android-build-merger@google.com>2015-11-13 17:37:44 +0100
commit11c26abe2d9f235461131ca00eaaff400da7d2fd (patch)
treecd94fb1681bc08f6dac3f34e9a7f003742441e5c /uncrypt
parentMerge "uncrypt: remove O_SYNC to avoid time-out failures" (diff)
parentMerge "We can use fclose directly in std::unique_ptr." (diff)
downloadandroid_bootable_recovery-11c26abe2d9f235461131ca00eaaff400da7d2fd.tar
android_bootable_recovery-11c26abe2d9f235461131ca00eaaff400da7d2fd.tar.gz
android_bootable_recovery-11c26abe2d9f235461131ca00eaaff400da7d2fd.tar.bz2
android_bootable_recovery-11c26abe2d9f235461131ca00eaaff400da7d2fd.tar.lz
android_bootable_recovery-11c26abe2d9f235461131ca00eaaff400da7d2fd.tar.xz
android_bootable_recovery-11c26abe2d9f235461131ca00eaaff400da7d2fd.tar.zst
android_bootable_recovery-11c26abe2d9f235461131ca00eaaff400da7d2fd.zip
Diffstat (limited to 'uncrypt')
-rw-r--r--uncrypt/uncrypt.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/uncrypt/uncrypt.cpp b/uncrypt/uncrypt.cpp
index 6db438258..4956cc297 100644
--- a/uncrypt/uncrypt.cpp
+++ b/uncrypt/uncrypt.cpp
@@ -186,8 +186,7 @@ static int produce_block_map(const char* path, const char* map_file, const char*
ALOGE("failed to open %s\n", map_file);
return -1;
}
- FILE* mapf = fdopen(mapfd, "w");
- unique_file mapf_holder(mapf);
+ std::unique_ptr<FILE, int(*)(FILE*)> mapf(fdopen(mapfd, "w"), fclose);
// Make sure we can write to the status_file.
if (!android::base::WriteStringToFd("0\n", status_fd)) {
@@ -212,7 +211,8 @@ static int produce_block_map(const char* path, const char* map_file, const char*
ranges[0] = -1;
ranges[1] = -1;
- fprintf(mapf, "%s\n%lld %lu\n", blk_dev, (long long)sb.st_size, (unsigned long)sb.st_blksize);
+ fprintf(mapf.get(), "%s\n%lld %lu\n",
+ blk_dev, (long long)sb.st_size, (unsigned long)sb.st_blksize);
unsigned char* buffers[WINDOW_SIZE];
if (encrypted) {
@@ -309,9 +309,9 @@ static int produce_block_map(const char* path, const char* map_file, const char*
++head_block;
}
- fprintf(mapf, "%d\n", range_used);
+ fprintf(mapf.get(), "%d\n", range_used);
for (int i = 0; i < range_used; ++i) {
- fprintf(mapf, "%d %d\n", ranges[i*2], ranges[i*2+1]);
+ fprintf(mapf.get(), "%d %d\n", ranges[i*2], ranges[i*2+1]);
}
if (fsync(mapfd) == -1) {