Merge "adb/base: minor compiler portability improvements"
This commit is contained in:
commit
892f0e9300
7 changed files with 27 additions and 13 deletions
|
@ -163,7 +163,7 @@ void adb_trace_init(char** argv) {
|
|||
}
|
||||
#endif
|
||||
|
||||
android::base::InitLogging(argv, AdbLogger);
|
||||
android::base::InitLogging(argv, &AdbLogger);
|
||||
setup_trace_mask();
|
||||
|
||||
VLOG(ADB) << adb_version();
|
||||
|
|
|
@ -182,11 +182,8 @@ std::string dump_hex(const void* data, size_t byte_count) {
|
|||
line.push_back(' ');
|
||||
|
||||
for (size_t i = 0; i < byte_count; ++i) {
|
||||
int c = p[i];
|
||||
if (c < 32 || c > 127) {
|
||||
c = '.';
|
||||
}
|
||||
line.push_back(c);
|
||||
int ch = p[i];
|
||||
line.push_back(isprint(ch) ? ch : '.');
|
||||
}
|
||||
|
||||
return line;
|
||||
|
|
|
@ -753,7 +753,7 @@ static int set_time_and_mode(const char *lpath, time_t time, unsigned int mode)
|
|||
umask(mask);
|
||||
int r2 = chmod(lpath, mode & ~mask);
|
||||
|
||||
return r1 ? : r2;
|
||||
return r1 ? r1 : r2;
|
||||
}
|
||||
|
||||
static bool copy_remote_dir_local(SyncConnection& sc, std::string rpath,
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#if !ADB_HOST
|
||||
#include "cutils/properties.h"
|
||||
#endif
|
||||
|
|
|
@ -309,7 +309,12 @@ extern char* adb_getcwd(char* buf, int size);
|
|||
#define closedir adb_closedir
|
||||
#define rewinddir rewinddir_utf8_not_yet_implemented
|
||||
#define telldir telldir_utf8_not_yet_implemented
|
||||
#define seekdir seekdir_utf8_not_yet_implemented
|
||||
// Some compiler's C++ headers have members named seekdir, so we can't do the
|
||||
// macro technique and instead cause a link error if seekdir is called.
|
||||
inline void seekdir(DIR*, long) {
|
||||
extern int seekdir_utf8_not_yet_implemented;
|
||||
seekdir_utf8_not_yet_implemented = 1;
|
||||
}
|
||||
|
||||
#define utime adb_utime
|
||||
#define chmod adb_chmod
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
|
||||
#include <base/logging.h>
|
||||
|
|
|
@ -212,8 +212,8 @@ void InitLogging(char* argv[]) {
|
|||
gInitialized = true;
|
||||
|
||||
// Stash the command line for later use. We can use /proc/self/cmdline on
|
||||
// Linux to recover this, but we don't have that luxury on the Mac, and there
|
||||
// are a couple of argv[0] variants that are commonly used.
|
||||
// Linux to recover this, but we don't have that luxury on the Mac/Windows,
|
||||
// and there are a couple of argv[0] variants that are commonly used.
|
||||
if (argv != nullptr) {
|
||||
gProgramInvocationName.reset(new std::string(basename(argv[0])));
|
||||
}
|
||||
|
@ -264,11 +264,20 @@ void SetLogger(LogFunction&& logger) {
|
|||
gLogger = std::move(logger);
|
||||
}
|
||||
|
||||
// We can't use basename(3) because this code runs on the Mac, which doesn't
|
||||
// have a non-modifying basename.
|
||||
static const char* GetFileBasename(const char* file) {
|
||||
// We can't use basename(3) even on Unix because the Mac doesn't
|
||||
// have a non-modifying basename.
|
||||
const char* last_slash = strrchr(file, '/');
|
||||
return (last_slash == nullptr) ? file : last_slash + 1;
|
||||
if (last_slash != nullptr) {
|
||||
return last_slash + 1;
|
||||
}
|
||||
#if defined(_WIN32)
|
||||
const char* last_backslash = strrchr(file, '\\');
|
||||
if (last_backslash != nullptr) {
|
||||
return last_backslash + 1;
|
||||
}
|
||||
#endif
|
||||
return file;
|
||||
}
|
||||
|
||||
// This indirection greatly reduces the stack impact of having lots of
|
||||
|
|
Loading…
Reference in a new issue