Merge "Use more std::string in fastboot."
diff --git a/adb/fdevent_test.h b/adb/fdevent_test.h
index c853bce..ef65b74 100644
--- a/adb/fdevent_test.h
+++ b/adb/fdevent_test.h
@@ -49,6 +49,16 @@
dummy = dummy_fds[0];
}
+ size_t GetAdditionalLocalSocketCount() {
+#if ADB_HOST
+ // dummy socket installed in PrepareThread()
+ return 1;
+#else
+ // dummy socket and one more socket installed in fdevent_subproc_setup()
+ return 2;
+#endif
+ }
+
void TerminateThread(adb_thread_t thread) {
fdevent_terminate_loop();
ASSERT_TRUE(WriteFdExactly(dummy, "", 1));
diff --git a/adb/socket_test.cpp b/adb/socket_test.cpp
index 20a3bbb..d2ce2d8 100644
--- a/adb/socket_test.cpp
+++ b/adb/socket_test.cpp
@@ -44,6 +44,8 @@
fdevent_loop();
}
+const size_t SLEEP_FOR_FDEVENT_IN_MS = 100;
+
TEST_F(LocalSocketTest, smoke) {
// Join two socketpairs with a chain of intermediate socketpairs.
int first[2];
@@ -99,7 +101,8 @@
ASSERT_EQ(0, adb_close(last[1]));
// Wait until the local sockets are closed.
- adb_sleep_ms(100);
+ adb_sleep_ms(SLEEP_FOR_FDEVENT_IN_MS);
+ ASSERT_EQ(GetAdditionalLocalSocketCount(), fdevent_installed_count());
TerminateThread(thread);
}
@@ -151,12 +154,13 @@
ASSERT_TRUE(adb_thread_create(reinterpret_cast<void (*)(void*)>(CloseWithPacketThreadFunc),
&arg, &thread));
// Wait until the fdevent_loop() starts.
- adb_sleep_ms(100);
+ adb_sleep_ms(SLEEP_FOR_FDEVENT_IN_MS);
ASSERT_EQ(0, adb_close(cause_close_fd[0]));
- adb_sleep_ms(100);
- EXPECT_EQ(2u, fdevent_installed_count());
+ adb_sleep_ms(SLEEP_FOR_FDEVENT_IN_MS);
+ EXPECT_EQ(1u + GetAdditionalLocalSocketCount(), fdevent_installed_count());
ASSERT_EQ(0, adb_close(socket_fd[0]));
-
+ adb_sleep_ms(SLEEP_FOR_FDEVENT_IN_MS);
+ ASSERT_EQ(GetAdditionalLocalSocketCount(), fdevent_installed_count());
TerminateThread(thread);
}
@@ -175,10 +179,10 @@
ASSERT_TRUE(adb_thread_create(reinterpret_cast<void (*)(void*)>(CloseWithPacketThreadFunc),
&arg, &thread));
// Wait until the fdevent_loop() starts.
- adb_sleep_ms(100);
+ adb_sleep_ms(SLEEP_FOR_FDEVENT_IN_MS);
ASSERT_EQ(0, adb_close(cause_close_fd[0]));
- adb_sleep_ms(100);
- EXPECT_EQ(2u, fdevent_installed_count());
+ adb_sleep_ms(SLEEP_FOR_FDEVENT_IN_MS);
+ EXPECT_EQ(1u + GetAdditionalLocalSocketCount(), fdevent_installed_count());
// Verify if we can read successfully.
std::vector<char> buf(arg.bytes_written);
@@ -186,6 +190,8 @@
ASSERT_EQ(true, ReadFdExactly(socket_fd[0], buf.data(), buf.size()));
ASSERT_EQ(0, adb_close(socket_fd[0]));
+ adb_sleep_ms(SLEEP_FOR_FDEVENT_IN_MS);
+ ASSERT_EQ(GetAdditionalLocalSocketCount(), fdevent_installed_count());
TerminateThread(thread);
}
@@ -208,10 +214,12 @@
&arg, &thread));
// Wait until the fdevent_loop() starts.
- adb_sleep_ms(100);
- EXPECT_EQ(3u, fdevent_installed_count());
+ adb_sleep_ms(SLEEP_FOR_FDEVENT_IN_MS);
+ EXPECT_EQ(2u + GetAdditionalLocalSocketCount(), fdevent_installed_count());
ASSERT_EQ(0, adb_close(socket_fd[0]));
+ adb_sleep_ms(SLEEP_FOR_FDEVENT_IN_MS);
+ ASSERT_EQ(GetAdditionalLocalSocketCount(), fdevent_installed_count());
TerminateThread(thread);
}
@@ -260,12 +268,14 @@
&arg, &thread));
// Wait until the fdevent_loop() starts.
- adb_sleep_ms(100);
- EXPECT_EQ(2u, fdevent_installed_count());
+ adb_sleep_ms(SLEEP_FOR_FDEVENT_IN_MS);
+ EXPECT_EQ(1u + GetAdditionalLocalSocketCount(), fdevent_installed_count());
// Wait until the client closes its socket.
ASSERT_TRUE(adb_thread_join(client_thread));
+ adb_sleep_ms(SLEEP_FOR_FDEVENT_IN_MS);
+ ASSERT_EQ(GetAdditionalLocalSocketCount(), fdevent_installed_count());
TerminateThread(thread);
}
diff --git a/adb/sysdeps_test.cpp b/adb/sysdeps_test.cpp
index f0c334e..fde344a 100644
--- a/adb/sysdeps_test.cpp
+++ b/adb/sysdeps_test.cpp
@@ -218,7 +218,7 @@
TEST_F(sysdeps_poll, fd_count) {
// https://code.google.com/p/android/issues/detail?id=12141
- static constexpr int num_sockets = 512;
+ static constexpr int num_sockets = 256;
std::vector<int> sockets;
std::vector<adb_pollfd> pfds;
sockets.resize(num_sockets * 2);
diff --git a/adb/test_device.py b/adb/test_device.py
index 9dab3ae..2a3be88 100644
--- a/adb/test_device.py
+++ b/adb/test_device.py
@@ -279,7 +279,7 @@
Raises:
unittest.SkipTest: The device doesn't support exit codes.
"""
- if self.device.SHELL_PROTOCOL_FEATURE not in self.device.features:
+ if not self.device.has_shell_protocol():
raise unittest.SkipTest('exit codes are unavailable on this device')
proc = subprocess.Popen(
@@ -342,7 +342,7 @@
a terminal stdin to test so this test will be skipped if stdin
is not a terminal.
"""
- if self.device.SHELL_PROTOCOL_FEATURE not in self.device.features:
+ if not self.device.has_shell_protocol():
raise unittest.SkipTest('PTY arguments unsupported on this device')
if not os.isatty(sys.stdin.fileno()):
raise unittest.SkipTest('PTY tests require stdin terminal')
@@ -394,7 +394,7 @@
Bug: http://b/19734861
"""
- if self.device.SHELL_PROTOCOL_FEATURE not in self.device.features:
+ if not self.device.has_shell_protocol():
raise unittest.SkipTest('shell protocol unsupported on this device')
# Shell protocol should be used by default.
@@ -424,7 +424,7 @@
Bug: http://b/23825725
"""
- if self.device.SHELL_PROTOCOL_FEATURE not in self.device.features:
+ if not self.device.has_shell_protocol():
raise unittest.SkipTest('shell protocol unsupported on this device')
# Start a long-running process.
@@ -445,7 +445,7 @@
def test_non_interactive_stdin(self):
"""Tests that non-interactive shells send stdin."""
- if self.device.SHELL_PROTOCOL_FEATURE not in self.device.features:
+ if not self.device.has_shell_protocol():
raise unittest.SkipTest('non-interactive stdin unsupported '
'on this device')
diff --git a/bootstat/Android.mk b/bootstat/Android.mk
index 6300941..bdd680d 100644
--- a/bootstat/Android.mk
+++ b/bootstat/Android.mk
@@ -16,8 +16,6 @@
LOCAL_PATH := $(call my-dir)
-bootstat_c_includes := external/gtest/include
-
bootstat_lib_src_files := \
boot_event_record_store.cpp \
event_log_list_builder.cpp \
@@ -57,7 +55,7 @@
LOCAL_MODULE := libbootstat
LOCAL_CFLAGS := $(bootstat_cflags)
-LOCAL_C_INCLUDES := $(bootstat_c_includes)
+LOCAL_WHOLE_STATIC_LIBRARIES := libgtest_prod
LOCAL_SHARED_LIBRARIES := $(bootstat_shared_libs)
LOCAL_SRC_FILES := $(bootstat_lib_src_files)
# Clang is required because of C++14
@@ -72,7 +70,7 @@
LOCAL_MODULE := libbootstat_debug
LOCAL_CFLAGS := $(bootstat_cflags)
-LOCAL_C_INCLUDES := $(bootstat_c_includes)
+LOCAL_WHOLE_STATIC_LIBRARIES := libgtest_prod
LOCAL_SHARED_LIBRARIES := $(bootstat_shared_libs)
LOCAL_SRC_FILES := $(bootstat_lib_src_files)
# Clang is required because of C++14
@@ -87,7 +85,7 @@
LOCAL_MODULE := libbootstat_host_debug
LOCAL_CFLAGS := $(bootstat_debug_cflags)
-LOCAL_C_INCLUDES := $(bootstat_c_includes)
+LOCAL_WHOLE_STATIC_LIBRARIES := libgtest_prod
LOCAL_SHARED_LIBRARIES := $(bootstat_shared_libs)
LOCAL_SRC_FILES := $(bootstat_lib_src_files)
# Clang is required because of C++14
@@ -102,7 +100,7 @@
LOCAL_MODULE := bootstat
LOCAL_CFLAGS := $(bootstat_cflags)
-LOCAL_C_INCLUDES := $(bootstat_c_includes)
+LOCAL_WHOLE_STATIC_LIBRARIES := libgtest_prod
LOCAL_SHARED_LIBRARIES := $(bootstat_shared_libs)
LOCAL_STATIC_LIBRARIES := libbootstat
LOCAL_INIT_RC := bootstat.rc
diff --git a/include/log/log.h b/include/log/log.h
index e606a84..045feca 100644
--- a/include/log/log.h
+++ b/include/log/log.h
@@ -614,11 +614,11 @@
* The stuff in the rest of this file should not be used directly.
*/
-#define android_printLog(prio, tag, fmt...) \
- __android_log_print(prio, tag, fmt)
+#define android_printLog(prio, tag, ...) \
+ __android_log_print(prio, tag, __VA_ARGS__)
-#define android_vprintLog(prio, cond, tag, fmt...) \
- __android_log_vprint(prio, tag, fmt)
+#define android_vprintLog(prio, cond, tag, ...) \
+ __android_log_vprint(prio, tag, __VA_ARGS__)
/* XXX Macros to work around syntax errors in places where format string
* arg is not passed to ALOG_ASSERT, LOG_ALWAYS_FATAL or LOG_ALWAYS_FATAL_IF
@@ -635,9 +635,9 @@
*/
#define __android_rest(first, ...) , ## __VA_ARGS__
-#define android_printAssert(cond, tag, fmt...) \
+#define android_printAssert(cond, tag, ...) \
__android_log_assert(cond, tag, \
- __android_second(0, ## fmt, NULL) __android_rest(fmt))
+ __android_second(0, ## __VA_ARGS__, NULL) __android_rest(__VA_ARGS__))
#define android_writeLog(prio, tag, text) \
__android_log_write(prio, tag, text)
diff --git a/init/devices.cpp b/init/devices.cpp
index e74140b..d452dd3 100644
--- a/init/devices.cpp
+++ b/init/devices.cpp
@@ -244,7 +244,11 @@
mode = get_device_perm(path, links, &uid, &gid) | (block ? S_IFBLK : S_IFCHR);
- selabel_lookup_best_match(sehandle, &secontext, path, links, mode);
+ if (selabel_lookup_best_match(sehandle, &secontext, path, links, mode)) {
+ ERROR("Device '%s' not created; cannot find SELinux label (%s)\n",
+ path, strerror(errno));
+ return;
+ }
setfscreatecon(secontext);
dev = makedev(major, minor);
@@ -254,14 +258,19 @@
* racy. Fixing the gid race at least fixed the issue with system_server
* opening dynamic input devices under the AID_INPUT gid. */
setegid(gid);
- mknod(path, mode, dev);
+ /* If the node already exists update its SELinux label to handle cases when
+ * it was created with the wrong context during coldboot procedure. */
+ if (mknod(path, mode, dev) && (errno == EEXIST)) {
+ if (lsetfilecon(path, secontext)) {
+ ERROR("Cannot set '%s' SELinux label on '%s' device (%s)\n",
+ secontext, path, strerror(errno));
+ }
+ }
chown(path, uid, -1);
setegid(AID_ROOT);
- if (secontext) {
- freecon(secontext);
- setfscreatecon(NULL);
- }
+ freecon(secontext);
+ setfscreatecon(NULL);
}
static void add_platform_device(const char *path)
diff --git a/liblog/event_tag_map.c b/liblog/event_tag_map.c
index 64d872a..3cb04cf 100644
--- a/liblog/event_tag_map.c
+++ b/liblog/event_tag_map.c
@@ -73,7 +73,7 @@
if (newTagMap == NULL)
return NULL;
- fd = open(fileName, O_RDONLY);
+ fd = open(fileName, O_RDONLY | O_CLOEXEC);
if (fd < 0) {
fprintf(stderr, "%s: unable to open map '%s': %s\n",
OUT_TAG, fileName, strerror(errno));
diff --git a/liblog/logd_reader.c b/liblog/logd_reader.c
index d844104..b894349 100644
--- a/liblog/logd_reader.c
+++ b/liblog/logd_reader.c
@@ -85,7 +85,7 @@
.clear = logdClear,
.getSize = logdGetSize,
.setSize = logdSetSize,
- .getReadableSize = logdGetSize,
+ .getReadableSize = logdGetReadableSize,
.getPrune = logdGetPrune,
.setPrune = logdSetPrune,
.getStats = logdGetStats,
diff --git a/liblog/logprint.c b/liblog/logprint.c
index 88afc14..59bd479 100644
--- a/liblog/logprint.c
+++ b/liblog/logprint.c
@@ -1043,7 +1043,7 @@
* Anything in the Android Logger before the dmesg logging span will
* be highly suspect regarding the monotonic time calculations.
*/
- FILE *p = popen("/system/bin/dmesg", "r");
+ FILE *p = popen("/system/bin/dmesg", "re");
if (p) {
char *line = NULL;
size_t len = 0;
diff --git a/liblog/pmsg_reader.c b/liblog/pmsg_reader.c
index 5695e8a..f5e91c8 100644
--- a/liblog/pmsg_reader.c
+++ b/liblog/pmsg_reader.c
@@ -151,13 +151,13 @@
memset(log_msg, 0, sizeof(*log_msg));
if (transp->context.fd <= 0) {
- int fd = open("/sys/fs/pstore/pmsg-ramoops-0", O_RDONLY);
+ int fd = open("/sys/fs/pstore/pmsg-ramoops-0", O_RDONLY | O_CLOEXEC);
if (fd < 0) {
return -errno;
}
if (fd == 0) { /* Argggg */
- fd = open("/sys/fs/pstore/pmsg-ramoops-0", O_RDONLY);
+ fd = open("/sys/fs/pstore/pmsg-ramoops-0", O_RDONLY | O_CLOEXEC);
close(0);
if (fd < 0) {
return -errno;
diff --git a/liblog/pmsg_writer.c b/liblog/pmsg_writer.c
index 9cd3c48..2ba31fa 100644
--- a/liblog/pmsg_writer.c
+++ b/liblog/pmsg_writer.c
@@ -54,7 +54,7 @@
static int pmsgOpen()
{
if (pmsgLoggerWrite.context.fd < 0) {
- pmsgLoggerWrite.context.fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY));
+ pmsgLoggerWrite.context.fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY | O_CLOEXEC));
}
return pmsgLoggerWrite.context.fd;
diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp
index f0360db..e20c823 100644
--- a/libnativeloader/native_loader.cpp
+++ b/libnativeloader/native_loader.cpp
@@ -36,7 +36,7 @@
namespace android {
#if defined(__ANDROID__)
-static constexpr const char* kPublicNativeLibrariesSystemConfig = "/system/etc/public.libraries.txt";
+static constexpr const char* kPublicNativeLibrariesSystemConfigPathFromRoot = "/etc/public.libraries.txt";
static constexpr const char* kPublicNativeLibrariesVendorConfig = "/vendor/etc/public.libraries.txt";
class LibraryNamespaces {
@@ -95,10 +95,14 @@
void Initialize() {
std::vector<std::string> sonames;
+ const char* android_root_env = getenv("ANDROID_ROOT");
+ std::string root_dir = android_root_env != nullptr ? android_root_env : "/system";
+ std::string public_native_libraries_system_config =
+ root_dir + kPublicNativeLibrariesSystemConfigPathFromRoot;
- LOG_ALWAYS_FATAL_IF(!ReadConfig(kPublicNativeLibrariesSystemConfig, &sonames),
+ LOG_ALWAYS_FATAL_IF(!ReadConfig(public_native_libraries_system_config, &sonames),
"Error reading public native library list from \"%s\": %s",
- kPublicNativeLibrariesSystemConfig, strerror(errno));
+ public_native_libraries_system_config.c_str(), strerror(errno));
// This file is optional, quietly ignore if the file does not exist.
ReadConfig(kPublicNativeLibrariesVendorConfig, &sonames);
@@ -159,10 +163,6 @@
static std::mutex g_namespaces_mutex;
static LibraryNamespaces* g_namespaces = new LibraryNamespaces;
-
-static bool namespaces_enabled(uint32_t target_sdk_version) {
- return target_sdk_version > 0;
-}
#endif
void InitializeNativeLoader() {
@@ -180,10 +180,7 @@
jstring library_path,
jstring permitted_path) {
#if defined(__ANDROID__)
- if (!namespaces_enabled(target_sdk_version)) {
- return nullptr;
- }
-
+ UNUSED(target_sdk_version);
std::lock_guard<std::mutex> guard(g_namespaces_mutex);
android_namespace_t* ns = g_namespaces->Create(env,
class_loader,
@@ -206,7 +203,8 @@
jobject class_loader,
jstring library_path) {
#if defined(__ANDROID__)
- if (!namespaces_enabled(target_sdk_version) || class_loader == nullptr) {
+ UNUSED(target_sdk_version);
+ if (class_loader == nullptr) {
return dlopen(path, RTLD_NOW);
}
diff --git a/libpixelflinger/scanline.cpp b/libpixelflinger/scanline.cpp
index a718b02..f48e1d0 100644
--- a/libpixelflinger/scanline.cpp
+++ b/libpixelflinger/scanline.cpp
@@ -965,7 +965,7 @@
* Use only for one-to-one texture mapping.
*/
struct horz_iterator32 {
- horz_iterator32(context_t* c) {
+ explicit horz_iterator32(context_t* c) {
const int x = c->iterators.xl;
const int y = c->iterators.y;
texture_t& tx = c->state.texture[0];
@@ -982,7 +982,7 @@
/* A variant for 16-bit source textures. */
struct horz_iterator16 {
- horz_iterator16(context_t* c) {
+ explicit horz_iterator16(context_t* c) {
const int x = c->iterators.xl;
const int y = c->iterators.y;
texture_t& tx = c->state.texture[0];
@@ -1002,7 +1002,7 @@
* texture pixel value.
*/
struct clamp_iterator {
- clamp_iterator(context_t* c) {
+ explicit clamp_iterator(context_t* c) {
const int xs = c->iterators.xl;
texture_t& tx = c->state.texture[0];
texture_iterators_t& ti = tx.iterators;
@@ -1112,13 +1112,13 @@
}
struct horz_clamp_iterator16 : horz_clamp_iterator {
- horz_clamp_iterator16(const context_t* c) {
+ explicit horz_clamp_iterator16(const context_t* c) {
init(c,1);
};
};
struct horz_clamp_iterator32 : horz_clamp_iterator {
- horz_clamp_iterator32(context_t* c) {
+ explicit horz_clamp_iterator32(context_t* c) {
init(c,2);
};
};
@@ -1126,7 +1126,7 @@
/* This is used to perform dithering operations.
*/
struct ditherer {
- ditherer(const context_t* c) {
+ explicit ditherer(const context_t* c) {
const int x = c->iterators.xl;
const int y = c->iterators.y;
m_line = &c->ditherMatrix[ ((y & GGL_DITHER_MASK)<<GGL_DITHER_ORDER_SHIFT) ];
@@ -1172,7 +1172,7 @@
* blender.blend(<32-bit-src-pixel-value>,<ptr-to-16-bit-dest-pixel>)
*/
struct blender_32to16 {
- blender_32to16(context_t* /*c*/) { }
+ explicit blender_32to16(context_t* /*c*/) { }
void write(uint32_t s, uint16_t* dst) {
if (s == 0)
return;
@@ -1229,7 +1229,7 @@
* where dstFactor=srcA*(1-srcA) srcFactor=srcA
*/
struct blender_32to16_srcA {
- blender_32to16_srcA(const context_t* /*c*/) { }
+ explicit blender_32to16_srcA(const context_t* /*c*/) { }
void write(uint32_t s, uint16_t* dst) {
if (!s) {
return;
@@ -1271,7 +1271,7 @@
/* This blender does a normal blend after modulation.
*/
struct blender_32to16_modulate : blender_modulate {
- blender_32to16_modulate(const context_t* c) {
+ explicit blender_32to16_modulate(const context_t* c) {
init(c);
}
void write(uint32_t s, uint16_t* dst) {
@@ -1343,7 +1343,7 @@
/* same as 32to16_modulate, except that the input is xRGB, instead of ARGB */
struct blender_x32to16_modulate : blender_modulate {
- blender_x32to16_modulate(const context_t* c) {
+ explicit blender_x32to16_modulate(const context_t* c) {
init(c);
}
void write(uint32_t s, uint16_t* dst) {
@@ -1398,7 +1398,7 @@
/* Same as above, but source is 16bit rgb565 */
struct blender_16to16_modulate : blender_modulate {
- blender_16to16_modulate(const context_t* c) {
+ explicit blender_16to16_modulate(const context_t* c) {
init(c);
}
void write(uint16_t s16, uint16_t* dst) {
@@ -1434,7 +1434,7 @@
* }
*/
struct dst_iterator16 {
- dst_iterator16(const context_t* c) {
+ explicit dst_iterator16(const context_t* c) {
const int x = c->iterators.xl;
const int width = c->iterators.xr - x;
const int32_t y = c->iterators.y;
diff --git a/libziparchive/zip_archive_stream_entry.cc b/libziparchive/zip_archive_stream_entry.cc
index f618835..4b205a7 100644
--- a/libziparchive/zip_archive_stream_entry.cc
+++ b/libziparchive/zip_archive_stream_entry.cc
@@ -48,7 +48,8 @@
class ZipArchiveStreamEntryUncompressed : public ZipArchiveStreamEntry {
public:
- ZipArchiveStreamEntryUncompressed(ZipArchiveHandle handle) : ZipArchiveStreamEntry(handle) {}
+ explicit ZipArchiveStreamEntryUncompressed(ZipArchiveHandle handle)
+ : ZipArchiveStreamEntry(handle) {}
virtual ~ZipArchiveStreamEntryUncompressed() {}
const std::vector<uint8_t>* Read() override;
@@ -110,7 +111,8 @@
class ZipArchiveStreamEntryCompressed : public ZipArchiveStreamEntry {
public:
- ZipArchiveStreamEntryCompressed(ZipArchiveHandle handle) : ZipArchiveStreamEntry(handle) {}
+ explicit ZipArchiveStreamEntryCompressed(ZipArchiveHandle handle)
+ : ZipArchiveStreamEntry(handle) {}
virtual ~ZipArchiveStreamEntryCompressed();
const std::vector<uint8_t>* Read() override;
@@ -249,7 +251,7 @@
class ZipArchiveStreamEntryRawCompressed : public ZipArchiveStreamEntryUncompressed {
public:
- ZipArchiveStreamEntryRawCompressed(ZipArchiveHandle handle)
+ explicit ZipArchiveStreamEntryRawCompressed(ZipArchiveHandle handle)
: ZipArchiveStreamEntryUncompressed(handle) {}
virtual ~ZipArchiveStreamEntryRawCompressed() {}
diff --git a/logcat/tests/logcat_benchmark.cpp b/logcat/tests/logcat_benchmark.cpp
index be815be..dd85164 100644
--- a/logcat/tests/logcat_benchmark.cpp
+++ b/logcat/tests/logcat_benchmark.cpp
@@ -49,7 +49,7 @@
}
}
- timestamp(const char *buffer)
+ explicit timestamp(const char *buffer)
{
init(buffer);
}
diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp
index 8c30f79..db65978 100644
--- a/logd/LogBuffer.cpp
+++ b/logd/LogBuffer.cpp
@@ -380,7 +380,7 @@
tid(tid),
padding(0) {
}
- LogBufferElementKey(uint64_t key):value(key) { }
+ explicit LogBufferElementKey(uint64_t key):value(key) { }
uint64_t getKey() { return value; }
};
diff --git a/sdcard/sdcard.c b/sdcard/sdcard.c
index f862561..f08c9d8 100644
--- a/sdcard/sdcard.c
+++ b/sdcard/sdcard.c
@@ -822,7 +822,8 @@
hdr->nodeid, node ? node->name : "?");
if (node) {
__u64 n = req->nlookup;
- while (n--) {
+ while (n) {
+ n--;
release_node_locked(node);
}
}
diff --git a/toolbox/ps.c b/toolbox/ps.c
index d366f3e..3b3c8a1 100644
--- a/toolbox/ps.c
+++ b/toolbox/ps.c
@@ -60,7 +60,7 @@
snprintf(statline, sizeof(statline), "/proc/%d", tid ? tid : pid);
stat(statline, &stats);
- if(tid) {
+ if (tid) {
snprintf(statline, sizeof(statline), "/proc/%d/task/%d/stat", pid, tid);
cmdline[0] = 0;
snprintf(macline, sizeof(macline), "/proc/%d/task/%d/attr/current", pid, tid);
@@ -69,21 +69,21 @@
snprintf(cmdline, sizeof(cmdline), "/proc/%d/cmdline", pid);
snprintf(macline, sizeof(macline), "/proc/%d/attr/current", pid);
int fd = open(cmdline, O_RDONLY);
- if(fd == 0) {
+ if (fd == 0) {
r = 0;
} else {
r = read(fd, cmdline, 1023);
close(fd);
- if(r < 0) r = 0;
+ if (r < 0) r = 0;
}
cmdline[r] = 0;
}
int fd = open(statline, O_RDONLY);
- if(fd == 0) return -1;
+ if (fd == 0) return -1;
r = read(fd, statline, 1023);
close(fd);
- if(r < 0) return -1;
+ if (r < 0) return -1;
statline[r] = 0;
ptr = statline;
@@ -142,19 +142,19 @@
nexttok(&ptr); // tty
- if(tid != 0) {
+ if (tid != 0) {
ppid = pid;
pid = tid;
}
pw = getpwuid(stats.st_uid);
- if(pw == 0 || (display_flags & SHOW_NUMERIC_UID)) {
- snprintf(user,sizeof(user),"%d",(int)stats.st_uid);
+ if (pw == 0 || (display_flags & SHOW_NUMERIC_UID)) {
+ snprintf(user, sizeof(user), "%d", (int)stats.st_uid);
} else {
- strcpy(user,pw->pw_name);
+ strcpy(user, pw->pw_name);
}
- if(ppid_filter != 0 && ppid != ppid_filter) {
+ if (ppid_filter != 0 && ppid != ppid_filter) {
return 0;
}
@@ -196,7 +196,7 @@
print_exe_abi(pid);
}
printf("%s", cmdline[0] ? cmdline : name);
- if(display_flags&SHOW_TIME)
+ if (display_flags & SHOW_TIME)
printf(" (u:%d, s:%d)", utime, stime);
printf("\n");
@@ -210,13 +210,13 @@
snprintf(exeline, sizeof(exeline), "/proc/%d/exe", pid);
fd = open(exeline, O_RDONLY);
- if(fd == 0) {
+ if (fd == 0) {
printf(" ");
return;
}
r = read(fd, exeline, 5 /* 4 byte ELFMAG + 1 byte EI_CLASS */);
close(fd);
- if(r < 0) {
+ if (r < 0) {
printf(" ");
return;
}
@@ -245,12 +245,12 @@
snprintf(tmp,sizeof(tmp),"/proc/%d/task",pid);
d = opendir(tmp);
- if(d == 0) return;
+ if (d == 0) return;
- while((de = readdir(d)) != 0){
- if(isdigit(de->d_name[0])){
+ while ((de = readdir(d)) != 0) {
+ if (isdigit(de->d_name[0])) {
int tid = atoi(de->d_name);
- if(tid == pid) continue;
+ if (tid == pid) continue;
ps_line(pid, tid);
}
}
@@ -264,24 +264,31 @@
int pidfilter = 0;
int threads = 0;
- while(argc > 1){
- if(!strcmp(argv[1],"-t")) {
+ while (argc > 1) {
+ if (!strcmp(argv[1], "-t")) {
threads = 1;
- } else if(!strcmp(argv[1],"-n")) {
+ } else if (!strcmp(argv[1], "-n")) {
display_flags |= SHOW_NUMERIC_UID;
- } else if(!strcmp(argv[1],"-x")) {
+ } else if (!strcmp(argv[1], "-x")) {
display_flags |= SHOW_TIME;
- } else if(!strcmp(argv[1], "-Z")) {
+ } else if (!strcmp(argv[1], "-Z")) {
display_flags |= SHOW_MACLABEL;
- } else if(!strcmp(argv[1],"-P")) {
+ } else if (!strcmp(argv[1], "-P")) {
display_flags |= SHOW_POLICY;
- } else if(!strcmp(argv[1],"-p")) {
+ } else if (!strcmp(argv[1], "-p")) {
display_flags |= SHOW_PRIO;
- } else if(!strcmp(argv[1],"-c")) {
+ } else if (!strcmp(argv[1], "-c")) {
display_flags |= SHOW_CPU;
- } else if(!strcmp(argv[1],"--abi")) {
+ } else if (!strcmp(argv[1], "--abi")) {
display_flags |= SHOW_ABI;
- } else if(!strcmp(argv[1],"--ppid")) {
+ } else if (!strcmp(argv[1], "--ppid")) {
+ if (argc < 3) {
+ /* Bug 26554285: Use printf because some apps require at least
+ * one line of output to stdout even for errors.
+ */
+ printf("no ppid\n");
+ return 1;
+ }
ppid_filter = atoi(argv[2]);
if (ppid_filter == 0) {
/* Bug 26554285: Use printf because some apps require at least
@@ -317,18 +324,17 @@
(display_flags&SHOW_ABI)?"ABI " : "");
d = opendir("/proc");
- if(d == 0) return -1;
+ if (d == 0) return -1;
- while((de = readdir(d)) != 0){
- if(isdigit(de->d_name[0])){
+ while ((de = readdir(d)) != 0) {
+ if (isdigit(de->d_name[0])) {
int pid = atoi(de->d_name);
- if(!pidfilter || (pidfilter == pid)) {
+ if (!pidfilter || (pidfilter == pid)) {
ps_line(pid, 0);
- if(threads) ps_threads(pid);
+ if (threads) ps_threads(pid);
}
}
}
closedir(d);
return 0;
}
-