am aec43a12: Merge "Use TEMP_FAILURE_RETRY, always build bootchart.cpp."

* commit 'aec43a12a76160e924fc0af9b131bd385cf7a60c':
  Use TEMP_FAILURE_RETRY, always build bootchart.cpp.
This commit is contained in:
Elliott Hughes 2015-02-04 18:45:23 +00:00 committed by Android Git Automerger
commit f86b0496b5
6 changed files with 25 additions and 70 deletions

View File

@ -4,6 +4,7 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
bootchart.cpp \
builtins.cpp \
devices.cpp \
init.cpp \
@ -17,13 +18,14 @@ LOCAL_SRC_FILES:= \
util.cpp \
watchdogd.cpp \
#LOCAL_CLANG := true
LOCAL_CPPFLAGS += \
-Wall \
-Wall -Wextra \
-Werror -Wno-error=deprecated-declarations \
-Wno-unused-parameter \
ifeq ($(strip $(INIT_BOOTCHART)),true)
LOCAL_SRC_FILES += bootchart.cpp
LOCAL_CPPFLAGS += -DBOOTCHART=1
endif

View File

@ -20,20 +20,17 @@
* some C code that is run right from the init script.
*/
#include <stdio.h>
#include <time.h>
#include "bootchart.h"
#include <dirent.h>
#include <unistd.h>
#include <fcntl.h>
#include <unistd.h>
#include <fcntl.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include "bootchart.h"
#include <time.h>
#include <unistd.h>
#define VERSION "0.8"
#define SAMPLE_PERIOD 0.2
@ -47,29 +44,13 @@
#define LOG_STARTFILE "/data/bootchart-start"
#define LOG_STOPFILE "/data/bootchart-stop"
static int
unix_read(int fd, void* buff, int len)
{
int ret;
do { ret = read(fd, buff, len); } while (ret < 0 && errno == EINTR);
return ret;
}
static int
unix_write(int fd, const void* buff, int len)
{
int ret;
do { ret = write(fd, buff, len); } while (ret < 0 && errno == EINTR);
return ret;
}
static int
proc_read(const char* filename, char* buff, size_t buffsize)
{
int len = 0;
int fd = open(filename, O_RDONLY | O_CLOEXEC);
if (fd >= 0) {
len = unix_read(fd, buff, buffsize-1);
len = TEMP_FAILURE_RETRY(read(fd, buff, buffsize-1));
close(fd);
}
buff[len > 0 ? len : 0] = 0;
@ -105,7 +86,7 @@ file_buff_write( FileBuff buff, const void* src, int len )
buff->count += avail;
if (buff->count == FILE_BUFF_SIZE) {
unix_write( buff->fd, buff->data, buff->count );
TEMP_FAILURE_RETRY(write(buff->fd, buff->data, buff->count));
buff->count = 0;
}
}
@ -115,7 +96,7 @@ static void
file_buff_done( FileBuff buff )
{
if (buff->count > 0) {
unix_write( buff->fd, buff->data, buff->count );
TEMP_FAILURE_RETRY(write(buff->fd, buff->data, buff->count));
buff->count = 0;
}
}
@ -170,23 +151,6 @@ log_header(void)
fclose(out);
}
static void
open_log_file(int* plogfd, const char* logfile)
{
int logfd = *plogfd;
/* create log file if needed */
if (logfd < 0)
{
logfd = open(logfile,O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC,0755);
if (logfd < 0) {
*plogfd = -2;
return;
}
*plogfd = logfd;
}
}
static void
do_log_uptime(FileBuff log)
{
@ -217,8 +181,7 @@ do_log_file(FileBuff log, const char* procfile)
fd = open(procfile,O_RDONLY|O_CLOEXEC);
if (fd >= 0) {
for (;;) {
int ret;
ret = unix_read(fd, buff, sizeof(buff));
int ret = TEMP_FAILURE_RETRY(read(fd, buff, sizeof(buff)));
if (ret <= 0)
break;
@ -259,7 +222,7 @@ do_log_procs(FileBuff log)
snprintf(filename,sizeof(filename),"/proc/%d/stat",pid);
fd = open(filename,O_RDONLY|O_CLOEXEC);
if (fd >= 0) {
len = unix_read(fd, buff, sizeof(buff)-1);
len = TEMP_FAILURE_RETRY(read(fd, buff, sizeof(buff)-1));
close(fd);
if (len > 0) {
int len2 = strlen(cmdline);
@ -325,7 +288,7 @@ int bootchart_init( void )
count = (timeout*1000 + BOOTCHART_POLLING_MS-1)/BOOTCHART_POLLING_MS;
do {ret=mkdir(LOG_ROOT,0755);}while (ret < 0 && errno == EINTR);
ret = TEMP_FAILURE_RETRY(mkdir(LOG_ROOT,0755));
file_buff_open(log_stat, LOG_STAT);
file_buff_open(log_procs, LOG_PROCS);

View File

@ -21,17 +21,13 @@
# define BOOTCHART 0
#endif
#if BOOTCHART
extern int bootchart_init(void);
extern int bootchart_step(void);
extern void bootchart_finish(void);
extern long long bootchart_gettime(void);
# define BOOTCHART_POLLING_MS 200 /* polling period in ms */
# define BOOTCHART_DEFAULT_TIME_SEC (2*60) /* default polling time in seconds */
# define BOOTCHART_MAX_TIME_SEC (10*60) /* max polling time in seconds */
#endif /* BOOTCHART */
#define BOOTCHART_POLLING_MS 200 /* polling period in ms */
#define BOOTCHART_DEFAULT_TIME_SEC (2*60) /* default polling time in seconds */
#define BOOTCHART_MAX_TIME_SEC (10*60) /* max polling time in seconds */
#endif /* _BOOTCHART_H */

View File

@ -67,9 +67,7 @@ static int write_file(const char *path, const char *value)
len = strlen(value);
do {
ret = write(fd, value, len);
} while (ret < 0 && errno == EINTR);
ret = TEMP_FAILURE_RETRY(write(fd, value, len));
close(fd);
if (ret < 0) {
@ -132,7 +130,7 @@ static int __ifupdown(const char *interface, int up)
ifr.ifr_flags &= ~IFF_UP;
ret = ioctl(s, SIOCSIFFLAGS, &ifr);
done:
close(s);
return ret;
@ -735,7 +733,7 @@ int do_sysclktz(int nargs, char **args)
return -1;
memset(&tz, 0, sizeof(tz));
tz.tz_minuteswest = atoi(args[1]);
tz.tz_minuteswest = atoi(args[1]);
if (settimeofday(NULL, &tz))
return -1;
return 0;
@ -768,7 +766,7 @@ int do_copy(int nargs, char **args)
if (nargs != 3)
return -1;
if (stat(args[1], &info) < 0)
if (stat(args[1], &info) < 0)
return -1;
if ((fd1 = open(args[1], O_RDONLY|O_CLOEXEC)) < 0)

View File

@ -43,7 +43,6 @@ static void sigchld_handler(int s)
static int wait_for_one_process(int block)
{
pid_t pid;
int status;
struct service *svc;
struct socketinfo *si;
@ -51,7 +50,7 @@ static int wait_for_one_process(int block)
struct listnode *node;
struct command *cmd;
while ( (pid = waitpid(-1, &status, block ? 0 : WNOHANG)) == -1 && errno == EINTR );
pid_t pid = TEMP_FAILURE_RETRY(waitpid(-1, &status, block ? 0 : WNOHANG));
if (pid <= 0) return -1;
INFO("waitpid returned pid %d, status = %08x\n", pid, status);

View File

@ -431,10 +431,7 @@ void get_hardware_name(char *hardware, unsigned int *revision) {
hardware[n] = 0;
}
} else if (strncmp(buf, "Revision", 8) == 0) {
const char* rev = strstr(buf, ": ");
if (rev) {
*revision = strtoul(rev + 2, 0, 16);
}
sscanf(buf, "Revision : %ux", revision);
}
}
fclose(fp);