From 91aa74296de76ddea7d234574b3e0ebc1ed399e6 Mon Sep 17 00:00:00 2001
From: George Kulakowski <kulakowski@google.com>
Date: Fri, 16 Nov 2018 22:57:55 -0800
Subject: [PATCH] [devmgr] Avoid identifiers with leading underscores

Test: no functional change
Change-Id: I7917af4cdc34d1a432e993c11d82fb67a298f276
---
 system/core/devmgr/devhost/core.cpp    |  8 ++++----
 system/core/devmgr/devhost/devhost.cpp |  8 ++++----
 system/core/devmgr/devmgr/devfs.cpp    | 22 +++++++++++-----------
 system/core/devmgr/fshost/main.cpp     |  4 ++--
 system/core/devmgr/shared/fdio.cpp     |  6 +++---
 system/core/devmgr/shared/fdio.h       |  8 ++++----
 6 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/system/core/devmgr/devhost/core.cpp b/system/core/devmgr/devhost/core.cpp
index 415fc98fc21..8835ffe44f6 100644
--- a/system/core/devmgr/devhost/core.cpp
+++ b/system/core/devmgr/devhost/core.cpp
@@ -294,7 +294,7 @@ zx_status_t devhost_device_create(zx_driver_t* drv, const fbl::RefPtr<zx_device_
                                   REQ_DM_LOCK {
 
     if (!drv) {
-        printf("devhost: _device_add could not find driver!\n");
+        printf("devhost: device_add could not find driver!\n");
         return ZX_ERR_INVALID_ARGS;
     }
 
@@ -606,8 +606,8 @@ zx_status_t devhost_device_close(fbl::RefPtr<zx_device_t> dev, uint32_t flags) R
     return r;
 }
 
-static zx_status_t _devhost_device_suspend(const fbl::RefPtr<zx_device>& dev,
-                                           uint32_t flags) REQ_DM_LOCK {
+static zx_status_t devhost_device_suspend_locked(const fbl::RefPtr<zx_device>& dev,
+                                               uint32_t flags) REQ_DM_LOCK {
     // first suspend children (so we suspend from leaf up)
     zx_status_t st;
     for (auto& child : dev->children) {
@@ -636,7 +636,7 @@ zx_status_t devhost_device_suspend(const fbl::RefPtr<zx_device>& dev,
                                    uint32_t flags) REQ_DM_LOCK {
     //TODO this should eventually be two-pass using SUSPENDING/SUSPENDED flags
     enum_lock_acquire();
-    zx_status_t r = _devhost_device_suspend(dev, flags);
+    zx_status_t r = devhost_device_suspend_locked(dev, flags);
     enum_lock_release();
     return r;
 }
diff --git a/system/core/devmgr/devhost/devhost.cpp b/system/core/devmgr/devhost/devhost.cpp
index bb14d76083c..0fa90a2891d 100644
--- a/system/core/devmgr/devhost/devhost.cpp
+++ b/system/core/devmgr/devhost/devhost.cpp
@@ -775,7 +775,7 @@ static void proxy_ios_destroy(const fbl::RefPtr<zx_device_t>& dev) {
 
 static zx::debuglog devhost_log_handle;
 
-static ssize_t _devhost_log_write(uint32_t flags, const void* _data, size_t len) {
+static ssize_t devhost_log_write_internal(uint32_t flags, const void* void_data, size_t len) {
     struct Context {
         Context() = default;
 
@@ -793,7 +793,7 @@ static ssize_t _devhost_log_write(uint32_t flags, const void* _data, size_t len)
         ctx->handle = zx::unowned_debuglog(devhost_log_handle);
     }
 
-    const char* data = static_cast<const char*>(_data);
+    const char* data = static_cast<const char*>(void_data);
     size_t r = len;
 
     while (len-- > 0) {
@@ -830,13 +830,13 @@ __EXPORT void driver_printf(uint32_t flags, const char* fmt, ...) {
         r = sizeof(buffer);
     }
 
-    devmgr::_devhost_log_write(flags, buffer, r);
+    devmgr::devhost_log_write_internal(flags, buffer, r);
 }
 
 namespace devmgr {
 
 static ssize_t devhost_log_write(void* cookie, const void* data, size_t len) {
-    return _devhost_log_write(0, data, len);
+    return devhost_log_write_internal(0, data, len);
 }
 
 static void devhost_io_init() {
diff --git a/system/core/devmgr/devmgr/devfs.cpp b/system/core/devmgr/devmgr/devfs.cpp
index 30b6ba39e9a..d4f9e4f08a2 100644
--- a/system/core/devmgr/devmgr/devfs.cpp
+++ b/system/core/devmgr/devmgr/devfs.cpp
@@ -445,7 +445,7 @@ done:
     return ZX_OK;
 }
 
-static void _devfs_remove(Devnode* dn) {
+static void devfs_remove(Devnode* dn) {
     if (list_in_list(&dn->node)) {
         list_delete(&dn->node);
     }
@@ -495,21 +495,21 @@ static void _devfs_remove(Devnode* dn) {
 
 void devfs_unpublish(Device* dev) {
     if (dev->self != nullptr) {
-        _devfs_remove(dev->self);
+        devfs_remove(dev->self);
         dev->self = nullptr;
     }
     if (dev->link != nullptr) {
-        _devfs_remove(dev->link);
+        devfs_remove(dev->link);
         dev->link = nullptr;
     }
 }
 
-static zx_status_t devfs_walk(Devnode** _dn, char* path, char** pathout) {
-    Devnode* dn = *_dn;
+static zx_status_t devfs_walk(Devnode** dn_inout, char* path, char** pathout) {
+    Devnode* dn = *dn_inout;
 
 again:
     if ((path == nullptr) || (path[0] == 0)) {
-        *_dn = dn;
+        *dn_inout = dn;
         return ZX_OK;
     }
     char* name = path;
@@ -531,13 +531,13 @@ again:
             goto again;
         }
     }
-    if (dn == *_dn) {
+    if (dn == *dn_inout) {
         return ZX_ERR_NOT_FOUND;
     }
     if (undo) {
         *undo = '/';
     }
-    *_dn = dn;
+    *dn_inout = dn;
     *pathout = name;
     return ZX_ERR_NEXT;
 }
@@ -627,9 +627,9 @@ static zx_status_t fill_dirent(vdirent_t* de, size_t delen, uint64_t ino,
     return static_cast<zx_status_t>(sz);
 }
 
-static zx_status_t devfs_readdir(Devnode* dn, uint64_t* _ino, void* data, size_t len) {
+static zx_status_t devfs_readdir(Devnode* dn, uint64_t* ino_inout, void* data, size_t len) {
     char* ptr = static_cast<char*>(data);
-    uint64_t ino = *_ino;
+    uint64_t ino = *ino_inout;
 
     Devnode* child;
     list_for_every_entry(&dn->children, child, Devnode, node) {
@@ -660,7 +660,7 @@ static zx_status_t devfs_readdir(Devnode* dn, uint64_t* _ino, void* data, size_t
         len -= r;
     }
 
-    *_ino = ino;
+    *ino_inout = ino;
     return static_cast<zx_status_t>(ptr - static_cast<char*>(data));
 }
 
diff --git a/system/core/devmgr/fshost/main.cpp b/system/core/devmgr/fshost/main.cpp
index 3f2c5552467..d1893087b15 100644
--- a/system/core/devmgr/fshost/main.cpp
+++ b/system/core/devmgr/fshost/main.cpp
@@ -388,7 +388,7 @@ int main(int argc, char** argv) {
         argv++;
     }
 
-    zx::channel _fs_root = zx::channel(zx_take_startup_handle(PA_HND(PA_USER0, 0)));
+    zx::channel fs_root = zx::channel(zx_take_startup_handle(PA_HND(PA_USER0, 0)));
     zx::channel devfs_root = zx::channel(zx_take_startup_handle(PA_HND(PA_USER0, 1)));
     zx::channel svc_root = zx::channel(zx_take_startup_handle(PA_HND(PA_USER0, 2)));
     zx_handle_t devmgr_loader = zx_take_startup_handle(PA_HND(PA_USER0, 3));
@@ -406,7 +406,7 @@ int main(int argc, char** argv) {
 
     // Initialize connections to external service managers, and begin
     // monitoring the |fshost_event| for a termination event.
-    root->InitializeConnections(std::move(_fs_root), std::move(devfs_root),
+    root->InitializeConnections(std::move(fs_root), std::move(devfs_root),
                                 std::move(svc_root), std::move(fshost_event));
     g_fshost = root.get();
 
diff --git a/system/core/devmgr/shared/fdio.cpp b/system/core/devmgr/shared/fdio.cpp
index fb375989ee5..b0a8e6d8cf9 100644
--- a/system/core/devmgr/shared/fdio.cpp
+++ b/system/core/devmgr/shared/fdio.cpp
@@ -74,7 +74,7 @@ zx_status_t devmgr_launch(
     const zx::job& job, const char* name,
     zx_status_t (*load)(void*, launchpad_t*, const char*), void* ctx,
     int argc, const char* const* argv,
-    const char** _envp, int stdiofd,
+    const char** initial_envp, int stdiofd,
     const zx_handle_t* handles, const uint32_t* types, size_t hcount,
     zx::process* out_proc, uint32_t flags) {
     zx_status_t status;
@@ -85,8 +85,8 @@ zx_status_t devmgr_launch(
         envp[envn++] = LDSO_TRACE_ENV;
     }
     envp[envn++] = ZX_SHELL_ENV_PATH;
-    while ((_envp && _envp[0]) && (envn < MAX_ENVP)) {
-        envp[envn++] = *_envp++;
+    while ((initial_envp && initial_envp[0]) && (envn < MAX_ENVP)) {
+        envp[envn++] = *initial_envp++;
     }
     envp[envn++] = nullptr;
 
diff --git a/system/core/devmgr/shared/fdio.h b/system/core/devmgr/shared/fdio.h
index f764ed417bc..ba79e0a97d0 100644
--- a/system/core/devmgr/shared/fdio.h
+++ b/system/core/devmgr/shared/fdio.h
@@ -50,10 +50,10 @@ zx_status_t devmgr_launch_cmdline(
     const zx_handle_t* handles, const uint32_t* types, size_t hcount,
     zx::process* proc_out, uint32_t flags);
 
-// getenv_bool looks in the environment for name. If not found, it returns
-// default. If found, it returns false if the found value matches "0", "off", or
-// "false", otherwise it returns true.
-bool getenv_bool(const char* key, bool _default);
+// getenv_bool looks in the environment for |key|. If not found, it
+// returns |default_value|. If found, it returns false if the found
+// value matches "0", "off", or "false", otherwise it returns true.
+bool getenv_bool(const char* key, bool default_value);
 
 // The variable to set on the kernel command line to enable ld.so tracing
 // of the processes we launch.
-- 
GitLab