Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6438539ybi; Wed, 31 Jul 2019 14:30:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaXB8MmYbvKlxuM36Q9yxlzSnKmoe4lE5ApvtbjBnTbmMgb9MPDS+A3+jCdmQkTbn8TtkV X-Received: by 2002:a65:640d:: with SMTP id a13mr114752988pgv.256.1564608652543; Wed, 31 Jul 2019 14:30:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564608652; cv=none; d=google.com; s=arc-20160816; b=I5pqJy/EyS2gNl549kClMwG4Yr5pUJ08ptNscsbi+BH2mvipkgY0zDbVS2BuCRcP8J TZUN244UpKxGm8ZFmucMXvYkLCDvzXmKcfWClrYr/d+u0y7E/IPyyjgLYqhsrsAuX+YY lmCSRrq14dQM92U4Fo1AixbnmSS7AtceVXegafXfOjvS8iU0TZ/i0jRV+RouCvS7aBd6 hr2nfp/byTAXTBR7tSUUCwfirPsvzsipbA5ddC67kU3dF2MbNpIKheVz9CKCJorEZZpU 1+rkrEb/lXiNvz/+nCBccCVq5TJXebi0s/EPdOVA0GNZ34gvxAMqIXVbJ4RAYKMW1ybM e6SA== 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=aaFN8f/6gdLaNk9s87cfULT7az0276TmZwx7Nw3bNzW8sRLmTtvtBEi6qCGKVlCLvv qMgt6m0+OUOyu/Y7c6hpVVWSHOMP8zW3iENSgBQLoWLRnXgxi2jIAAf9cT2YcoiGOod8 TsGnV4BCG0ao+85K7OD6Rq/Igk8K59FuclnO6sLsD+b4XNW7X+MOw0x9Sm1yBVsMYY/h kcffaY6VqQya/eO8gfZmHiT2knx6r/cXsT16ZXdFOVfghH6i2MzlxNIHFqV7G5xbuHiI e6PBGkTstB9koei+15nrvWlN3hyEL+rRguqU/D6W+tsTrU9d/JxcY1BCD1lAvsfXmmHB NlYA== 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 i9si31130512plt.387.2019.07.31.14.30.37; Wed, 31 Jul 2019 14:30:52 -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 S1729762AbfGaSYn (ORCPT + 99 others); Wed, 31 Jul 2019 14:24:43 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:7789 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726469AbfGaSYk (ORCPT ); Wed, 31 Jul 2019 14:24:40 -0400 Received: from sc9-mailhost2.vmware.com (10.113.161.72) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Wed, 31 Jul 2019 11:24:34 -0700 Received: from rlwimi.localdomain (unknown [10.166.66.112]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id B4F53B2841; Wed, 31 Jul 2019 14:24:37 -0400 (EDT) From: Matt Helsley To: LKML CC: Ingo Molnar , Steven Rostedt , Matt Helsley Subject: [PATCH v4 2/8] recordmcount: Remove uread() Date: Wed, 31 Jul 2019 11:24:10 -0700 Message-ID: <31a87c22b19150cec1c8dc800c8b0873a2741703.1564596289.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-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