summaryrefslogtreecommitdiffstats
path: root/init/bootchart.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-03-10 08:39:45 -0700
committerElliott Hughes <enh@google.com>2015-03-20 16:03:41 -0700
commit81399e1e0e9189b1b87531bfb566ba5386ab567f (patch)
tree4cf31b001d0ae333bea76ee92c6a9cb4da769a2f /init/bootchart.cpp
parentdb7a994e1687574a675ccf5d56aa76df4cd98a88 (diff)
downloadcore-81399e1e0e9189b1b87531bfb566ba5386ab567f.tar.gz
core-81399e1e0e9189b1b87531bfb566ba5386ab567f.tar.bz2
core-81399e1e0e9189b1b87531bfb566ba5386ab567f.zip
Use unique_ptr to call closedir.
Change-Id: I8f572a06ce59283e5bd444ae0491dea71b0ea304
Diffstat (limited to 'init/bootchart.cpp')
-rw-r--r--init/bootchart.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/init/bootchart.cpp b/init/bootchart.cpp
index 530eba806..03c8b300a 100644
--- a/init/bootchart.cpp
+++ b/init/bootchart.cpp
@@ -30,6 +30,7 @@
#include <time.h>
#include <unistd.h>
+#include <memory>
#include <string>
#include <base/file.h>
@@ -114,9 +115,9 @@ static void do_log_file(FILE* log, const char* procfile) {
static void do_log_procs(FILE* log) {
do_log_uptime(log);
- DIR* dir = opendir("/proc");
+ std::unique_ptr<DIR, int(*)(DIR*)> dir(opendir("/proc"), closedir);
struct dirent* entry;
- while ((entry = readdir(dir)) != NULL) {
+ while ((entry = readdir(dir.get())) != NULL) {
// Only match numeric values.
char* end;
int pid = strtol(entry->d_name, &end, 10);
@@ -146,7 +147,6 @@ static void do_log_procs(FILE* log) {
}
}
}
- closedir(dir);
fputc('\n', log);
}