Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1078803lqp; Fri, 22 Mar 2024 05:12:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU9BEzsCWd7t2Fp+PlNbWiFUs4QjBVk4yRR1dqWUsqUiDuyjwXJ4VwWDWA7GBCKr0QdnvrvfqpYFgaQtsLXjxgaYujIRCWCmEbZTEvKoQ== X-Google-Smtp-Source: AGHT+IGlgJx36QUsxCGme4tWk+HIyXxpZ6/B5Bd7UV929FG6YEyD7CADQxk3ugPLwN/YGDkjA+kO X-Received: by 2002:a05:6a00:3a19:b0:6ea:7468:1f31 with SMTP id fj25-20020a056a003a1900b006ea74681f31mr2567851pfb.30.1711109572963; Fri, 22 Mar 2024 05:12:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711109572; cv=pass; d=google.com; s=arc-20160816; b=mQa0fzLvjUxvrV6Zk1mi7l2BNzedmWTRhhqLTAy7wSgyDsYArsndFWeYkUAP2sc6zR 3bmQwgUIh/B2LZ4G6fdRDEotiRHxh5459zcQM4NWrpLUrziAiWh8xNv8y3FA2OM8mU+a Ffrr9CpzfIko5wIN2qwqIK4w/l+kMr7TKz5SAb3s5W3VB4D/rFWyXkYWkFNmY4ge3d18 Q0Kvz/eBNFrfD7jRRIyXKYEA8nHWIlwY4k9F7YPJ7ynI7YtQwGY3evKqKJBbFgppEPr0 Ajs8ahxjiQbGRZf63xz3yaxU4a0zFE+BdnUOT70sK2HM7+ZcTx75aHIHVOdeqv+B9FNV cp9Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=wCq2FE60V3pV/yhvm3uWH0CfUPLEIb+P6hzLkArCEKw=; fh=sjxBMbigrgKUzplA8V3gIjRPqs2fwVVyor1W+PgO1Zk=; b=oGaTT7pQZdhWsFIdulduiam2MC2iRuJluDBm17CpnOxDse4rU/VICVd8OhKH4j+MdV tzZzwC3H2UERI6OIGWZ6Ex7Tcn3V9/0W6VtxbvKmfHgEFocEAXBUgMNEP1SSMrMYGm0n H4j/OPOXrMK2R8UEDSqOWmgVMFDDpyIq2NF0kjLv22RIe4q7J2x2PmjRxGdT8TRV4daK 0aGEwHkcjbcu43F+pZaK3mI0Q+a1/gnjJzo4qOaIDv67ZWEbfvZ+1M17jTvKon6b2n7q 5Z0ndvDWxsOHllueKeuEmS5L4jm/QrqNNZy+Pyd2I623vviGH5SkadrKiflnaogr8Zf0 fByA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-111402-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111402-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id u34-20020a634562000000b005cdacf9065fsi1845110pgk.720.2024.03.22.05.12.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 05:12:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111402-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-111402-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111402-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id F105DB23667 for ; Fri, 22 Mar 2024 12:07:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 990083FBB2; Fri, 22 Mar 2024 12:07:01 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 51DD03FB04; Fri, 22 Mar 2024 12:06:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711109221; cv=none; b=tSNf612exYox8HGXR6i1uLsrUDcR98zA/igDVfNHGMF2AuQ0i3nAUroRg1kjQ7Ff/IrP0liSIkM6BlV7k1eBQHR6i/D5tK18unUmKeJ+7Rmod2GV8nSKB1khjuRUCAiowUOX0rH16vddY3RbBm0Rr8+NxXL4JBXAxgy2nK0QVg4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711109221; c=relaxed/simple; bh=bthc13dk1gLvIK9FTpWxxjgtBBe4ubu8K3uAhfkPPkY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=EAcAiaMUzqWltf2Ejmjby6Lb2q8Zz58v1/AZ/7ZMR2h08RgvrDY4YcpBoENLzxdhla59T0yKsSd9sTTX0ahNLl9GvbBBqUIwkPC7AknCDY/CLqoEOCovlqlW/01ZODIl5fDEMp+xRJTIP7UxGcImgqeDvPy5rn5PSqQG+J200u4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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; -- 2.34.1