Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1079993ybm; Wed, 22 May 2019 17:06:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqyV9m9T1VZMSr3aDl+QL93zVBrVm3FRKeMYa7DluSKmLXOZ1AZxL+UHEy+eAXoQubjVODeU X-Received: by 2002:a62:14d7:: with SMTP id 206mr4686803pfu.73.1558569997884; Wed, 22 May 2019 17:06:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558569997; cv=none; d=google.com; s=arc-20160816; b=m9xAWM2pD03aI+dB1AJfJiiVYWH43DKbjBdK1crAhY7X51HGuv+7I8LEoyJxnJXNHA offuYgmn+G3ZbvyvTu/DBhlV7gjAyPGy5pVtjAuDdZ4zXuNU2HWl2M128POVN+6dNh/a jnzpz9BFJ1M7Oi4Ce0QMscjlwBChmMnxCr27UAYPeIiNT+2b7ABuRsLWVNm+MlcXHsff 9bRJCnhCrZGAVgXzwz0APdfS2+5TybTdITkmWD46yao+p4uP/0x5a5S9mp+gSgSp+Jzv 51NuqB2Xd8gArX1lkGpYCZ0hY463YlDMbZaVfVcXm0V9yCnPsH4BmImUSBPbLkf7q2uF 3rMw== 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=gjdA/WPZRI/WmnmJ7bK/PM0F9xGmC39oAnqxSmmIBEo=; b=qe8CyltSM4Ov8wkGEPjFke0/WxOyInyhtaa9HBAqfsbXSTzEMvHAcQqgXCZ4baZggq RmjFFYsNZCX78jhoiPHtzDdXjTvcmpgW/Q9WcoZqNptqtJB3hT3N1WOfwv0LXVXzi9dv QrzZ+RMTauv66NsD8wuHB97OUBk3qmFCYZ65knzlYHWNpXIb/stCRLKzut9pGKQeSPaW VU8mqUar/tc97HOHgEvDwvO1YDWBuw4W2DfSS9CYmQkEj3Iqp16xj8jRJT7DKOeCLNEO p/NOfkqixD/1eVhFMw7H2RZfRWd+eUfsFqwJWp4lbpSel3jFvRQSsIF/YOXulUOrduUw Zx3A== 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 d34si27743553pld.58.2019.05.22.17.06.23; Wed, 22 May 2019 17:06:37 -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 S1729583AbfEWAD4 (ORCPT + 99 others); Wed, 22 May 2019 20:03:56 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:9693 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726890AbfEWADz (ORCPT ); Wed, 22 May 2019 20:03:55 -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, 22 May 2019 17:03:46 -0700 Received: from rlwimi.localdomain (unknown [10.129.221.32]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 3D9B4B2044; Wed, 22 May 2019 20:03:53 -0400 (EDT) From: Matt Helsley To: LKML CC: Ingo Molnar , Josh Poimboeuf , Peter Zijlstra , Steven Rostedt , Matt Helsley Subject: [RFC][PATCH 02/13] recordmcount: Remove uread() Date: Wed, 22 May 2019 17:03:25 -0700 Message-ID: <9088518b098444d52861a3debcf327c365977476.1558569448.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 7f835059e7c2..30ef6da68e12 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