Fix clang build by removing unused locals.
Also don't manually set FD_CLOEXEC on a socket that's always opened
with SOCK_CLOEXEC. (None of the other callers to the function do this.)
Also move locals to where they're first used to help prevent more of this
kind of breakage.
Change-Id: I1ba7cd9400f53508dffb51a2bbf9d491ae647f26
diff --git a/init/devices.cpp b/init/devices.cpp
index c32eb4f..1fa70ec 100644
--- a/init/devices.cpp
+++ b/init/devices.cpp
@@ -983,12 +983,7 @@
}
}
-void device_init(void)
-{
- suseconds_t t0, t1;
- struct stat info;
- int fd;
-
+void device_init() {
sehandle = NULL;
if (is_selinux_enabled() > 0) {
sehandle = selinux_android_file_context_handle();
@@ -1000,16 +995,15 @@
if(device_fd < 0)
return;
- fcntl(device_fd, F_SETFD, FD_CLOEXEC);
fcntl(device_fd, F_SETFL, O_NONBLOCK);
+ struct stat info;
if (stat(COLDBOOT_DONE, &info) < 0) {
Timer t;
coldboot("/sys/class");
coldboot("/sys/block");
coldboot("/sys/devices");
- fd = open(COLDBOOT_DONE, O_WRONLY|O_CREAT|O_CLOEXEC, 0000);
- close(fd);
+ close(open(COLDBOOT_DONE, O_WRONLY|O_CREAT|O_CLOEXEC, 0000));
NOTICE("Coldboot took %.2fs.\n", t.duration());
} else {
NOTICE("Skipping coldboot, already done!\n");