Commit 02d7d31a authored by Dev Jain's avatar Dev Jain Committed by Andrew Morton

selftests/mm: parse VMA range in one go

Use sscanf() to directly parse the VMA range. No functional change is intended.

Link: https://lkml.kernel.org/r/20240322120551.818764-1-dev.jain@arm.comSigned-off-by: default avatarDev Jain <dev.jain@arm.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 353dc187
...@@ -20,8 +20,6 @@ static int get_vm_area(unsigned long addr, struct vm_boundaries *area) ...@@ -20,8 +20,6 @@ static int get_vm_area(unsigned long addr, struct vm_boundaries *area)
FILE *file; FILE *file;
int ret = 1; int ret = 1;
char line[1024] = {0}; char line[1024] = {0};
char *end_addr;
char *stop;
unsigned long start; unsigned long start;
unsigned long end; unsigned long end;
...@@ -37,21 +35,10 @@ static int get_vm_area(unsigned long addr, struct vm_boundaries *area) ...@@ -37,21 +35,10 @@ static int get_vm_area(unsigned long addr, struct vm_boundaries *area)
memset(area, 0, sizeof(struct vm_boundaries)); memset(area, 0, sizeof(struct vm_boundaries));
while(fgets(line, 1024, file)) { while(fgets(line, 1024, file)) {
end_addr = strchr(line, '-'); if (sscanf(line, "%lx-%lx", &start, &end) != 2) {
if (!end_addr) {
ksft_print_msg("cannot parse /proc/self/maps\n"); ksft_print_msg("cannot parse /proc/self/maps\n");
goto out; goto out;
} }
*end_addr = '\0';
end_addr++;
stop = strchr(end_addr, ' ');
if (!stop) {
ksft_print_msg("cannot parse /proc/self/maps\n");
goto out;
}
sscanf(line, "%lx", &start);
sscanf(end_addr, "%lx", &end);
if (start <= addr && end > addr) { if (start <= addr && end > addr) {
area->start = start; area->start = start;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment