Loading debuggerd/getevent.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include <sys/poll.h> #include <linux/input.h> #include <errno.h> #include <memory> #include <cutils/log.h> static struct pollfd* ufds; Loading Loading @@ -143,22 +144,20 @@ static int read_notify(const char* dirname, int nfd) { static int scan_dir(const char* dirname) { char devname[PATH_MAX]; char* filename; DIR* dir; struct dirent* de; dir = opendir(dirname); std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(dirname), closedir); if (dir == NULL) return -1; strcpy(devname, dirname); filename = devname + strlen(devname); *filename++ = '/'; while ((de = readdir(dir))) { while ((de = readdir(dir.get()))) { if ((de->d_name[0] == '.' && de->d_name[1] == '\0') || (de->d_name[1] == '.' && de->d_name[2] == '\0')) continue; strcpy(filename, de->d_name); open_device(devname); } closedir(dir); return 0; } Loading fastboot/usb_linux.cpp +3 −5 Original line number Diff line number Diff line Loading @@ -333,15 +333,14 @@ static std::unique_ptr<usb_handle> find_usb_device(const char* base, ifc_match_f char desc[1024]; int n, in, out, ifc; DIR *busdir; struct dirent *de; int fd; int writable; busdir = opendir(base); std::unique_ptr<DIR, decltype(&closedir)> busdir(opendir(base), closedir); if (busdir == 0) return 0; while ((de = readdir(busdir)) && (usb == nullptr)) { while ((de = readdir(busdir.get())) && (usb == nullptr)) { if (badname(de->d_name)) continue; if (!convert_to_devfs_name(de->d_name, devname, sizeof(devname))) { Loading Loading @@ -377,7 +376,6 @@ static std::unique_ptr<usb_handle> find_usb_device(const char* base, ifc_match_f } } } closedir(busdir); return usb; } Loading healthd/BatteryMonitor.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include <stdlib.h> #include <sys/types.h> #include <unistd.h> #include <memory> #include <batteryservice/BatteryService.h> #include <cutils/klog.h> Loading Loading @@ -456,13 +457,13 @@ void BatteryMonitor::init(struct healthd_config *hc) { char pval[PROPERTY_VALUE_MAX]; mHealthdConfig = hc; DIR* dir = opendir(POWER_SUPPLY_SYSFS_PATH); std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(POWER_SUPPLY_SYSFS_PATH), closedir); if (dir == NULL) { KLOG_ERROR(LOG_TAG, "Could not open %s\n", POWER_SUPPLY_SYSFS_PATH); } else { struct dirent* entry; while ((entry = readdir(dir))) { while ((entry = readdir(dir.get()))) { const char* name = entry->d_name; if (!strcmp(name, ".") || !strcmp(name, "..")) Loading Loading @@ -600,7 +601,6 @@ void BatteryMonitor::init(struct healthd_config *hc) { break; } } closedir(dir); } // This indicates that there is no charger driver registered. Loading init/devices.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ #include <sys/un.h> #include <linux/netlink.h> #include <memory> #include <selinux/selinux.h> #include <selinux/label.h> #include <selinux/android.h> Loading Loading @@ -957,10 +959,9 @@ static void do_coldboot(DIR *d) static void coldboot(const char *path) { DIR *d = opendir(path); std::unique_ptr<DIR, decltype(&closedir)> d(opendir(path), closedir); if(d) { do_coldboot(d); closedir(d); do_coldboot(d.get()); } } Loading libbacktrace/backtrace_test.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -404,17 +404,16 @@ void GetThreads(pid_t pid, std::vector<pid_t>* threads) { char task_path[128]; snprintf(task_path, sizeof(task_path), "/proc/%d/task", pid); DIR* tasks_dir = opendir(task_path); std::unique_ptr<DIR, decltype(&closedir)> tasks_dir(opendir(task_path), closedir); ASSERT_TRUE(tasks_dir != nullptr); struct dirent* entry; while ((entry = readdir(tasks_dir)) != nullptr) { while ((entry = readdir(tasks_dir.get())) != nullptr) { char* end; pid_t tid = strtoul(entry->d_name, &end, 10); if (*end == '\0') { threads->push_back(tid); } } closedir(tasks_dir); } TEST(libbacktrace, ptrace_threads) { Loading Loading
debuggerd/getevent.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include <sys/poll.h> #include <linux/input.h> #include <errno.h> #include <memory> #include <cutils/log.h> static struct pollfd* ufds; Loading Loading @@ -143,22 +144,20 @@ static int read_notify(const char* dirname, int nfd) { static int scan_dir(const char* dirname) { char devname[PATH_MAX]; char* filename; DIR* dir; struct dirent* de; dir = opendir(dirname); std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(dirname), closedir); if (dir == NULL) return -1; strcpy(devname, dirname); filename = devname + strlen(devname); *filename++ = '/'; while ((de = readdir(dir))) { while ((de = readdir(dir.get()))) { if ((de->d_name[0] == '.' && de->d_name[1] == '\0') || (de->d_name[1] == '.' && de->d_name[2] == '\0')) continue; strcpy(filename, de->d_name); open_device(devname); } closedir(dir); return 0; } Loading
fastboot/usb_linux.cpp +3 −5 Original line number Diff line number Diff line Loading @@ -333,15 +333,14 @@ static std::unique_ptr<usb_handle> find_usb_device(const char* base, ifc_match_f char desc[1024]; int n, in, out, ifc; DIR *busdir; struct dirent *de; int fd; int writable; busdir = opendir(base); std::unique_ptr<DIR, decltype(&closedir)> busdir(opendir(base), closedir); if (busdir == 0) return 0; while ((de = readdir(busdir)) && (usb == nullptr)) { while ((de = readdir(busdir.get())) && (usb == nullptr)) { if (badname(de->d_name)) continue; if (!convert_to_devfs_name(de->d_name, devname, sizeof(devname))) { Loading Loading @@ -377,7 +376,6 @@ static std::unique_ptr<usb_handle> find_usb_device(const char* base, ifc_match_f } } } closedir(busdir); return usb; } Loading
healthd/BatteryMonitor.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include <stdlib.h> #include <sys/types.h> #include <unistd.h> #include <memory> #include <batteryservice/BatteryService.h> #include <cutils/klog.h> Loading Loading @@ -456,13 +457,13 @@ void BatteryMonitor::init(struct healthd_config *hc) { char pval[PROPERTY_VALUE_MAX]; mHealthdConfig = hc; DIR* dir = opendir(POWER_SUPPLY_SYSFS_PATH); std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(POWER_SUPPLY_SYSFS_PATH), closedir); if (dir == NULL) { KLOG_ERROR(LOG_TAG, "Could not open %s\n", POWER_SUPPLY_SYSFS_PATH); } else { struct dirent* entry; while ((entry = readdir(dir))) { while ((entry = readdir(dir.get()))) { const char* name = entry->d_name; if (!strcmp(name, ".") || !strcmp(name, "..")) Loading Loading @@ -600,7 +601,6 @@ void BatteryMonitor::init(struct healthd_config *hc) { break; } } closedir(dir); } // This indicates that there is no charger driver registered. Loading
init/devices.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ #include <sys/un.h> #include <linux/netlink.h> #include <memory> #include <selinux/selinux.h> #include <selinux/label.h> #include <selinux/android.h> Loading Loading @@ -957,10 +959,9 @@ static void do_coldboot(DIR *d) static void coldboot(const char *path) { DIR *d = opendir(path); std::unique_ptr<DIR, decltype(&closedir)> d(opendir(path), closedir); if(d) { do_coldboot(d); closedir(d); do_coldboot(d.get()); } } Loading
libbacktrace/backtrace_test.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -404,17 +404,16 @@ void GetThreads(pid_t pid, std::vector<pid_t>* threads) { char task_path[128]; snprintf(task_path, sizeof(task_path), "/proc/%d/task", pid); DIR* tasks_dir = opendir(task_path); std::unique_ptr<DIR, decltype(&closedir)> tasks_dir(opendir(task_path), closedir); ASSERT_TRUE(tasks_dir != nullptr); struct dirent* entry; while ((entry = readdir(tasks_dir)) != nullptr) { while ((entry = readdir(tasks_dir.get())) != nullptr) { char* end; pid_t tid = strtoul(entry->d_name, &end, 10); if (*end == '\0') { threads->push_back(tid); } } closedir(tasks_dir); } TEST(libbacktrace, ptrace_threads) { Loading