From patchwork Fri Mar 22 12:05:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dev Jain X-Patchwork-Id: 13600022 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44DF0C47DD9 for ; Fri, 22 Mar 2024 12:06:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A81876B007B; Fri, 22 Mar 2024 08:06:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A107C6B0082; Fri, 22 Mar 2024 08:06:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D22E6B0083; Fri, 22 Mar 2024 08:06:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 79AE16B007B for ; Fri, 22 Mar 2024 08:06:58 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3C5CC1202BB for ; Fri, 22 Mar 2024 12:06:58 +0000 (UTC) X-FDA: 81924548916.13.54B1DD7 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf20.hostedemail.com (Postfix) with ESMTP id 8D0B51C0012 for ; Fri, 22 Mar 2024 12:06:56 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of dev.jain@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=dev.jain@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711109216; a=rsa-sha256; cv=none; b=gXcCfX8TWtOxqzZVBEV1p5gFzEqnK4+l6aUuVNM04XDOwWHrBPsyuphkTBsYBZYJg7urab 7Tj2AzaCv/mRZqUucFANvOasxHbFCrp8x5aDFWcjmOZtiXfZpr/j5+CbmbBG+069B5fQO9 HL216GzJ0kKINkKLNM9X/9AHHGOEVRM= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of dev.jain@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=dev.jain@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711109216; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=wCq2FE60V3pV/yhvm3uWH0CfUPLEIb+P6hzLkArCEKw=; b=mSmGpAVkS3IGbBKt5ljyhUky/d9LfvOvEDxqN0aBKSo3cJWir93xvCA8U8Eavzz1lFgRzb YvzRLuAs4sP2ATdTmOHqkmjCtYPrfP3hxBB7mZKmxawBItAvk6VFNgCwFp26e2Ke30TGqr 10Fx3rcIejHW0LEre5FVHhtpVtoKPmQ= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 816911007; Fri, 22 Mar 2024 05:07:29 -0700 (PDT) Received: from e116581.blr.arm.com (e116581.arm.com [10.162.40.23]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A8D813F67D; Fri, 22 Mar 2024 05:06:52 -0700 (PDT) From: Dev Jain To: akpm@linux-foundation.org, shuah@kernel.org Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Anshuman.Khandual@arm.com, Dev Jain Subject: [PATCH] selftests/mm: Parse VMA range in one go Date: Fri, 22 Mar 2024 17:35:51 +0530 Message-Id: <20240322120551.818764-1-dev.jain@arm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 8D0B51C0012 X-Stat-Signature: ddu5eezi65ambeqib7wxez5hfqwuumib X-HE-Tag: 1711109216-47340 X-HE-Meta: U2FsdGVkX1+xLbvYW55Rc2l0eiahXtpyGIVEjYqGS76sD3XjOS2lCWoG3imge0gZLwPDQKK7ZGRNrrN3Y2wFtd0RqEwvNcS/LGtQj4Q7Yt2tVOODrUYJKtJzAvyL4vv52bMXc4Hm1UHtl5tyd8plQU9LRtdWA7Ga7f1ofGmPB+t25lm4QGh61fghgkQR4PKBH+UdaomsBuR4XvQg3H0mqp002DcHDKK4k3GO+RIj/JVRDiuTiCAWDJbxZ2jgDLzqR5PJF+egfoxtBCUHn9bBLmMSRg+t9EenWwCCEqIbjYLGKF9jsot6cVtfVNjv2aHRpe1XqN5yj9suqWZueMI6k3cOL9UcaLfuHBNRYbZrsEdfzcDJwksCbnmBGwuHVHmlQebbgEn7SUfW/US3kZGsVtqI+CdzTkeNG2Ssr8xVcXrinbJ4q7s3GWMvnb6/D/+WkB9CxTHF8DiHbTWDDXM8dA/eiqRjtqNSzvUgu+RrdgqTWAi6pZm3Kxus38iKEaPbiS1ZNpqbkzPhP8HTxK/53cspaiLvajCYGUjyBj9DjiHLSTX4ToWBQHQJVxE6/1PpEmxPcNd6/YTMJ+MffqE+B9C72WTN/VriJaQcEnZKOiiDzD8bOvsUE80fsEmyjctxN7J1XVBvn42a5JAjb6ZDmOBKLibAWgLRmEt3FnqvAwkmGEzW6/faZtMpmEVwiEXX/1g3NF8UznYulWc/BIwEvVC4msrboiD5icBTNiIVmiFCntuWXSJ0AVgoNHFp4nN6dTfWrOlbBrN5L/IqDE3wGqu8ciT2UJ+zbPJhyqmmDSbSxMBSrLOmjA7GbPgtDj1J23vXwUE4N6UvZ12fvXka068wLOE8QotM X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Use sscanf() to directly parse the VMA range. No functional change is intended. Signed-off-by: Dev Jain --- tools/testing/selftests/mm/mlock2-tests.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/tools/testing/selftests/mm/mlock2-tests.c b/tools/testing/selftests/mm/mlock2-tests.c index 26f744188ad0..7f0d50fa361d 100644 --- a/tools/testing/selftests/mm/mlock2-tests.c +++ b/tools/testing/selftests/mm/mlock2-tests.c @@ -20,8 +20,6 @@ static int get_vm_area(unsigned long addr, struct vm_boundaries *area) FILE *file; int ret = 1; char line[1024] = {0}; - char *end_addr; - char *stop; unsigned long start; unsigned long end; @@ -37,21 +35,10 @@ static int get_vm_area(unsigned long addr, struct vm_boundaries *area) memset(area, 0, sizeof(struct vm_boundaries)); while(fgets(line, 1024, file)) { - end_addr = strchr(line, '-'); - if (!end_addr) { + if (sscanf(line, "%lx-%lx", &start, &end) != 2) { ksft_print_msg("cannot parse /proc/self/maps\n"); 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) { area->start = start;