Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10009720ybi; Wed, 24 Jul 2019 14:06:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwRhDMHq7NELu8K4s7m9L2NdUqTurdzLVpEXUMekbIXGxG7m32+8XhaN37vm/k1jH6BdXP7 X-Received: by 2002:a17:902:7612:: with SMTP id k18mr86590154pll.48.1564002381846; Wed, 24 Jul 2019 14:06:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564002381; cv=none; d=google.com; s=arc-20160816; b=LO3msGfE+LJzfVkTp9H+q93RN0wZCv0D+U9D1XoLwbYTnafy1JZjd5l+LjYG9BgS5N 4OUytZzSP9P5p3U4z6Sqx8peFOkw9nIT/W2cJZ2CZgWkyk/HnJW5QMhCAOtoEqpcBCgT a+3yI8J1sJ0K9iEz7UorgKn9il7CPDplYJ37P2sL95X9rFuzZJjSB4imMYDE5bwlFdMJ X7s3//xj/60+XG9cz+UEiopkTnvfdLuom2O9KQDjL7WbE6Uo+lAIdnFuxXvTVbMDZS2S ZGU74vhH77LQyifoS71YOvik1sS05z9qhrcwcMsfmzaFEXpDeCkEfNumBh2ilF8okIba ro7A== 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=Fu7sdJ/jg5POczCTxmpqDIb7XO8cDq0T5CDVxJENLdXXXrB9KO3BYtJR3tUSTL0hxJ UZUCB+bpflyY/PcXxbPzqXnlr7gvvEsi1mv5gEj16EmNs8RMTFXaFCJnJKnXsdNA27Of X4aMFf6Q9Oxl/jT5E/h0lWjYf6zEtabYZobEDG/szJCZ/Ai8r23gpQiQO3jjjhBB1TCs BkLKRK88RoobhHZf9cxHXuTDhnxA9KeQuOWJc4E5VDftJbMnaA6fLp9GkKM5RflRpFrG vGfXkvx4oAYNdOwtAub2S1qoshzgHVw++GquAYntZcUqqj+3gQMqgKQSW6PwEBlyy7mh hYQQ== 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 s128si15805456pfb.207.2019.07.24.14.06.06; Wed, 24 Jul 2019 14:06:21 -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 S2387980AbfGXVF3 (ORCPT + 99 others); Wed, 24 Jul 2019 17:05:29 -0400 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:53151 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387933AbfGXVF0 (ORCPT ); Wed, 24 Jul 2019 17:05:26 -0400 Received: from sc9-mailhost3.vmware.com (10.113.161.73) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Wed, 24 Jul 2019 14:05:05 -0700 Received: from rlwimi.localdomain (unknown [10.166.65.164]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id D379140709; Wed, 24 Jul 2019 14:05:24 -0700 (PDT) From: Matt Helsley To: LKML CC: Ingo Molnar , Josh Poimboeuf , Peter Zijlstra , Steven Rostedt , Matt Helsley Subject: [PATCH v3 02/13] recordmcount: Remove uread() Date: Wed, 24 Jul 2019 14:04:56 -0700 Message-ID: <31a87c22b19150cec1c8dc800c8b0873a2741703.1563992889.git.mhelsley@vmware.com> 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-001.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