Be even more C++. Switch on a warning.

Remove lots of "extern C" and "ifdef __cplusplus" which are no longer
needed now all of vold is C++. Also turn on the cert-err58-cpp warning
we once had to disable.

Bug: 67041047
Test: compiles, boots
Change-Id: I8c6f9dd486f2409e0deed7bb648d959677465b21
diff --git a/Android.bp b/Android.bp
index 4432153..5941cd9 100644
--- a/Android.bp
+++ b/Android.bp
@@ -17,7 +17,6 @@
         "-*",
         "cert-*",
         "clang-analyzer-security*",
-        "-cert-err58-cpp",
     ],
     tidy_flags: [
         "-warnings-as-errors=clang-analyzer-security*,cert-*",
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index f54fb00..e078c0d 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -599,11 +599,6 @@
     return 0;
 }
 
-extern "C" int vold_unmountAll(void) {
-    VolumeManager *vm = VolumeManager::Instance();
-    return vm->unmountAll();
-}
-
 int VolumeManager::mkdirs(const std::string& path) {
     // Only offer to create directories for paths managed by vold
     if (android::base::StartsWith(path, "/storage/")) {
diff --git a/VolumeManager.h b/VolumeManager.h
index 8a780c4..5baa7ce 100644
--- a/VolumeManager.h
+++ b/VolumeManager.h
@@ -21,8 +21,6 @@
 #include <fnmatch.h>
 #include <stdlib.h>
 
-#ifdef __cplusplus
-
 #include <list>
 #include <mutex>
 #include <string>
@@ -154,12 +152,4 @@
     int mNextObbId;
 };
 
-extern "C" {
-#endif /* __cplusplus */
-#define UNMOUNT_NOT_MOUNTED_ERR (-2)
-    int vold_unmountAll(void);
-#ifdef __cplusplus
-}
-#endif
-
 #endif
diff --git a/cryptfs.cpp b/cryptfs.cpp
index ae9b0af..7302c44 100644
--- a/cryptfs.cpp
+++ b/cryptfs.cpp
@@ -2051,6 +2051,11 @@
     return rc;
 }
 
+static int vold_unmountAll(void) {
+    VolumeManager* vm = VolumeManager::Instance();
+    return vm->unmountAll();
+}
+
 int cryptfs_enable_internal(const char *howarg, int crypt_type, const char *passwd,
                             int no_ui)
 {
diff --git a/cryptfs.h b/cryptfs.h
index 5642e29..767270f 100644
--- a/cryptfs.h
+++ b/cryptfs.h
@@ -14,6 +14,9 @@
  * limitations under the License.
  */
 
+#ifndef ANDROID_VOLD_CRYPTFS_H
+#define ANDROID_VOLD_CRYPTFS_H
+
 /* This structure starts 16,384 bytes before the end of a hardware
  * partition that is encrypted, or in a separate partition.  It's location
  * is specified by a property set in init.<device>.rc.
@@ -218,34 +221,28 @@
 #define PERSIST_DEL_KEY_ERROR_OTHER       (-1)
 #define PERSIST_DEL_KEY_ERROR_NO_FIELD    (-2)
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+int match_multi_entry(const char* key, const char* field, unsigned index);
+int wait_and_unmount(const char* mountpoint, bool kill);
 
-  int match_multi_entry(const char *key, const char *field, unsigned index);
-  int wait_and_unmount(const char *mountpoint, bool kill);
+typedef int (*kdf_func)(const char* passwd, const unsigned char* salt, unsigned char* ikey,
+                        void* params);
 
-  typedef int (*kdf_func)(const char *passwd, const unsigned char *salt,
-                          unsigned char *ikey, void *params);
+int cryptfs_crypto_complete(void);
+int cryptfs_check_passwd(const char* pw);
+int cryptfs_verify_passwd(const char* pw);
+int cryptfs_restart(void);
+int cryptfs_enable(const char* flag, int type, const char* passwd, int no_ui);
+int cryptfs_changepw(int type, const char* newpw);
+int cryptfs_enable_default(const char* flag, int no_ui);
+int cryptfs_setup_ext_volume(const char* label, const char* real_blkdev, const unsigned char* key,
+                             int keysize, char* out_crypto_blkdev);
+int cryptfs_revert_ext_volume(const char* label);
+int cryptfs_getfield(const char* fieldname, char* value, int len);
+int cryptfs_setfield(const char* fieldname, const char* value);
+int cryptfs_mount_default_encrypted(void);
+int cryptfs_get_password_type(void);
+const char* cryptfs_get_password(void);
+void cryptfs_clear_password(void);
+int cryptfs_isConvertibleToFBE(void);
 
-  int cryptfs_crypto_complete(void);
-  int cryptfs_check_passwd(const char *pw);
-  int cryptfs_verify_passwd(const char *pw);
-  int cryptfs_restart(void);
-  int cryptfs_enable(const char *flag, int type, const char *passwd, int no_ui);
-  int cryptfs_changepw(int type, const char *newpw);
-  int cryptfs_enable_default(const char *flag, int no_ui);
-  int cryptfs_setup_ext_volume(const char* label, const char* real_blkdev,
-          const unsigned char* key, int keysize, char* out_crypto_blkdev);
-  int cryptfs_revert_ext_volume(const char* label);
-  int cryptfs_getfield(const char *fieldname, char *value, int len);
-  int cryptfs_setfield(const char *fieldname, const char *value);
-  int cryptfs_mount_default_encrypted(void);
-  int cryptfs_get_password_type(void);
-  const char* cryptfs_get_password(void);
-  void cryptfs_clear_password(void);
-  int cryptfs_isConvertibleToFBE(void);
-
-#ifdef __cplusplus
-}
-#endif
+#endif /* ANDROID_VOLD_CRYPTFS_H */