Merge "Replace PATH_MAX usages with smaller size" into main
This commit is contained in:
commit
e1eb315723
16
lmkd.cpp
16
lmkd.cpp
|
|
@ -120,6 +120,8 @@ static inline void trace_kill_end() {}
|
||||||
#define STRINGIFY(x) STRINGIFY_INTERNAL(x)
|
#define STRINGIFY(x) STRINGIFY_INTERNAL(x)
|
||||||
#define STRINGIFY_INTERNAL(x) #x
|
#define STRINGIFY_INTERNAL(x) #x
|
||||||
|
|
||||||
|
#define PROCFS_PATH_MAX 64
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read lmk property with persist.device_config.lmkd_native.<name> overriding ro.lmk.<name>
|
* Read lmk property with persist.device_config.lmkd_native.<name> overriding ro.lmk.<name>
|
||||||
* persist.device_config.lmkd_native.* properties are being set by experiments. If a new property
|
* persist.device_config.lmkd_native.* properties are being set by experiments. If a new property
|
||||||
|
|
@ -1029,11 +1031,11 @@ static inline long get_time_diff_ms(struct timespec *from,
|
||||||
|
|
||||||
/* Reads /proc/pid/status into buf. */
|
/* Reads /proc/pid/status into buf. */
|
||||||
static bool read_proc_status(int pid, char *buf, size_t buf_sz) {
|
static bool read_proc_status(int pid, char *buf, size_t buf_sz) {
|
||||||
char path[PATH_MAX];
|
char path[PROCFS_PATH_MAX];
|
||||||
int fd;
|
int fd;
|
||||||
ssize_t size;
|
ssize_t size;
|
||||||
|
|
||||||
snprintf(path, PATH_MAX, "/proc/%d/status", pid);
|
snprintf(path, PROCFS_PATH_MAX, "/proc/%d/status", pid);
|
||||||
fd = open(path, O_RDONLY | O_CLOEXEC);
|
fd = open(path, O_RDONLY | O_CLOEXEC);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1070,7 +1072,7 @@ static bool parse_status_tag(char *buf, const char *tag, int64_t *out) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int proc_get_size(int pid) {
|
static int proc_get_size(int pid) {
|
||||||
char path[PATH_MAX];
|
char path[PROCFS_PATH_MAX];
|
||||||
char line[LINE_MAX];
|
char line[LINE_MAX];
|
||||||
int fd;
|
int fd;
|
||||||
int rss = 0;
|
int rss = 0;
|
||||||
|
|
@ -1078,7 +1080,7 @@ static int proc_get_size(int pid) {
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
|
||||||
/* gid containing AID_READPROC required */
|
/* gid containing AID_READPROC required */
|
||||||
snprintf(path, PATH_MAX, "/proc/%d/statm", pid);
|
snprintf(path, PROCFS_PATH_MAX, "/proc/%d/statm", pid);
|
||||||
fd = open(path, O_RDONLY | O_CLOEXEC);
|
fd = open(path, O_RDONLY | O_CLOEXEC);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -1096,13 +1098,13 @@ static int proc_get_size(int pid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *proc_get_name(int pid, char *buf, size_t buf_size) {
|
static char *proc_get_name(int pid, char *buf, size_t buf_size) {
|
||||||
char path[PATH_MAX];
|
char path[PROCFS_PATH_MAX];
|
||||||
int fd;
|
int fd;
|
||||||
char *cp;
|
char *cp;
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
|
||||||
/* gid containing AID_READPROC required */
|
/* gid containing AID_READPROC required */
|
||||||
snprintf(path, PATH_MAX, "/proc/%d/cmdline", pid);
|
snprintf(path, PROCFS_PATH_MAX, "/proc/%d/cmdline", pid);
|
||||||
fd = open(path, O_RDONLY | O_CLOEXEC);
|
fd = open(path, O_RDONLY | O_CLOEXEC);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -1124,7 +1126,7 @@ static char *proc_get_name(int pid, char *buf, size_t buf_size) {
|
||||||
|
|
||||||
static void cmd_procprio(LMKD_CTRL_PACKET packet, int field_count, struct ucred *cred) {
|
static void cmd_procprio(LMKD_CTRL_PACKET packet, int field_count, struct ucred *cred) {
|
||||||
struct proc *procp;
|
struct proc *procp;
|
||||||
char path[LINE_MAX];
|
char path[PROCFS_PATH_MAX];
|
||||||
char val[20];
|
char val[20];
|
||||||
int soft_limit_mult;
|
int soft_limit_mult;
|
||||||
struct lmk_procprio params;
|
struct lmk_procprio params;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue