Merge "Remove LogMessage::LogLineLowStack."
diff --git a/base/CPPLINT.cfg b/base/CPPLINT.cfg
index a61c08d..d94a89c 100644
--- a/base/CPPLINT.cfg
+++ b/base/CPPLINT.cfg
@@ -1,2 +1,2 @@
set noparent
-filter=-build/header_guard,-build/include,-build/c++11
+filter=-build/header_guard,-build/include,-build/c++11,-whitespace/operators
diff --git a/include/cutils/sockets.h b/include/cutils/sockets.h
index c47588c..f8076ca 100644
--- a/include/cutils/sockets.h
+++ b/include/cutils/sockets.h
@@ -18,6 +18,7 @@
#define __CUTILS_SOCKETS_H
#include <errno.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
@@ -46,30 +47,19 @@
*/
static inline int android_get_control_socket(const char *name)
{
- char key[64] = ANDROID_SOCKET_ENV_PREFIX;
- const char *val;
- int fd;
+ char key[64];
+ snprintf(key, sizeof(key), ANDROID_SOCKET_ENV_PREFIX "%s", name);
- /* build our environment variable, counting cycles like a wolf ... */
-#if HAVE_STRLCPY
- strlcpy(key + sizeof(ANDROID_SOCKET_ENV_PREFIX) - 1,
- name,
- sizeof(key) - sizeof(ANDROID_SOCKET_ENV_PREFIX));
-#else /* for the host, which may lack the almightly strncpy ... */
- strncpy(key + sizeof(ANDROID_SOCKET_ENV_PREFIX) - 1,
- name,
- sizeof(key) - sizeof(ANDROID_SOCKET_ENV_PREFIX));
- key[sizeof(key)-1] = '\0';
-#endif
-
- val = getenv(key);
- if (!val)
+ const char* val = getenv(key);
+ if (!val) {
return -1;
+ }
errno = 0;
- fd = strtol(val, NULL, 10);
- if (errno)
+ int fd = strtol(val, NULL, 10);
+ if (errno) {
return -1;
+ }
return fd;
}
diff --git a/toolbox/Android.mk b/toolbox/Android.mk
index ff001a8..186a89f 100644
--- a/toolbox/Android.mk
+++ b/toolbox/Android.mk
@@ -60,7 +60,6 @@
start \
stop \
top \
- umount \
uptime \
watchprops \
diff --git a/toolbox/umount.c b/toolbox/umount.c
deleted file mode 100644
index 3e17396..0000000
--- a/toolbox/umount.c
+++ /dev/null
@@ -1,90 +0,0 @@
-
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <linux/loop.h>
-#include <errno.h>
-
-#define LOOPDEV_MAXLEN 64
-#define LOOP_MAJOR 7
-
-static int is_loop(char *dev)
-{
- struct stat st;
- int ret = 0;
-
- if (stat(dev, &st) == 0) {
- if (S_ISBLK(st.st_mode) && (major(st.st_rdev) == LOOP_MAJOR)) {
- ret = 1;
- }
- }
-
- return ret;
-}
-
-static int is_loop_mount(const char* path, char *loopdev)
-{
- FILE* f;
- int count;
- char device[256];
- char mount_path[256];
- char rest[256];
- int result = 0;
-
- f = fopen("/proc/mounts", "r");
- if (!f) {
- fprintf(stdout, "could not open /proc/mounts: %s\n", strerror(errno));
- return -1;
- }
-
- do {
- count = fscanf(f, "%255s %255s %255s\n", device, mount_path, rest);
- if (count == 3) {
- if (is_loop(device) && strcmp(path, mount_path) == 0) {
- strlcpy(loopdev, device, LOOPDEV_MAXLEN);
- result = 1;
- break;
- }
- }
- } while (count == 3);
-
- fclose(f);
- return result;
-}
-
-int umount_main(int argc, char *argv[])
-{
- int loop, loop_fd;
- char loopdev[LOOPDEV_MAXLEN];
-
- if(argc != 2) {
- fprintf(stderr,"umount <path>\n");
- return 1;
- }
-
- loop = is_loop_mount(argv[1], loopdev);
- if (umount(argv[1])) {
- fprintf(stderr, "failed: %s\n", strerror(errno));
- return 1;
- }
-
- if (loop) {
- // free the loop device
- loop_fd = open(loopdev, O_RDONLY);
- if (loop_fd < 0) {
- fprintf(stderr, "open loop device failed: %s\n", strerror(errno));
- return 1;
- }
- if (ioctl(loop_fd, LOOP_CLR_FD, 0) < 0) {
- fprintf(stderr, "ioctl LOOP_CLR_FD failed: %s\n", strerror(errno));
- return 1;
- }
-
- close(loop_fd);
- }
-
- return 0;
-}