Fixed variable names according to Google C++ style.

Trivia question: what do you get when Java developers refactor C into C++?
Anser: a_bigMess

BUG: 26379932

Test: DumpstateTest passes

Change-Id: I64c00f3b5953f077fb646cdc45a1656060a4b46e
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 1ca3e03..ea07cdb 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -162,7 +162,7 @@
     if (!ds.IsZipping()) return;
     std::string title = "MOUNT INFO";
     mount_points.clear();
-    DurationReporter durationReporter(title, nullptr);
+    DurationReporter duration_reporter(title, nullptr);
     for_each_pid(do_mountinfo, nullptr);
     MYLOGD("%s: %d entries added to zip file\n", title.c_str(), (int)mount_points.size());
 }
@@ -703,7 +703,7 @@
     printf("Command line: %s\n", strtok(cmdline_buf, "\n"));
     printf("Bugreport format version: %s\n", version_.c_str());
     printf("Dumpstate info: id=%lu pid=%d dryRun=%d args=%s extraOptions=%s\n", id_, getpid(),
-           dryRun_, args_.c_str(), extraOptions_.c_str());
+           dry_run_, args_.c_str(), extra_options_.c_str());
     printf("\n");
 }
 
@@ -795,7 +795,7 @@
         return;
     }
     MYLOGD("Adding dir %s (recursive: %d)\n", dir.c_str(), recursive);
-    DurationReporter durationReporter(dir, nullptr);
+    DurationReporter duration_reporter(dir, nullptr);
     dump_files("", dir.c_str(), recursive ? skip_none : is_dir, _add_file_from_fd);
 }
 
@@ -841,7 +841,7 @@
 }
 
 static void dumpstate() {
-    DurationReporter durationReporter("DUMPSTATE");
+    DurationReporter duration_reporter("DUMPSTATE");
     unsigned long timeout;
 
     dump_dev_files("TRUSTY VERSION", "/sys/bus/platform/drivers/trusty", "trusty_version");
@@ -887,7 +887,7 @@
     /* Dump Bluetooth HCI logs */
     ds.AddDir("/data/misc/bluetooth/logs", true);
 
-    if (!ds.doEarlyScreenshot_) {
+    if (!ds.do_early_screenshot_) {
         MYLOGI("taking late screenshot\n");
         ds.TakeScreenshot();
     }
@@ -1128,7 +1128,7 @@
 
     printf("========================================================\n");
     printf("== Final progress (pid %d): %d/%d (originally %d)\n", getpid(), ds.progress_,
-           ds.weightTotal_, WEIGHT_TOTAL);
+           ds.weight_total_, WEIGHT_TOTAL);
     printf("========================================================\n");
     printf("== dumpstate: done (id %lu)\n", ds.id_);
     printf("========================================================\n");
@@ -1189,9 +1189,9 @@
 }
 
 bool Dumpstate::FinishZipFile() {
-    std::string entry_name = baseName_ + "-" + name_ + ".txt";
+    std::string entry_name = base_name_ + "-" + name_ + ".txt";
     MYLOGD("Adding main entry (%s) from %s to .zip bugreport\n", entry_name.c_str(),
-           tmp_path.c_str());
+           tmp_path_.c_str());
     // Final timestamp
     char date[80];
     time_t the_real_now_please_stand_up = time(nullptr);
@@ -1199,7 +1199,7 @@
     MYLOGD("dumpstate id %lu finished around %s (%ld s)\n", ds.id_, date,
            the_real_now_please_stand_up - ds.now_);
 
-    if (!ds.AddZipEntry(entry_name, tmp_path)) {
+    if (!ds.AddZipEntry(entry_name, tmp_path_)) {
         MYLOGE("Failed to add text entry to .zip file\n");
         return false;
     }
@@ -1210,12 +1210,12 @@
 
     // Add log file (which contains stderr output) to zip...
     fprintf(stderr, "dumpstate_log.txt entry on zip file logged up to here\n");
-    if (!ds.AddZipEntry("dumpstate_log.txt", ds.log_path.c_str())) {
+    if (!ds.AddZipEntry("dumpstate_log.txt", ds.log_path_.c_str())) {
         MYLOGE("Failed to add dumpstate log to .zip file\n");
         return false;
     }
     // ... and re-opens it for further logging.
-    redirect_to_existing_file(stderr, const_cast<char*>(ds.log_path.c_str()));
+    redirect_to_existing_file(stderr, const_cast<char*>(ds.log_path_.c_str()));
     fprintf(stderr, "\n");
 
     int32_t err = zip_writer->Finish();
@@ -1228,12 +1228,12 @@
     ds.zip_file.reset(nullptr);
 
     if (IsUserBuild()) {
-        MYLOGD("Removing temporary file %s\n", tmp_path.c_str())
-        if (remove(tmp_path.c_str()) != 0) {
-            ALOGW("remove(%s): %s\n", tmp_path.c_str(), strerror(errno));
+        MYLOGD("Removing temporary file %s\n", tmp_path_.c_str())
+        if (remove(tmp_path_.c_str()) != 0) {
+            ALOGW("remove(%s): %s\n", tmp_path_.c_str(), strerror(errno));
         }
     } else {
-        MYLOGD("Keeping temporary file %s on non-user build\n", tmp_path.c_str())
+        MYLOGD("Keeping temporary file %s on non-user build\n", tmp_path_.c_str())
     }
 
     return true;
@@ -1307,13 +1307,13 @@
         }
     }
 
-    ds.extraOptions_ = android::base::GetProperty(PROPERTY_EXTRA_OPTIONS, "");
-    MYLOGI("Dumpstate args: %s (extra options: %s)\n", ds.args_.c_str(), ds.extraOptions_.c_str());
+    ds.extra_options_ = android::base::GetProperty(PROPERTY_EXTRA_OPTIONS, "");
+    MYLOGI("Dumpstate args: %s (extra options: %s)\n", ds.args_.c_str(), ds.extra_options_.c_str());
 
     /* gets the sequential id */
-    int lastId = android::base::GetIntProperty(PROPERTY_LAST_ID, 0);
-    ds.id_ = ++lastId;
-    android::base::SetProperty(PROPERTY_LAST_ID, std::to_string(lastId));
+    int last_id = android::base::GetIntProperty(PROPERTY_LAST_ID, 0);
+    ds.id_ = ++last_id;
+    android::base::SetProperty(PROPERTY_LAST_ID, std::to_string(last_id));
     MYLOGI("dumpstate id: %lu\n", ds.id_);
 
     /* set as high priority, and protect from OOM killer */
@@ -1345,7 +1345,7 @@
             case 'v':                            break;  // compatibility no-op
             case 'q': do_vibrate = 0;            break;
             case 'p': do_fb = 1;                 break;
-            case 'P': ds.updateProgress_ = true; break;
+            case 'P': ds.update_progress_ = true; break;
             case 'R': is_remote_mode = 1;        break;
             case 'B': do_broadcast = 1;          break;
             case 'V': ds.version_ = optarg;      break;
@@ -1359,29 +1359,29 @@
         }
     }
 
