summaryrefslogtreecommitdiffstats
path: root/base/logging.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2018-10-19 13:59:44 -0700
committerElliott Hughes <enh@google.com>2018-10-19 14:04:24 -0700
commit4679a39610e053680f33f8e88fc52d91a9754d51 (patch)
treee792f990d5e480da68418291779dc2a02d966794 /base/logging.cpp
parent7a08c896dda54b1814a2c7f06e45fff3de98ecdc (diff)
downloadsystem_core-4679a39610e053680f33f8e88fc52d91a9754d51.tar.gz
system_core-4679a39610e053680f33f8e88fc52d91a9754d51.tar.bz2
system_core-4679a39610e053680f33f8e88fc52d91a9754d51.zip
adb: rationalize fatal/error logging.
Let's use LOG(FATAL)/PLOG(FATAL) for actual fatal stuff. Add a Windows error(3) and move folks who didn't really mean "abort" fatal over to it. Also get rid of syntax_error which wasn't adding a lot of value, and most of the places it was adding "usage: " didn't seem entirely appropriate anyway. In particular, we seemed to have confused fastdeploy.cpp into aborting in most user error cases, and none of the reviewers noticed. Clearly we'd all lost track of far too many options. (I've also cleaned up a few random instances of fprintf(3) + exit(2).) Bug: N/A Test: manual Change-Id: I3e8440848a24e30d928de9eded505916bc324786
Diffstat (limited to 'base/logging.cpp')
-rw-r--r--base/logging.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/base/logging.cpp b/base/logging.cpp
index d60d91d5d..bd09069a0 100644
--- a/base/logging.cpp
+++ b/base/logging.cpp
@@ -53,6 +53,7 @@
#include <unistd.h>
#endif
+#include <android-base/file.h>
#include <android-base/macros.h>
#include <android-base/parseint.h>
#include <android-base/strings.h>
@@ -71,14 +72,8 @@ static const char* getprogname() {
static char progname[MAX_PATH] = {};
if (first) {
- CHAR longname[MAX_PATH];
- DWORD nchars = GetModuleFileNameA(nullptr, longname, arraysize(longname));
- if ((nchars >= arraysize(longname)) || (nchars == 0)) {
- // String truncation or some other error.
- strcpy(progname, "<unknown>");
- } else {
- strcpy(progname, basename(longname));
- }
+ snprintf(progname, sizeof(progname), "%s",
+ android::base::Basename(android::base::GetExecutablePath()).c_str());
first = false;
}