Merge "Replace PATH_MAX usages with smaller size" into main am: e1eb315723

Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/3072843

Change-Id: I213c3f0ef714c337032d418d24b0b4811cfb0ef1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot 2024-05-03 00:47:25 +00:00 committed by Automerger Merge Worker
commit 79b31d8bd1
1 changed files with 9 additions and 7 deletions

View File

@ -120,6 +120,8 @@ static inline void trace_kill_end() {}
#define STRINGIFY(x) STRINGIFY_INTERNAL(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>
* 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. */
static bool read_proc_status(int pid, char *buf, size_t buf_sz) {
char path[PATH_MAX];
char path[PROCFS_PATH_MAX];
int fd;
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);
if (fd < 0) {
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) {
char path[PATH_MAX];
char path[PROCFS_PATH_MAX];
char line[LINE_MAX];
int fd;
int rss = 0;
@ -1078,7 +1080,7 @@ static int proc_get_size(int pid) {
ssize_t ret;
/* 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);
if (fd == -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) {
char path[PATH_MAX];
char path[PROCFS_PATH_MAX];
int fd;
char *cp;
ssize_t ret;
/* 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);
if (fd == -1) {
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) {
struct proc *procp;
char path[LINE_MAX];
char path[PROCFS_PATH_MAX];
char val[20];
int soft_limit_mult;
struct lmk_procprio params;