Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5222542ybi; Tue, 11 Jun 2019 22:07:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxzaNpmxCg7nKPRL9Hvq7h14YvpxG/X5F4CHMjNlFFe8z720AmqHRTYwdbjC18a4bbce97C X-Received: by 2002:aa7:9407:: with SMTP id x7mr41842355pfo.163.1560316023846; Tue, 11 Jun 2019 22:07:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560316023; cv=none; d=google.com; s=arc-20160816; b=0CAV5LOXH+diSyUcMWw+k6CJWEJQVpW7u/Tz5Q5U1Dqlk8EnHhzEAY8l1lYfK9uqXJ U7LnsVFhqKKkAS3jEGoGM5iBCH2BgIMZjWbwWJ8DwsBE/1Fhphqef8518Wlq2JdghkDs 5cXoGIBlgmkjtdP+qZqQ+0+OWUZ9cJjvmbkODBYFGRwgnYTOVC8CcAw0SQp6T3myARvv dhlJvGj/VL5ywI+hFU1VNvNXz1u+w1sLUgSbNfbG/UuBIbXFmA6CONRMyv9uBL8EO77c NNYjgkrDbU/y50AVtRFAXdtrfZYHORxDx705ImNg1sAYAFjo17b8QDF4YNKqPSUqZgVT iQSQ== 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=7iZBwU6zWD8cHxfRXPH6fm/o5GtxnYloOFQNwt8+IFU=; b=KNR73Aza09QfTgmFqSGLMM3HS/qOnFteRR4MHTOQo/fJnCdQuPEJTk0n3tT+buhORT C7Eqz3r/sqC8hSUAyvG9GMNZqJWrzyse2FDWK9wYPmILthkh3r//meE9AcQxG9QnGfa4 TUOPBYu9FnnSPV2prLmUCZuAF9bzlNadQi7uPbBz9Qp74j8OLL5KcF5rLbqeTAMUuGc7 oyWFankt9/eeew8bNPhlz63KjA+/69nMdL+qTS/oMcZc+d9nVtoDxvY9UpKX89KIpHAj qhqBotvbtrj+EvqS5cY1i3jdg0qA8LzgefmddMM3UkHbt3cWO/kb5/LiOwN4tBdyqRO1 RNNw== 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 d23si4247323pjw.37.2019.06.11.22.06.46; Tue, 11 Jun 2019 22:07:03 -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 S2436827AbfFKWXA (ORCPT + 99 others); Tue, 11 Jun 2019 18:23:00 -0400 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:3288 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436801AbfFKWWP (ORCPT ); Tue, 11 Jun 2019 18:22:15 -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; Tue, 11 Jun 2019 15:22:07 -0700 Received: from rlwimi.localdomain (unknown [10.129.220.121]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 721C241BB0; Tue, 11 Jun 2019 15:22:13 -0700 (PDT) From: Matt Helsley To: LKML CC: Ingo Molnar , Josh Poimboeuf , Peter Zijlstra , Steven Rostedt , Matt Helsley Subject: [PATCH v2 03/13] recordmcount: Remove unused fd from uwrite() and ulseek() Date: Tue, 11 Jun 2019 15:21:45 -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-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 uwrite() works within the pseudo-mapping and extends it as necessary without needing the file descriptor (fd) parameter passed to it. Similarly, ulseek() doesn't need its fd parameter. These parameters were only added because the functions bear a conceptual resemblance to write() and lseek(). Worse, they obscure the fact that at the time uwrite() and ulseek() are called fd_map is not a valid file descriptor. Remove the unused file descriptor parameters that make it look like fd_map is still valid. Signed-off-by: Matt Helsley --- scripts/recordmcount.c | 16 ++++++++-------- scripts/recordmcount.h | 26 +++++++++++++------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c index c0dd46344063..1fe5fba99959 100644 --- a/scripts/recordmcount.c +++ b/scripts/recordmcount.c @@ -92,7 +92,7 @@ succeed_file(void) /* ulseek, uwrite, ...: Check return value for errors. */ static off_t -ulseek(int const fd, off_t const offset, int const whence) +ulseek(off_t const offset, int const whence) { switch (whence) { case SEEK_SET: @@ -113,7 +113,7 @@ ulseek(int const fd, off_t const offset, int const whence) } static size_t -uwrite(int const fd, void const *const buf, size_t const count) +uwrite(void const *const buf, size_t const count) { size_t cnt = count; off_t idx = 0; @@ -183,8 +183,8 @@ static int make_nop_x86(void *map, size_t const offset) return -1; /* convert to nop */ - ulseek(fd_map, offset - 1, SEEK_SET); - uwrite(fd_map, ideal_nop, 5); + ulseek(offset - 1, SEEK_SET); + uwrite(ideal_nop, 5); return 0; } @@ -232,10 +232,10 @@ static int make_nop_arm(void *map, size_t const offset) return -1; /* Convert to nop */ - ulseek(fd_map, off, SEEK_SET); + ulseek(off, SEEK_SET); do { - uwrite(fd_map, ideal_nop, nop_size); + uwrite(ideal_nop, nop_size); } while (--cnt > 0); return 0; @@ -252,8 +252,8 @@ static int make_nop_arm64(void *map, size_t const offset) return -1; /* Convert to nop */ - ulseek(fd_map, offset, SEEK_SET); - uwrite(fd_map, ideal_nop, 4); + ulseek(offset, SEEK_SET); + uwrite(ideal_nop, 4); return 0; } diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h index 13c5e6c8829c..690fa86ded59 100644 --- a/scripts/recordmcount.h +++ b/scripts/recordmcount.h @@ -202,14 +202,14 @@ static void append_func(Elf_Ehdr *const ehdr, new_e_shoff = t; /* body for new shstrtab */ - ulseek(fd_map, sb.st_size, SEEK_SET); - uwrite(fd_map, old_shstr_sh_offset + (void *)ehdr, old_shstr_sh_size); - uwrite(fd_map, mc_name, 1 + strlen(mc_name)); + ulseek(sb.st_size, SEEK_SET); + uwrite(old_shstr_sh_offset + (void *)ehdr, old_shstr_sh_size); + uwrite(mc_name, 1 + strlen(mc_name)); /* old(modified) Elf_Shdr table, word-byte aligned */ - ulseek(fd_map, t, SEEK_SET); + ulseek(t, SEEK_SET); t += sizeof(Elf_Shdr) * old_shnum; - uwrite(fd_map, old_shoff + (void *)ehdr, + uwrite(old_shoff + (void *)ehdr, sizeof(Elf_Shdr) * old_shnum); /* new sections __mcount_loc and .rel__mcount_loc */ @@ -225,7 +225,7 @@ static void append_func(Elf_Ehdr *const ehdr, mcsec.sh_info = 0; mcsec.sh_addralign = _w(_size); mcsec.sh_entsize = _w(_size); - uwrite(fd_map, &mcsec, sizeof(mcsec)); + uwrite(&mcsec, sizeof(mcsec)); mcsec.sh_name = w(old_shstr_sh_size); mcsec.sh_type = (sizeof(Elf_Rela) == rel_entsize) @@ -239,15 +239,15 @@ static void append_func(Elf_Ehdr *const ehdr, mcsec.sh_info = w(old_shnum); mcsec.sh_addralign = _w(_size); mcsec.sh_entsize = _w(rel_entsize); - uwrite(fd_map, &mcsec, sizeof(mcsec)); + uwrite(&mcsec, sizeof(mcsec)); - uwrite(fd_map, mloc0, (void *)mlocp - (void *)mloc0); - uwrite(fd_map, mrel0, (void *)mrelp - (void *)mrel0); + uwrite(mloc0, (void *)mlocp - (void *)mloc0); + uwrite(mrel0, (void *)mrelp - (void *)mrel0); ehdr->e_shoff = _w(new_e_shoff); ehdr->e_shnum = w2(2 + w2(ehdr->e_shnum)); /* {.rel,}__mcount_loc */ - ulseek(fd_map, 0, SEEK_SET); - uwrite(fd_map, ehdr, sizeof(*ehdr)); + ulseek(0, SEEK_SET); + uwrite(ehdr, sizeof(*ehdr)); } static unsigned get_mcountsym(Elf_Sym const *const sym0, @@ -395,8 +395,8 @@ static void nop_mcount(Elf_Shdr const *const relhdr, Elf_Rel rel; rel = *(Elf_Rel *)relp; Elf_r_info(&rel, Elf_r_sym(relp), rel_type_nop); - ulseek(fd_map, (void *)relp - (void *)ehdr, SEEK_SET); - uwrite(fd_map, &rel, sizeof(rel)); + ulseek((void *)relp - (void *)ehdr, SEEK_SET); + uwrite(&rel, sizeof(rel)); } relp = (Elf_Rel const *)(rel_entsize + (void *)relp); } -- 2.20.1