Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5222569ybi; Tue, 11 Jun 2019 22:07:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqz7rErDvbJs13zczjmiDve4VEeuXyePI6TPULTDYzQxEty7llphIUusQDVrAi+3CdXq+jn9 X-Received: by 2002:a17:90a:cb97:: with SMTP id a23mr30105352pju.67.1560316026631; Tue, 11 Jun 2019 22:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560316026; cv=none; d=google.com; s=arc-20160816; b=WDyjQ7tox9By75qMo48kyT+jfkxqM/dhtbfPKfiugSeOO5JVUETQXvhLoFCloO4vBH LeoTVL9ZSoTduYum3fBXGjiue0H0ekZMEbw5aaD0JoQezSXwnbdDEq4bFLBQE2a7P8XO LuOOCALPmWxolycYq0aak78QYazAGKKkjTTOW+7/ffTPq+PVdRSmQBHlc2M4AvHGL9Tt 8TdIsutzUJsfcfl54ottSfgsXS6Qbf6go3AbyG0EcKAgyCpCOOuCNfT3iUy6kvHGvw6l H1YLuv2ebutDUHJLIbpkYnhoY57MHIxSAvjgVLS+lZg1FjjKkcO/zGR7+i5lUOpkOebG QEmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=887MOVHYJLaADlpDEgAYiOxMt5ciox++AXOZxg/4QHY=; b=a+UHwT+vx5KbhkuTZ4uFF5LyqRdgv1RdPtiWCtrZnbbk2qDSYrqok9WQfFftteKM8g i4Dbs+rw8vNq/s1oiz8l2p6fzu7rytkaLd4pXI+XZjXZeio+wG5/ZuH2VD7eeapBT9du GnGS/VMCNO/uGgPY3PcxY0BHNJUmNJ4iYbYUiEJbwV0ctB796ikz8nWD/UepRnniFqbq Gvj584G2HHfzXd7PNLHT/dOrz8+yq9/D1473bsU0sUAd8pSJV44rJq+JWZb2ggjKi4BL qvjLjuIrj5EY1LJuQoVPsH1Qp5j6Su9y9kcEYgjn9yzikZOkDXGBqpQYV+QR9NijJe+J +mxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=vmware.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v3si14316346plo.329.2019.06.11.22.06.50; Tue, 11 Jun 2019 22:07:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=vmware.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436928AbfFKWXF (ORCPT + 99 others); Tue, 11 Jun 2019 18:23:05 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:28995 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436797AbfFKWWO (ORCPT ); Tue, 11 Jun 2019 18:22:14 -0400 Received: from sc9-mailhost3.vmware.com (10.113.161.73) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Tue, 11 Jun 2019 15:22:09 -0700 Received: from rlwimi.localdomain (unknown [10.129.220.121]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id C5B4441BAC; Tue, 11 Jun 2019 15:22:12 -0700 (PDT) From: Matt Helsley To: LKML CC: Ingo Molnar , Josh Poimboeuf , Peter Zijlstra , Steven Rostedt , Matt Helsley Subject: [PATCH v2 02/13] recordmcount: Remove uread() Date: Tue, 11 Jun 2019 15:21:44 -0700 Message-ID: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII Received-SPF: None (EX13-EDG-OU-002.vmware.com: mhelsley@vmware.com does not designate permitted sender hosts) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org uread() is only used to initialize the ELF file's pseudo private-memory mapping while uwrite() and ulseek() work within the pseudo-mapping and extend it as necessary. Thus it is not a complementary function to uwrite() and ulseek(). It also makes no sense to do cleanups inside uread() when its only caller, mmap_file(), is doing the relevant allocations and associated initializations. Therefore it's clearer to use a plain read() call to initialize the data in mmap_file() and remove uread(). Signed-off-by: Matt Helsley --- scripts/recordmcount.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c index ebe98c39f3cd..c0dd46344063 100644 --- a/scripts/recordmcount.c +++ b/scripts/recordmcount.c @@ -89,7 +89,7 @@ succeed_file(void) longjmp(jmpenv, SJ_SUCCEED); } -/* ulseek, uread, ...: Check return value for errors. */ +/* ulseek, uwrite, ...: Check return value for errors. */ static off_t ulseek(int const fd, off_t const offset, int const whence) @@ -112,17 +112,6 @@ ulseek(int const fd, off_t const offset, int const whence) return file_ptr - file_map; } -static size_t -uread(int const fd, void *const buf, size_t const count) -{ - size_t const n = read(fd, buf, count); - if (n != count) { - perror("read"); - fail_file(); - } - return n; -} - static size_t uwrite(int const fd, void const *const buf, size_t const count) { @@ -298,7 +287,10 @@ static void *mmap_file(char const *fname) if (file_map == MAP_FAILED) { mmap_failed = 1; file_map = umalloc(sb.st_size); - uread(fd_map, file_map, sb.st_size); + if (read(fd_map, file_map, sb.st_size) != sb.st_size) { + perror(fname); + fail_file(); + } } close(fd_map); -- 2.20.1