Clean up /proc/<pid>/maps sscanfs.

sscanf will swallow whitespace for us.

Change-Id: I59931cbad00f0144fd33ed4749ac0aaad15e6de6
This commit is contained in:
Elliott Hughes
2015-09-22 15:45:50 -07:00
parent efcb5d9d4c
commit 0dec228921
2 changed files with 4 additions and 7 deletions

View File

@@ -1163,9 +1163,9 @@ TEST(pthread, pthread_attr_getstack__main_thread) {
char line[BUFSIZ];
while (fgets(line, sizeof(line), fp) != NULL) {
uintptr_t lo, hi;
char name[10];
sscanf(line, "%" PRIxPTR "-%" PRIxPTR " %*4s %*x %*x:%*x %*d %10s", &lo, &hi, name);
if (strcmp(name, "[stack]") == 0) {
int name_pos;
sscanf(line, "%" PRIxPTR "-%" PRIxPTR " %*4s %*x %*x:%*x %*d %n", &lo, &hi, &name_pos);
if (strcmp(line + name_pos, "[stack]\n") == 0) {
maps_stack_hi = reinterpret_cast<void*>(hi);
break;
}