-    if (!ds.extraOptions_.empty()) {
+    if (!ds.extra_options_.empty()) {
         // Framework uses a system property to override some command-line args.
         // Currently, it contains the type of the requested bugreport.
-        if (ds.extraOptions_ == "bugreportplus") {
+        if (ds.extra_options_ == "bugreportplus") {
             MYLOGD("Running as bugreportplus: add -P, remove -p\n");
-            ds.updateProgress_ = true;
+            ds.update_progress_ = true;
             do_fb = 0;
-        } else if (ds.extraOptions_ == "bugreportremote") {
+        } else if (ds.extra_options_ == "bugreportremote") {
             MYLOGD("Running as bugreportremote: add -q -R, remove -p\n");
             do_vibrate = 0;
             is_remote_mode = 1;
             do_fb = 0;
-        } else if (ds.extraOptions_ == "bugreportwear") {
+        } else if (ds.extra_options_ == "bugreportwear") {
             MYLOGD("Running as bugreportwear: add -P\n");
-            ds.updateProgress_ = true;
+            ds.update_progress_ = true;
         } else {
-            MYLOGE("Unknown extra option: %s\n", ds.extraOptions_.c_str());
+            MYLOGE("Unknown extra option: %s\n", ds.extra_options_.c_str());
         }
         // Reset the property
         android::base::SetProperty(PROPERTY_EXTRA_OPTIONS, "");
     }
 
-    if ((do_zip_file || do_add_date || ds.updateProgress_ || do_broadcast) && !use_outfile) {
+    if ((do_zip_file || do_add_date || ds.update_progress_ || do_broadcast) && !use_outfile) {
         ExitOnInvalidArgs();
     }
 
@@ -1389,11 +1389,11 @@
         ExitOnInvalidArgs();
     }
 
-    if (ds.updateProgress_ && !do_broadcast) {
+    if (ds.update_progress_ && !do_broadcast) {
         ExitOnInvalidArgs();
     }
 
-    if (is_remote_mode && (ds.updateProgress_ || !do_broadcast || !do_zip_file || !do_add_date)) {
+    if (is_remote_mode && (ds.update_progress_ || !do_broadcast || !do_zip_file || !do_add_date)) {
         ExitOnInvalidArgs();
     }
 
@@ -1403,7 +1403,7 @@
 
     MYLOGI("bugreport format version: %s\n", ds.version_.c_str());
 
-    ds.doEarlyScreenshot_ = ds.updateProgress_;
+    ds.do_early_screenshot_ = ds.update_progress_;
 
     // If we are going to use a socket, do it as early as possible
     // to avoid timeouts from bugreport.
@@ -1413,16 +1413,16 @@
 
     if (use_control_socket) {
         MYLOGD("Opening control socket\n");
-        ds.controlSocketFd_ = open_socket("dumpstate");
-        ds.updateProgress_ = 1;
+        ds.control_socket_fd_ = open_socket("dumpstate");
+        ds.update_progress_ = 1;
     }
 
     /* redirect output if needed */
     bool is_redirecting = !use_socket && use_outfile;
 
     if (is_redirecting) {
-        ds.bugreportDir_ = dirname(use_outfile);
-        ds.baseName_ = basename(use_outfile);
+        ds.bugreport_dir_ = dirname(use_outfile);
+        ds.base_name_ = basename(use_outfile);
         if (do_add_date) {
             char date[80];
             strftime(date, sizeof(date), "%Y-%m-%d-%H-%M-%S", localtime(&ds.now_));
@@ -1431,12 +1431,12 @@
             ds.name_ = "undated";
         }
         std::string buildId = android::base::GetProperty("ro.build.id", "UNKNOWN_BUILD");
-        ds.baseName_ = ds.baseName_ + "-" + buildId;
+        ds.base_name_ += "-" + buildId;
         if (do_fb) {
-            ds.screenshotPath_ = ds.GetPath(".png");
+            ds.screenshot_path_ = ds.GetPath(".png");
         }
-        ds.tmp_path = ds.GetPath(".tmp");
-        ds.log_path = ds.GetPath("-dumpstate_log-" + std::to_string(getpid()) + ".txt");
+        ds.tmp_path_ = ds.GetPath(".tmp");
+        ds.log_path_ = ds.GetPath("-dumpstate_log-" + std::to_string(getpid()) + ".txt");
 
         MYLOGD(
             "Bugreport dir: %s\n"
@@ -1445,16 +1445,16 @@
             "Log path: %s\n"
             "Temporary path: %s\n"
             "Screenshot path: %s\n",
-            ds.bugreportDir_.c_str(), ds.baseName_.c_str(), ds.name_.c_str(), ds.log_path.c_str(),
-            ds.tmp_path.c_str(), ds.screenshotPath_.c_str());
+            ds.bugreport_dir_.c_str(), ds.base_name_.c_str(), ds.name_.c_str(),
+            ds.log_path_.c_str(), ds.tmp_path_.c_str(), ds.screenshot_path_.c_str());
 
         if (do_zip_file) {
-            ds.path = ds.GetPath(".zip");
-            MYLOGD("Creating initial .zip file (%s)\n", ds.path.c_str());
-            create_parent_dirs(ds.path.c_str());
-            ds.zip_file.reset(fopen(ds.path.c_str(), "wb"));
+            ds.path_ = ds.GetPath(".zip");
+            MYLOGD("Creating initial .zip file (%s)\n", ds.path_.c_str());
+            create_parent_dirs(ds.path_.c_str());
+            ds.zip_file.reset(fopen(ds.path_.c_str(), "wb"));
             if (ds.zip_file == nullptr) {
-                MYLOGE("fopen(%s, 'wb'): %s\n", ds.path.c_str(), strerror(errno));
+                MYLOGE("fopen(%s, 'wb'): %s\n", ds.path_.c_str(), strerror(errno));
                 do_zip_file = 0;
             } else {
                 zip_writer.reset(new ZipWriter(ds.zip_file.get()));
@@ -1462,7 +1462,7 @@
             ds.AddTextZipEntry("version.txt", ds.version_);
         }
 
-        if (ds.updateProgress_) {
+        if (ds.update_progress_) {
             if (do_broadcast) {
                 // clang-format off
                 std::vector<std::string> am_args = {
@@ -1476,7 +1476,7 @@
                 send_broadcast("android.intent.action.BUGREPORT_STARTED", am_args);
             }
             if (use_control_socket) {
-                dprintf(ds.controlSocketFd_, "BEGIN:%s\n", ds.path.c_str());
+                dprintf(ds.control_socket_fd_, "BEGIN:%s\n", ds.path_.c_str());
             }
         }
     }
@@ -1497,8 +1497,8 @@
         }
     }
 
-    if (do_fb && ds.doEarlyScreenshot_) {
-        if (ds.screenshotPath_.empty()) {
+    if (do_fb && ds.do_early_screenshot_) {
+        if (ds.screenshot_path_.empty()) {
             // should not have happened
             MYLOGE("INTERNAL ERROR: skipping early screenshot because path was not set\n");
         } else {
@@ -1508,25 +1508,25 @@
     }
 
     if (do_zip_file) {
-        if (chown(ds.path.c_str(), AID_SHELL, AID_SHELL)) {
-            MYLOGE("Unable to change ownership of zip file %s: %s\n", ds.path.c_str(),
+        if (chown(ds.path_.c_str(), AID_SHELL, AID_SHELL)) {
+            MYLOGE("Unable to change ownership of zip file %s: %s\n", ds.path_.c_str(),
                    strerror(errno));
         }
     }
 
     if (is_redirecting) {
-        redirect_to_file(stderr, const_cast<char*>(ds.log_path.c_str()));
-        if (chown(ds.log_path.c_str(), AID_SHELL, AID_SHELL)) {
-            MYLOGE("Unable to change ownership of dumpstate log file %s: %s\n", ds.log_path.c_str(),
-                   strerror(errno));
+        redirect_to_file(stderr, const_cast<char*>(ds.log_path_.c_str()));
+        if (chown(ds.log_path_.c_str(), AID_SHELL, AID_SHELL)) {
+            MYLOGE("Unable to change ownership of dumpstate log file %s: %s\n",
+                   ds.log_path_.c_str(), strerror(errno));
         }
         /* TODO: rather than generating a text file now and zipping it later,
            it would be more efficient to redirect stdout to the zip entry
            directly, but the libziparchive doesn't support that option yet. */
-        redirect_to_file(stdout, const_cast<char*>(ds.tmp_path.c_str()));
-        if (chown(ds.tmp_path.c_str(), AID_SHELL, AID_SHELL)) {
+        redirect_to_file(stdout, const_cast<char*>(ds.tmp_path_.c_str()));
+        if (chown(ds.tmp_path_.c_str(), AID_SHELL, AID_SHELL)) {
             MYLOGE("Unable to change ownership of temporary bugreport file %s: %s\n",
-                   ds.tmp_path.c_str(), strerror(errno));
+                   ds.tmp_path_.c_str(), strerror(errno));
         }
     }
     // NOTE: there should be no stdout output until now, otherwise it would break the header.
@@ -1603,13 +1603,13 @@
         if (change_suffix) {
             MYLOGI("changing suffix from %s to %s\n", ds.name_.c_str(), name.c_str());
             ds.name_ = name;
-            if (!ds.screenshotPath_.empty()) {
-                std::string newScreenshotPath = ds.GetPath(".png");
-                if (rename(ds.screenshotPath_.c_str(), newScreenshotPath.c_str())) {
-                    MYLOGE("rename(%s, %s): %s\n", ds.screenshotPath_.c_str(),
-                           newScreenshotPath.c_str(), strerror(errno));
+            if (!ds.screenshot_path_.empty()) {
+                std::string new_screenshot_path = ds.GetPath(".png");
+                if (rename(ds.screenshot_path_.c_str(), new_screenshot_path.c_str())) {
+                    MYLOGE("rename(%s, %s): %s\n", ds.screenshot_path_.c_str(),
+                           new_screenshot_path.c_str(), strerror(errno));
                 } else {
-                    ds.screenshotPath_ = newScreenshotPath;
+                    ds.screenshot_path_ = new_screenshot_path;
                 }
             }
         }
@@ -1622,36 +1622,36 @@
             } else {
                 do_text_file = false;
                 // Since zip file is already created, it needs to be renamed.
-                std::string newPath = ds.GetPath(".zip");
-                if (ds.path != newPath) {
-                    MYLOGD("Renaming zip file from %s to %s\n", ds.path.c_str(), newPath.c_str());
-                    if (rename(ds.path.c_str(), newPath.c_str())) {
-                        MYLOGE("rename(%s, %s): %s\n", ds.path.c_str(), newPath.c_str(),
+                std::string new_path = ds.GetPath(".zip");
+                if (ds.path_ != new_path) {
+                    MYLOGD("Renaming zip file from %s to %s\n", ds.path_.c_str(), new_path.c_str());
+                    if (rename(ds.path_.c_str(), new_path.c_str())) {
+                        MYLOGE("rename(%s, %s): %s\n", ds.path_.c_str(), new_path.c_str(),
                                strerror(errno));
                     } else {
-                        ds.path = newPath;
+                        ds.path_ = new_path;
                     }
                 }
             }
         }
         if (do_text_file) {
-            ds.path = ds.GetPath(".txt");
-            MYLOGD("Generating .txt bugreport at %s from %s\n", ds.path.c_str(),
-                   ds.tmp_path.c_str());
-            if (rename(ds.tmp_path.c_str(), ds.path.c_str())) {
-                MYLOGE("rename(%s, %s): %s\n", ds.tmp_path.c_str(), ds.path.c_str(),
+            ds.path_ = ds.GetPath(".txt");
+            MYLOGD("Generating .txt bugreport at %s from %s\n", ds.path_.c_str(),
+                   ds.tmp_path_.c_str());
+            if (rename(ds.tmp_path_.c_str(), ds.path_.c_str())) {
+                MYLOGE("rename(%s, %s): %s\n", ds.tmp_path_.c_str(), ds.path_.c_str(),
                        strerror(errno));
-                ds.path.clear();
+                ds.path_.clear();
             }
         }
         if (use_control_socket) {
             if (do_text_file) {
-                dprintf(ds.controlSocketFd_,
+                dprintf(ds.control_socket_fd_,
                         "FAIL:could not create zip file, check %s "
                         "for more details\n",
-                        ds.log_path.c_str());
+                        ds.log_path_.c_str());
             } else {
-                dprintf(ds.controlSocketFd_, "OK:%s\n", ds.path.c_str());
+                dprintf(ds.control_socket_fd_, "OK:%s\n", ds.path_.c_str());
             }
         }
     }
@@ -1666,27 +1666,27 @@
 
     /* tell activity manager we're done */
     if (do_broadcast) {
-        if (!ds.path.empty()) {
-            MYLOGI("Final bugreport path: %s\n", ds.path.c_str());
+        if (!ds.path_.empty()) {
+            MYLOGI("Final bugreport path: %s\n", ds.path_.c_str());
             // clang-format off
             std::vector<std::string> am_args = {
                  "--receiver-permission", "android.permission.DUMP", "--receiver-foreground",
                  "--ei", "android.intent.extra.ID", std::to_string(ds.id_),
                  "--ei", "android.intent.extra.PID", std::to_string(getpid()),
-                 "--ei", "android.intent.extra.MAX", std::to_string(ds.weightTotal_),
-                 "--es", "android.intent.extra.BUGREPORT", ds.path,
-                 "--es", "android.intent.extra.DUMPSTATE_LOG", ds.log_path
+                 "--ei", "android.intent.extra.MAX", std::to_string(ds.weight_total_),
+                 "--es", "android.intent.extra.BUGREPORT", ds.path_,
+                 "--es", "android.intent.extra.DUMPSTATE_LOG", ds.log_path_
             };
             // clang-format on
             if (do_fb) {
                 am_args.push_back("--es");
                 am_args.push_back("android.intent.extra.SCREENSHOT");
-                am_args.push_back(ds.screenshotPath_);
+                am_args.push_back(ds.screenshot_path_);
             }
             if (is_remote_mode) {
                 am_args.push_back("--es");
                 am_args.push_back("android.intent.extra.REMOTE_BUGREPORT_HASH");
-                am_args.push_back(SHA256_file_hash(ds.path));
+                am_args.push_back(SHA256_file_hash(ds.path_));
                 send_broadcast("android.intent.action.REMOTE_BUGREPORT_FINISHED", am_args);
             } else {
                 send_broadcast("android.intent.action.BUGREPORT_FINISHED", am_args);
@@ -1696,16 +1696,16 @@
         }
     }
 
-    MYLOGD("Final progress: %d/%d (originally %d)\n", ds.progress_, ds.weightTotal_, WEIGHT_TOTAL);
+    MYLOGD("Final progress: %d/%d (originally %d)\n", ds.progress_, ds.weight_total_, WEIGHT_TOTAL);
     MYLOGI("done (id %lu)\n", ds.id_);
 
     if (is_redirecting) {
         fclose(stderr);
     }
 
-    if (use_control_socket && ds.controlSocketFd_ != -1) {
+    if (use_control_socket && ds.control_socket_fd_ != -1) {
         MYLOGD("Closing control socket\n");
-        close(ds.controlSocketFd_);
+        close(ds.control_socket_fd_);
     }
 
     return 0;
diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h
index e7dd6e8..29d3c0b 100644
--- a/cmds/dumpstate/dumpstate.h
+++ b/cmds/dumpstate/dumpstate.h
@@ -119,9 +119,9 @@
 
         long timeout_;
         bool always_;
-        RootMode rootMode_;
-        StdoutMode stdoutMode_;
-        std::string loggingMessage_;
+        RootMode root_mode_;
+        StdoutMode stdout_mode_;
+        std::string logging_message_;
 
         friend class CommandOptions;
         friend class CommandOptionsBuilder;
@@ -129,7 +129,7 @@
 
     CommandOptions(const CommandOptionsValues& values);
 
-    const CommandOptionsValues values_;
+    const CommandOptionsValues values;
 
   public:
     class CommandOptionsBuilder {
@@ -150,7 +150,7 @@
 
       private:
         CommandOptionsBuilder(long timeout);
-        CommandOptionsValues values_;
+        CommandOptionsValues values;
         friend class CommandOptions;
     };
 
@@ -249,12 +249,12 @@
      * description).
      * |dumpsys_args| `dumpsys` arguments (except `-t`).
      * |options| optional argument defining the command's behavior.
-     * |dumpsysTimeout| when > 0, defines the value passed to `dumpsys -t` (otherwise it uses the
+     * |dumpsys_timeout| when > 0, defines the value passed to `dumpsys -t` (otherwise it uses the
      * timeout from `options`)
      */
-    void RunDumpsys(const std::string& title, const std::vector<std::string>& dumpsysArgs,
+    void RunDumpsys(const std::string& title, const std::vector<std::string>& dumpsys_args,
                     const CommandOptions& options = CommandOptions::DEFAULT_DUMPSYS,
-                    long dumpsysTimeout = 0);
+                    long dumpsys_timeout = 0);
 
     /*
      * Prints the contents of a file.
@@ -317,19 +317,19 @@
     unsigned long id_;
 
     // Whether progress updates should be published.
-    bool updateProgress_ = false;
+    bool update_progress_ = false;
 
     // Whether it should take an screenshot earlier in the process.
-    bool doEarlyScreenshot_ = false;
+    bool do_early_screenshot_ = false;
 
     // Currrent progress.
     int progress_ = 0;
 
     // Total estimated progress.
-    int weightTotal_ = WEIGHT_TOTAL;
+    int weight_total_ = WEIGHT_TOTAL;
 
     // When set, defines a socket file-descriptor use to report progress to bugreportz.
-    int controlSocketFd_ = -1;
+    int control_socket_fd_ = -1;
 
     // Bugreport format version;
     std::string version_ = VERSION_DEFAULT;
@@ -338,39 +338,39 @@
     std::string args_;
 
     // Extra options passed as system property.
-    std::string extraOptions_;
+    std::string extra_options_;
 
     // Full path of the directory where the bugreport files will be written.
-    std::string bugreportDir_;
+    std::string bugreport_dir_;
 
     // Full path of the temporary file containing the screenshot (when requested).
-    std::string screenshotPath_;
+    std::string screenshot_path_;
 
     time_t now_;
 
     // Base name (without suffix or extensions) of the bugreport files, typically
     // `bugreport-BUILD_ID`.
-    std::string baseName_;
+    std::string base_name_;
 
     // Name is the suffix part of the bugreport files - it's typically the date (when invoked with
     // `-d`), but it could be changed by the user..
     std::string name_;
 
     // Full path of the temporary file containing the bugreport.
-    std::string tmp_path;
+    std::string tmp_path_;
 
     // Full path of the file containing the dumpstate logs.
-    std::string log_path;
+    std::string log_path_;
 
     // Pointer to the actual path, be it zip or text.
-    std::string path;
+    std::string path_;
 
     // Pointer to the zipped file.
     std::unique_ptr<FILE, int (*)(FILE*)> zip_file{nullptr, fclose};
 
   private:
     // Used by GetInstance() only.
-    Dumpstate(bool dryRun = false, const std::string& buildType = "user");
+    Dumpstate(bool dry_run = false, const std::string& build_type = "user");
 
     // Internal version of RunCommand that just runs it, without updating progress.
     int JustRunCommand(const char* command, const char* path, std::vector<const char*>& args,
@@ -380,10 +380,10 @@
     int JustDumpFile(const std::string& title, const std::string& path) const;
 
     // Whether this is a dry run.
-    bool dryRun_;
+    bool dry_run_;
 
     // Build type (such as 'user' or 'eng').
-    std::string buildType_;
+    std::string build_type_;
 };
 
 // for_each_pid_func = void (*)(int, const char*);
diff --git a/cmds/dumpstate/tests/dumpstate_test.cpp b/cmds/dumpstate/tests/dumpstate_test.cpp
index 8d70704..4073c3c 100644
--- a/cmds/dumpstate/tests/dumpstate_test.cpp
+++ b/cmds/dumpstate/tests/dumpstate_test.cpp
@@ -52,15 +52,15 @@
     void SetUp() {
         SetDryRun(false);
         SetBuildType(android::base::GetProperty("ro.build.type", "(unknown)"));
-        ds.updateProgress_ = false;
+        ds.update_progress_ = false;
     }
 
     // Runs a command and capture `stdout` and `stderr`.
-    int RunCommand(const std::string& title, const std::vector<std::string>& fullCommand,
+    int RunCommand(const std::string& title, const std::vector<std::string>& full_command,
                    const CommandOptions& options = CommandOptions::DEFAULT) {
         CaptureStdout();
         CaptureStderr();
-        int status = ds.RunCommand(title, fullCommand, options);
+        int status = ds.RunCommand(title, full_command, options);
         out = GetCapturedStdout();
         err = GetCapturedStderr();
         return status;
@@ -76,14 +76,14 @@
         return status;
     }
 
-    void SetDryRun(bool dryRun) {
-        ALOGD("Setting dryRun_ to %s\n", dryRun ? "true" : "false");
-        ds.dryRun_ = dryRun;
+    void SetDryRun(bool dry_run) {
+        ALOGD("Setting dry_run_ to %s\n", dry_run ? "true" : "false");
+        ds.dry_run_ = dry_run;
     }
 
-    void SetBuildType(const std::string& buildType) {
-        ALOGD("Setting buildType_ to '%s'\n", buildType.c_str());
-        ds.buildType_ = buildType;
+    void SetBuildType(const std::string& build_type) {
+        ALOGD("Setting build_type_ to '%s'\n", build_type.c_str());
+        ds.build_type_ = build_type;
     }
 
     bool IsUserBuild() {
@@ -97,41 +97,41 @@
     }
 
     // TODO: remove when progress is set by Binder callbacks.
-    void AssertSystemProperty(const std::string& key, const std::string& expectedValue) {
+    void AssertSystemProperty(const std::string& key, const std::string& expected_value) {
         std::string actualValue = android::base::GetProperty(key, "not set");
-        EXPECT_THAT(expectedValue, StrEq(actualValue)) << "invalid value for property " << key;
+        EXPECT_THAT(expected_value, StrEq(actualValue)) << "invalid value for property " << key;
     }
 
-    std::string GetProgressMessage(int progress, int weightTotal, int oldWeightTotal = 0) {
+    std::string GetProgressMessage(int progress, int weigh_total, int old_weigh_total = 0) {
         EXPECT_EQ(progress, ds.progress_) << "invalid progress";
-        EXPECT_EQ(weightTotal, ds.weightTotal_) << "invalid weightTotal";
+        EXPECT_EQ(weigh_total, ds.weight_total_) << "invalid weigh_total";
 
         AssertSystemProperty(android::base::StringPrintf("dumpstate.%d.progress", getpid()),
                              std::to_string(progress));
 
-        bool maxIncreased = oldWeightTotal > 0;
+        bool max_increased = old_weigh_total > 0;
 
-        std::string adjustmentMessage = "";
-        if (maxIncreased) {
+        std::string adjustment_message = "";
+        if (max_increased) {
             AssertSystemProperty(android::base::StringPrintf("dumpstate.%d.max", getpid()),
-                                 std::to_string(weightTotal));
-            adjustmentMessage = android::base::StringPrintf(
-                "Adjusting total weight from %d to %d\n", oldWeightTotal, weightTotal);
+                                 std::to_string(weigh_total));
+            adjustment_message = android::base::StringPrintf(
+                "Adjusting total weight from %d to %d\n", old_weigh_total, weigh_total);
         }
 
         return android::base::StringPrintf("%sSetting progress (dumpstate.%d.progress): %d/%d\n",
-                                           adjustmentMessage.c_str(), getpid(), progress,
-                                           weightTotal);
+                                           adjustment_message.c_str(), getpid(), progress,
+                                           weigh_total);
     }
 
     // `stdout` and `stderr` from the last command ran.
     std::string out, err;
 
-    std::string testPath = dirname(android::base::GetExecutablePath().c_str());
-    std::string fixturesPath = testPath + "/../dumpstate_test_fixture/";
-    std::string testDataPath = fixturesPath + "/testdata/";
-    std::string simpleCommand = fixturesPath + "dumpstate_test_fixture";
-    std::string echoCommand = "/system/bin/echo";
+    std::string test_path = dirname(android::base::GetExecutablePath().c_str());
+    std::string fixtures_path = test_path + "/../dumpstate_test_fixture/";
+    std::string test_data_path = fixtures_path + "/testdata/";
+    std::string simple_command = fixtures_path + "dumpstate_test_fixture";
+    std::string echo_command = "/system/bin/echo";
 
     Dumpstate& ds = Dumpstate::GetInstance();
 };
@@ -141,52 +141,52 @@
 }
 
 TEST_F(DumpstateTest, RunCommandNoTitle) {
-    EXPECT_EQ(0, RunCommand("", {simpleCommand}));
+    EXPECT_EQ(0, RunCommand("", {simple_command}));
     EXPECT_THAT(out, StrEq("stdout\n"));
     EXPECT_THAT(err, StrEq("stderr\n"));
 }
 
 TEST_F(DumpstateTest, RunCommandWithTitle) {
-    EXPECT_EQ(0, RunCommand("I AM GROOT", {simpleCommand}));
+    EXPECT_EQ(0, RunCommand("I AM GROOT", {simple_command}));
     EXPECT_THAT(err, StrEq("stderr\n"));
     // We don't know the exact duration, so we check the prefix and suffix
     EXPECT_THAT(out,
-                StartsWith("------ I AM GROOT (" + simpleCommand + ") ------\nstdout\n------"));
+                StartsWith("------ I AM GROOT (" + simple_command + ") ------\nstdout\n------"));
     EXPECT_THAT(out, EndsWith("s was the duration of 'I AM GROOT' ------\n"));
 }
 
 TEST_F(DumpstateTest, RunCommandWithLoggingMessage) {
     EXPECT_EQ(
-        0, RunCommand("", {simpleCommand},
+        0, RunCommand("", {simple_command},
                       CommandOptions::WithTimeout(10).Log("COMMAND, Y U NO LOG FIRST?").Build()));
     EXPECT_THAT(out, StrEq("stdout\n"));
     EXPECT_THAT(err, StrEq("COMMAND, Y U NO LOG FIRST?stderr\n"));
 }
 
 TEST_F(DumpstateTest, RunCommandRedirectStderr) {
-    EXPECT_EQ(0, RunCommand("", {simpleCommand},
+    EXPECT_EQ(0, RunCommand("", {simple_command},
                             CommandOptions::WithTimeout(10).RedirectStderr().Build()));
     EXPECT_THAT(out, IsEmpty());
     EXPECT_THAT(err, StrEq("stdout\nstderr\n"));
 }
 
 TEST_F(DumpstateTest, RunCommandWithOneArg) {
-    EXPECT_EQ(0, RunCommand("", {echoCommand, "one"}));
+    EXPECT_EQ(0, RunCommand("", {echo_command, "one"}));
     EXPECT_THAT(err, IsEmpty());
     EXPECT_THAT(out, StrEq("one\n"));
 }
 
 TEST_F(DumpstateTest, RunCommandWithMultipleArgs) {
-    EXPECT_EQ(0, RunCommand("", {echoCommand, "one", "is", "the", "loniest", "number"}));
+    EXPECT_EQ(0, RunCommand("", {echo_command, "one", "is", "the", "loniest", "number"}));
     EXPECT_THAT(err, IsEmpty());
     EXPECT_THAT(out, StrEq("one is the loniest number\n"));
 }
 
 TEST_F(DumpstateTest, RunCommandDryRun) {
     SetDryRun(true);
-    EXPECT_EQ(0, RunCommand("I AM GROOT", {simpleCommand}));
+    EXPECT_EQ(0, RunCommand("I AM GROOT", {simple_command}));
     // We don't know the exact duration, so we check the prefix and suffix
-    EXPECT_THAT(out, StartsWith("------ I AM GROOT (" + simpleCommand +
+    EXPECT_THAT(out, StartsWith("------ I AM GROOT (" + simple_command +
                                 ") ------\n\t(skipped on dry run)\n------"));
     EXPECT_THAT(out, EndsWith("s was the duration of 'I AM GROOT' ------\n"));
     EXPECT_THAT(err, IsEmpty());
@@ -194,14 +194,14 @@
 
 TEST_F(DumpstateTest, RunCommandDryRunNoTitle) {
     SetDryRun(true);
-    EXPECT_EQ(0, RunCommand("", {simpleCommand}));
+    EXPECT_EQ(0, RunCommand("", {simple_command}));
     EXPECT_THAT(out, IsEmpty());
     EXPECT_THAT(err, IsEmpty());
 }
 
 TEST_F(DumpstateTest, RunCommandDryRunAlways) {
     SetDryRun(true);
-    EXPECT_EQ(0, RunCommand("", {simpleCommand}, CommandOptions::WithTimeout(10).Always().Build()));
+    EXPECT_EQ(0, RunCommand("", {simple_command}, CommandOptions::WithTimeout(10).Always().Build()));
     EXPECT_THAT(out, StrEq("stdout\n"));
     EXPECT_THAT(err, StrEq("stderr\n"));
 }
@@ -213,28 +213,28 @@
 }
 
 TEST_F(DumpstateTest, RunCommandFails) {
-    EXPECT_EQ(42, RunCommand("", {simpleCommand, "--exit", "42"}));
-    EXPECT_THAT(
-        out, StrEq("stdout\n*** command '" + simpleCommand + " --exit 42' failed: exit code 42\n"));
-    EXPECT_THAT(
-        err, StrEq("stderr\n*** command '" + simpleCommand + " --exit 42' failed: exit code 42\n"));
+    EXPECT_EQ(42, RunCommand("", {simple_command, "--exit", "42"}));
+    EXPECT_THAT(out, StrEq("stdout\n*** command '" + simple_command +
+                           " --exit 42' failed: exit code 42\n"));
+    EXPECT_THAT(err, StrEq("stderr\n*** command '" + simple_command +
+                           " --exit 42' failed: exit code 42\n"));
 }
 
 TEST_F(DumpstateTest, RunCommandCrashes) {
-    EXPECT_NE(0, RunCommand("", {simpleCommand, "--crash"}));
+    EXPECT_NE(0, RunCommand("", {simple_command, "--crash"}));
     // We don't know the exit code, so check just the prefix.
     EXPECT_THAT(
-        out, StartsWith("stdout\n*** command '" + simpleCommand + " --crash' failed: exit code"));
+        out, StartsWith("stdout\n*** command '" + simple_command + " --crash' failed: exit code"));
     EXPECT_THAT(
-        err, StartsWith("stderr\n*** command '" + simpleCommand + " --crash' failed: exit code"));
+        err, StartsWith("stderr\n*** command '" + simple_command + " --crash' failed: exit code"));
 }
 
 TEST_F(DumpstateTest, RunCommandTimesout) {
-    EXPECT_EQ(-1, RunCommand("", {simpleCommand, "--sleep", "2"},
+    EXPECT_EQ(-1, RunCommand("", {simple_command, "--sleep", "2"},
                              CommandOptions::WithTimeout(1).Build()));
-    EXPECT_THAT(out, StartsWith("stdout line1\n*** command '" + simpleCommand +
+    EXPECT_THAT(out, StartsWith("stdout line1\n*** command '" + simple_command +
                                 " --sleep 2' timed out after 1"));
-    EXPECT_THAT(err, StartsWith("sleeping for 2s\n*** command '" + simpleCommand +
+    EXPECT_THAT(err, StartsWith("sleeping for 2s\n*** command '" + simple_command +
                                 " --sleep 2' timed out after 1"));
 }
 
@@ -243,7 +243,7 @@
     CaptureStderr();
 
     std::thread t([=]() {
-        EXPECT_EQ(SIGTERM, ds.RunCommand("", {simpleCommand, "--pid", "--sleep", "20"},
+        EXPECT_EQ(SIGTERM, ds.RunCommand("", {simple_command, "--pid", "--sleep", "20"},
                                          CommandOptions::WithTimeout(100).Always().Build()));
     });
 
@@ -270,53 +270,53 @@
     out = GetCapturedStdout();
     err = GetCapturedStderr();
 
-    EXPECT_THAT(out, StrEq("*** command '" + simpleCommand +
+    EXPECT_THAT(out, StrEq("*** command '" + simple_command +
                            " --pid --sleep 20' failed: killed by signal 15\n"));
-    EXPECT_THAT(err, StrEq("*** command '" + simpleCommand +
+    EXPECT_THAT(err, StrEq("*** command '" + simple_command +
                            " --pid --sleep 20' failed: killed by signal 15\n"));
 }
 
 TEST_F(DumpstateTest, RunCommandProgress) {
-    ds.updateProgress_ = true;
+    ds.update_progress_ = true;
     ds.progress_ = 0;
-    ds.weightTotal_ = 30;
+    ds.weight_total_ = 30;
 
-    EXPECT_EQ(0, RunCommand("", {simpleCommand}, CommandOptions::WithTimeout(20).Build()));
-    std::string progressMessage = GetProgressMessage(20, 30);
+    EXPECT_EQ(0, RunCommand("", {simple_command}, CommandOptions::WithTimeout(20).Build()));
+    std::string progress_message = GetProgressMessage(20, 30);
     EXPECT_THAT(out, StrEq("stdout\n"));
-    EXPECT_THAT(err, StrEq("stderr\n" + progressMessage));
+    EXPECT_THAT(err, StrEq("stderr\n" + progress_message));
 
-    EXPECT_EQ(0, RunCommand("", {simpleCommand}, CommandOptions::WithTimeout(10).Build()));
-    progressMessage = GetProgressMessage(30, 30);
+    EXPECT_EQ(0, RunCommand("", {simple_command}, CommandOptions::WithTimeout(10).Build()));
+    progress_message = GetProgressMessage(30, 30);
     EXPECT_THAT(out, StrEq("stdout\n"));
-    EXPECT_THAT(err, StrEq("stderr\n" + progressMessage));
+    EXPECT_THAT(err, StrEq("stderr\n" + progress_message));
 
     // Run a command that will increase maximum timeout.
-    EXPECT_EQ(0, RunCommand("", {simpleCommand}, CommandOptions::WithTimeout(1).Build()));
-    progressMessage = GetProgressMessage(31, 36, 30);  // 20% increase
+    EXPECT_EQ(0, RunCommand("", {simple_command}, CommandOptions::WithTimeout(1).Build()));
+    progress_message = GetProgressMessage(31, 36, 30);  // 20% increase
     EXPECT_THAT(out, StrEq("stdout\n"));
-    EXPECT_THAT(err, StrEq("stderr\n" + progressMessage));
+    EXPECT_THAT(err, StrEq("stderr\n" + progress_message));
 
-    // Make sure command ran while in dryRun is counted.
+    // Make sure command ran while in dry_run is counted.
     SetDryRun(true);
-    EXPECT_EQ(0, RunCommand("", {simpleCommand}, CommandOptions::WithTimeout(4).Build()));
-    progressMessage = GetProgressMessage(35, 36);
+    EXPECT_EQ(0, RunCommand("", {simple_command}, CommandOptions::WithTimeout(4).Build()));
+    progress_message = GetProgressMessage(35, 36);
     EXPECT_THAT(out, IsEmpty());
-    EXPECT_THAT(err, StrEq(progressMessage));
+    EXPECT_THAT(err, StrEq(progress_message));
 }
 
 TEST_F(DumpstateTest, RunCommandDropRoot) {
     // First check root case - only available when running with 'adb root'.
     uid_t uid = getuid();
     if (uid == 0) {
-        EXPECT_EQ(0, RunCommand("", {simpleCommand, "--uid"}));
+        EXPECT_EQ(0, RunCommand("", {simple_command, "--uid"}));
         EXPECT_THAT(out, StrEq("0\nstdout\n"));
         EXPECT_THAT(err, StrEq("stderr\n"));
         return;
     }
     // Then drop root.
 
-    EXPECT_EQ(0, RunCommand("", {simpleCommand, "--uid"},
+    EXPECT_EQ(0, RunCommand("", {simple_command, "--uid"},
                             CommandOptions::WithTimeout(1).DropRoot().Build()));
     EXPECT_THAT(out, StrEq("2000\nstdout\n"));
     EXPECT_THAT(err, StrEq("drop_root_user(): already running as Shell\nstderr\n"));
@@ -330,11 +330,11 @@
 
     DropRoot();
 
-    EXPECT_EQ(0, RunCommand("", {simpleCommand}, CommandOptions::WithTimeout(1).AsRoot().Build()));
+    EXPECT_EQ(0, RunCommand("", {simple_command}, CommandOptions::WithTimeout(1).AsRoot().Build()));
 
     // We don't know the exact path of su, so we just check for the 'root ...' commands
     EXPECT_THAT(out, StartsWith("Skipping"));
-    EXPECT_THAT(out, EndsWith("root " + simpleCommand + "' on user build.\n"));
+    EXPECT_THAT(out, EndsWith("root " + simple_command + "' on user build.\n"));
     EXPECT_THAT(err, IsEmpty());
 }
 
@@ -346,7 +346,7 @@
 
     DropRoot();
 
-    EXPECT_EQ(0, RunCommand("", {simpleCommand, "--uid"},
+    EXPECT_EQ(0, RunCommand("", {simple_command, "--uid"},
                             CommandOptions::WithTimeout(1).AsRoot().Build()));
 
     EXPECT_THAT(out, StrEq("0\nstdout\n"));
@@ -370,55 +370,55 @@
 }
 
 TEST_F(DumpstateTest, DumpFileSingleLine) {
-    EXPECT_EQ(0, DumpFile("", testDataPath + "single-line.txt"));
+    EXPECT_EQ(0, DumpFile("", test_data_path + "single-line.txt"));
     EXPECT_THAT(err, IsEmpty());
     EXPECT_THAT(out, StrEq("I AM LINE1\n"));  // dumpstate adds missing newline
 }
 
 TEST_F(DumpstateTest, DumpFileSingleLineWithNewLine) {
-    EXPECT_EQ(0, DumpFile("", testDataPath + "single-line-with-newline.txt"));
+    EXPECT_EQ(0, DumpFile("", test_data_path + "single-line-with-newline.txt"));
     EXPECT_THAT(err, IsEmpty());
     EXPECT_THAT(out, StrEq("I AM LINE1\n"));
 }
 
 TEST_F(DumpstateTest, DumpFileMultipleLines) {
-    EXPECT_EQ(0, DumpFile("", testDataPath + "multiple-lines.txt"));
+    EXPECT_EQ(0, DumpFile("", test_data_path + "multiple-lines.txt"));
     EXPECT_THAT(err, IsEmpty());
     EXPECT_THAT(out, StrEq("I AM LINE1\nI AM LINE2\nI AM LINE3\n"));
 }
 
 TEST_F(DumpstateTest, DumpFileMultipleLinesWithNewLine) {
-    EXPECT_EQ(0, DumpFile("", testDataPath + "multiple-lines-with-newline.txt"));
+    EXPECT_EQ(0, DumpFile("", test_data_path + "multiple-lines-with-newline.txt"));
     EXPECT_THAT(err, IsEmpty());
     EXPECT_THAT(out, StrEq("I AM LINE1\nI AM LINE2\nI AM LINE3\n"));
 }
 
 TEST_F(DumpstateTest, DumpFileOnDryRunNoTitle) {
     SetDryRun(true);
-    EXPECT_EQ(0, DumpFile("", testDataPath + "single-line.txt"));
+    EXPECT_EQ(0, DumpFile("", test_data_path + "single-line.txt"));
     EXPECT_THAT(err, IsEmpty());
     EXPECT_THAT(out, IsEmpty());
 }
 
 TEST_F(DumpstateTest, DumpFileOnDryRun) {
     SetDryRun(true);
-    EXPECT_EQ(0, DumpFile("Might as well dump. Dump!", testDataPath + "single-line.txt"));
+    EXPECT_EQ(0, DumpFile("Might as well dump. Dump!", test_data_path + "single-line.txt"));
     EXPECT_THAT(err, IsEmpty());
-    EXPECT_THAT(out, StartsWith("------ Might as well dump. Dump! (" + testDataPath +
+    EXPECT_THAT(out, StartsWith("------ Might as well dump. Dump! (" + test_data_path +
                                 "single-line.txt) ------\n\t(skipped on dry run)\n------"));
     EXPECT_THAT(out, EndsWith("s was the duration of 'Might as well dump. Dump!' ------\n"));
     EXPECT_THAT(err, IsEmpty());
 }
 
 TEST_F(DumpstateTest, DumpFileUpdateProgress) {
-    ds.updateProgress_ = true;
+    ds.update_progress_ = true;
     ds.progress_ = 0;
-    ds.weightTotal_ = 30;
+    ds.weight_total_ = 30;
 
-    EXPECT_EQ(0, DumpFile("", testDataPath + "single-line.txt"));
+    EXPECT_EQ(0, DumpFile("", test_data_path + "single-line.txt"));
 
-    std::string progressMessage = GetProgressMessage(5, 30);  // TODO: unhardcode WEIGHT_FILE (5)?
+    std::string progress_message = GetProgressMessage(5, 30);  // TODO: unhardcode WEIGHT_FILE (5)?
 
-    EXPECT_THAT(err, StrEq(progressMessage));
+    EXPECT_THAT(err, StrEq(progress_message));
     EXPECT_THAT(out, StrEq("I AM LINE1\n"));  // dumpstate adds missing newline
 }
diff --git a/cmds/dumpstate/utils.cpp b/cmds/dumpstate/utils.cpp
index fc9c037..527cf91 100644
--- a/cmds/dumpstate/utils.cpp
+++ b/cmds/dumpstate/utils.cpp
@@ -59,9 +59,9 @@
 
 // TODO: temporary variables and functions used during C++ refactoring
 static Dumpstate& ds = Dumpstate::GetInstance();
-static int RunCommand(const std::string& title, const std::vector<std::string>& fullCommand,
+static int RunCommand(const std::string& title, const std::vector<std::string>& full_command,
                       const CommandOptions& options = CommandOptions::DEFAULT) {
-    return ds.RunCommand(title, fullCommand, options);
+    return ds.RunCommand(title, full_command, options);
 }
 static bool IsDryRun() {
     return Dumpstate::GetInstance().IsDryRun();
@@ -95,82 +95,82 @@
 CommandOptions CommandOptions::AS_ROOT_10 = CommandOptions::WithTimeout(10).AsRoot().Build();
 CommandOptions CommandOptions::AS_ROOT_20 = CommandOptions::WithTimeout(20).AsRoot().Build();
 
-CommandOptions::CommandOptionsBuilder::CommandOptionsBuilder(long timeout) : values_(timeout) {
+CommandOptions::CommandOptionsBuilder::CommandOptionsBuilder(long timeout) : values(timeout) {
 }
 
 CommandOptions::CommandOptionsBuilder& CommandOptions::CommandOptionsBuilder::Always() {
-    values_.always_ = true;
+    values.always_ = true;
     return *this;
 }
 
 CommandOptions::CommandOptionsBuilder& CommandOptions::CommandOptionsBuilder::AsRoot() {
-    values_.rootMode_ = SU_ROOT;
+    values.root_mode_ = SU_ROOT;
     return *this;
 }
 
 CommandOptions::CommandOptionsBuilder& CommandOptions::CommandOptionsBuilder::DropRoot() {
-    values_.rootMode_ = DROP_ROOT;
+    values.root_mode_ = DROP_ROOT;
     return *this;
 }
 
 CommandOptions::CommandOptionsBuilder& CommandOptions::CommandOptionsBuilder::RedirectStderr() {
-    values_.stdoutMode_ = REDIRECT_TO_STDERR;
+    values.stdout_mode_ = REDIRECT_TO_STDERR;
     return *this;
 }
 
 CommandOptions::CommandOptionsBuilder& CommandOptions::CommandOptionsBuilder::Log(
     const std::string& message) {
-    values_.loggingMessage_ = message;
+    values.logging_message_ = message;
     return *this;
 }
 
 CommandOptions CommandOptions::CommandOptionsBuilder::Build() {
-    return CommandOptions(values_);
+    return CommandOptions(values);
 }
 
 CommandOptions::CommandOptionsValues::CommandOptionsValues(long timeout)
     : timeout_(timeout),
       always_(false),
-      rootMode_(DONT_DROP_ROOT),
-      stdoutMode_(NORMAL_STDOUT),
-      loggingMessage_("") {
+      root_mode_(DONT_DROP_ROOT),
+      stdout_mode_(NORMAL_STDOUT),
+      logging_message_("") {
 }
 
-CommandOptions::CommandOptions(const CommandOptionsValues& values) : values_(values) {
+CommandOptions::CommandOptions(const CommandOptionsValues& values) : values(values) {
 }
 
 long CommandOptions::Timeout() const {
-    return values_.timeout_;
+    return values.timeout_;
 }
 
 bool CommandOptions::Always() const {
-    return values_.always_;
+    return values.always_;
 }
 
 RootMode CommandOptions::RootMode() const {
-    return values_.rootMode_;
+    return values.root_mode_;
 }
 
 StdoutMode CommandOptions::StdoutMode() const {
-    return values_.stdoutMode_;
+    return values.stdout_mode_;
 }
 
 std::string CommandOptions::LoggingMessage() const {
-    return values_.loggingMessage_;
+    return values.logging_message_;
 }
 
 CommandOptions::CommandOptionsBuilder CommandOptions::WithTimeout(long timeout) {
     return CommandOptions::CommandOptionsBuilder(timeout);
 }
 
-Dumpstate::Dumpstate(bool dryRun, const std::string& buildType)
-    : now_(time(nullptr)), dryRun_(dryRun), buildType_(buildType) {
+Dumpstate::Dumpstate(bool dry_run, const std::string& build_type)
+    : now_(time(nullptr)), dry_run_(dry_run), build_type_(build_type) {
 }
 
 Dumpstate& Dumpstate::GetInstance() {
-    static Dumpstate sSingleton(android::base::GetBoolProperty("dumpstate.dry_run", false),
+    static Dumpstate singleton_(android::base::GetBoolProperty("dumpstate.dry_run", false),
                                 android::base::GetProperty("ro.build.type", "(unknown)"));
-    return sSingleton;
+    return singleton_;
 }
 
 DurationReporter::DurationReporter(const std::string& title) : DurationReporter(title, stdout) {
@@ -202,15 +202,15 @@
 }
 
 bool Dumpstate::IsDryRun() const {
-    return dryRun_;
+    return dry_run_;
 }
 
 bool Dumpstate::IsUserBuild() const {
-    return "user" == buildType_;
+    return "user" == build_type_;
 }
 
 std::string Dumpstate::GetPath(const std::string& suffix) const {
-    return android::base::StringPrintf("%s/%s-%s%s", bugreportDir_.c_str(), baseName_.c_str(),
+    return android::base::StringPrintf("%s/%s-%s%s", bugreport_dir_.c_str(), base_name_.c_str(),
                                        name_.c_str(), suffix.c_str());
 }
 
@@ -597,7 +597,7 @@
 }
 
 int Dumpstate::DumpFile(const std::string& title, const std::string& path) {
-    DurationReporter durationReporter(title);
+    DurationReporter duration_reporter(title);
     if (IsDryRun()) {
         if (!title.empty()) {
             printf("------ %s (%s) ------\n", title.c_str(), path.c_str());
@@ -778,41 +778,41 @@
     return true;
 }
 
-int Dumpstate::RunCommand(const std::string& title, const std::vector<std::string>& fullCommand,
+int Dumpstate::RunCommand(const std::string& title, const std::vector<std::string>& full_command,
                           const CommandOptions& options) {
-    if (fullCommand.empty()) {
+    if (full_command.empty()) {
         MYLOGE("No arguments on command '%s'\n", title.c_str());
         return -1;
     }
 
-    int size = fullCommand.size() + 1;  // null terminated
-    int startingIndex = 0;
+    int size = full_command.size() + 1;  // null terminated
+    int starting_index = 0;
     if (options.RootMode() == SU_ROOT) {
-        startingIndex = 2;  // "su" "root"
-        size += startingIndex;
+        starting_index = 2;  // "su" "root"
+        size += starting_index;
     }
 
     std::vector<const char*> args;
     args.resize(size);
 
-    std::string commandString;
+    std::string command_string;
     if (options.RootMode() == SU_ROOT) {
         args[0] = SU_PATH;
-        commandString += SU_PATH;
+        command_string += SU_PATH;
         args[1] = "root";
-        commandString += " root ";
+        command_string += " root ";
     }
-    int i = startingIndex;
-    for (auto arg = fullCommand.begin(); arg != fullCommand.end(); ++arg) {
+    int i = starting_index;
+    for (auto arg = full_command.begin(); arg != full_command.end(); ++arg) {
         args[i++] = arg->c_str();
-        commandString += arg->c_str();
-        if (arg != fullCommand.end() - 1) {
-            commandString += " ";
+        command_string += arg->c_str();
+        if (arg != full_command.end() - 1) {
+            command_string += " ";
         }
     }
     args[i] = nullptr;
     const char* path = args[0];
-    const char* command = commandString.c_str();
+    const char* command = command_string.c_str();
 
     if (options.RootMode() == SU_ROOT && ds.IsUserBuild()) {
         printf("Skipping '%s' on user build.\n", command);
@@ -824,11 +824,11 @@
     }
 
     fflush(stdout);
-    DurationReporter durationReporter(title);
+    DurationReporter duration_reporter(title);
 
-    const std::string& loggingMessage = options.LoggingMessage();
-    if (!loggingMessage.empty()) {
-        MYLOGI(loggingMessage.c_str(), commandString.c_str());
+    const std::string& logging_message = options.LoggingMessage();
+    if (!logging_message.empty()) {
+        MYLOGI(logging_message.c_str(), command_string.c_str());
     }
 
     if (IsDryRun() && !options.Always()) {
@@ -945,11 +945,11 @@
     return status;
 }
 
-void Dumpstate::RunDumpsys(const std::string& title, const std::vector<std::string>& dumpsysArgs,
+void Dumpstate::RunDumpsys(const std::string& title, const std::vector<std::string>& dumpsys_args,
                            const CommandOptions& options, long dumpsysTimeout) {
     long timeout = dumpsysTimeout > 0 ? dumpsysTimeout : options.Timeout();
     std::vector<std::string> dumpsys = {"/system/bin/dumpsys", "-t", std::to_string(timeout)};
-    dumpsys.insert(dumpsys.end(), dumpsysArgs.begin(), dumpsysArgs.end());
+    dumpsys.insert(dumpsys.end(), dumpsys_args.begin(), dumpsys_args.end());
     RunCommand(title, dumpsys, options);
 }
 
@@ -1315,7 +1315,7 @@
 
 // TODO: make this function thread safe if sections are generated in parallel.
 void Dumpstate::UpdateProgress(int delta) {
-    if (!updateProgress_) return;
+    if (!update_progress_) return;
 
     progress_ += delta;
 
@@ -1323,12 +1323,12 @@
     char value[PROPERTY_VALUE_MAX];
 
     // adjusts max on the fly
-    if (progress_ > weightTotal_) {
-        int newTotal = weightTotal_ * 1.2;
-        MYLOGD("Adjusting total weight from %d to %d\n", weightTotal_, newTotal);
-        weightTotal_ = newTotal;
+    if (progress_ > weight_total_) {
+        int new_total = weight_total_ * 1.2;
+        MYLOGD("Adjusting total weight from %d to %d\n", weight_total_, new_total);
+        weight_total_ = new_total;
         snprintf(key, sizeof(key), "dumpstate.%d.max", getpid());
-        snprintf(value, sizeof(value), "%d", weightTotal_);
+        snprintf(value, sizeof(value), "%d", weight_total_);
         int status = property_set(key, value);
         if (status != 0) {
             MYLOGE("Could not update max weight by setting system property %s to %s: %d\n",
@@ -1341,16 +1341,16 @@
 
     if (progress_ % 100 == 0) {
         // We don't want to spam logcat, so only log multiples of 100.
-        MYLOGD("Setting progress (%s): %s/%d\n", key, value, weightTotal_);
+        MYLOGD("Setting progress (%s): %s/%d\n", key, value, weight_total_);
     } else {
         // stderr is ignored on normal invocations, but useful when calling /system/bin/dumpstate
         // directly for debuggging.
-        fprintf(stderr, "Setting progress (%s): %s/%d\n", key, value, weightTotal_);
+        fprintf(stderr, "Setting progress (%s): %s/%d\n", key, value, weight_total_);
     }
 
-    if (controlSocketFd_ >= 0) {
-        dprintf(controlSocketFd_, "PROGRESS:%d/%d\n", progress_, weightTotal_);
-        fsync(controlSocketFd_);
+    if (control_socket_fd_ >= 0) {
+        dprintf(control_socket_fd_, "PROGRESS:%d/%d\n", progress_, weight_total_);
+        fsync(control_socket_fd_);
     }
 
     int status = property_set(key, value);
@@ -1361,14 +1361,14 @@
 }
 
 void Dumpstate::TakeScreenshot(const std::string& path) {
-    const std::string& realPath = path.empty() ? screenshotPath_ : path;
+    const std::string& real_path = path.empty() ? screenshot_path_ : path;
     int status =
-        RunCommand("", {"/system/bin/screencap", "-p", realPath},
+        RunCommand("", {"/system/bin/screencap", "-p", real_path},
                    CommandOptions::WithTimeout(10).Always().DropRoot().RedirectStderr().Build());
     if (status == 0) {
-        MYLOGD("Screenshot saved on %s\n", realPath.c_str());
+        MYLOGD("Screenshot saved on %s\n", real_path.c_str());
     } else {
-        MYLOGE("Failed to take screenshot on %s\n", realPath.c_str());
+        MYLOGE("Failed to take screenshot on %s\n", real_path.c_str());
     }
 }