From patchwork Sat Nov 23 13:27:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 180089 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp735982ilf; Sat, 23 Nov 2019 05:28:22 -0800 (PST) X-Google-Smtp-Source: APXvYqyRotFCibTfEb/bm73vRbWir3N1eOw++5xFCfuF7by1d7yCYQGSgAknBTKyegxSsX48Dg9K X-Received: by 2002:a17:906:b6c3:: with SMTP id ec3mr28098955ejb.27.1574515702238; Sat, 23 Nov 2019 05:28:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574515702; cv=none; d=google.com; s=arc-20160816; b=t7qABxxbYLZU8e4+QXvkuiKAptyzKhp0vGXXHkEbK16ipAJ/y89BvQ/9bOPgGb8Wuj pO4JHIyM5OsNNGIA6HwhmJE0p0apoccA65bt4f1RnNrvIVvi8HEvp+1wC760EXncuzeh BjfOd9UQzrtguVgmxNXXAEhT2PjP6oJxH4qdTIMiiQ78HA26S0ZARxlUSoD+Vz68oEqz 4WAEt2fs/jpm+YYfcsAp4M9sQWNpRVd+avxxAaKKdCXZ68NqcxUlhQ1MoW/V1iUfPYOz 7m3rgw3dBYAFYpeV3/feZljf4rWNdZgDokeghrR47+fjFoxUpIN1PXzb3CPh1UzJhZ74 oGCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=A1pH5sFWnicqKcGRYR3bGaguX1Aj6aoTLBQi/Wtt0iA=; b=W61RJJzCH60+6LZksuJeZL5nE+SqI8P2ilz7aoQ+H2AkbSIVp0bkVdk4EVQ7STxhe4 vxI4cS5YGn/gxx9wvwzQoOEbg2xmEK4RDnTEobZQuUIgocPO6vx1k6Nd7Tf258J8m9OY cdEKbXyNn5n5FNTLs2CQB7gRHMkvrft4Q2Uo2JnZkJRQHY1qEB2M3QJ6ufypGK0Ednqx Vu9yhf0l1VSoHmH0hqHtDd5t6G2xBLWdvTg9by5Sc2DrABeXzT03WmSr4U0FsVKl7yy5 ErhmNYg1vPT0aTsbNELaWX40Orw10AB5KP2BJxZQiOc4pOh8mVdgMIqbCYUtSJmj8xOx ou9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=OugDC2Ik; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12si764070edy.41.2019.11.23.05.28.22; Sat, 23 Nov 2019 05:28:22 -0800 (PST) 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; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=OugDC2Ik; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727095AbfKWN2T (ORCPT + 26 others); Sat, 23 Nov 2019 08:28:19 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:39540 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726784AbfKWN2B (ORCPT ); Sat, 23 Nov 2019 08:28:01 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-10.nifty.com with ESMTP id xANDRbki000733; Sat, 23 Nov 2019 22:27:42 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com xANDRbki000733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574515663; bh=A1pH5sFWnicqKcGRYR3bGaguX1Aj6aoTLBQi/Wtt0iA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OugDC2IkWj5dXOoQuC/L+F79/gvUzPwpxJyjnzD6xvV3KTS92nxGNS3atPMmCzanc ENMo/QgrCGu/Yc4KaGWo0qz8KIdWVXjVshT+RL2uQVSAT42s4Zux2T2huq3IXFdBSa 4+Z5HlMTlLvaHEJRVqYCmVPgRzxyFrGJAr+mK4DXQzBI0pXYMV7LgXvlLHYk+IpJS3 TuM4qfTtmrvKM807YZwZXMFvn9PfHdBNrSFlUkhs+6I9sIC5JP2mn3RcugGYKn/isx J/YZMMsYmyK0EOLRxwSyXZOc7xmok5PPlgy1sQaYIbKDaIIuxYbxdsySLjpXEf6KZ+ TTfmHd0Sf1mCw== X-Nifty-SrcIP: [126.93.102.113] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 09/16] scripts/kallsyms: add const qualifiers where possible Date: Sat, 23 Nov 2019 22:27:20 +0900 Message-Id: <20191123132727.30151-10-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123132727.30151-1-yamada.masahiro@socionext.com> References: <20191123132727.30151-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add 'const' where a function does not write to the pointer dereferenes. Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) -- 2.17.1 diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index c4f7f20ecfb7..d745fd2c7247 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -170,11 +170,11 @@ static int read_symbol(FILE *in, struct sym_entry *s) return 0; } -static int symbol_in_range(struct sym_entry *s, struct addr_range *ranges, - int entries) +static int symbol_in_range(const struct sym_entry *s, + const struct addr_range *ranges, int entries) { size_t i; - struct addr_range *ar; + const struct addr_range *ar; for (i = 0; i < entries; ++i) { ar = &ranges[i]; @@ -186,14 +186,14 @@ static int symbol_in_range(struct sym_entry *s, struct addr_range *ranges, return 0; } -static int symbol_valid(struct sym_entry *s) +static int symbol_valid(const struct sym_entry *s) { /* Symbols which vary between passes. Passes 1 and 2 must have * identical symbol lists. The kallsyms_* symbols below are only added * after pass 1, they would be included in pass 2 when --all-symbols is * specified so exclude them to get a stable symbol list. */ - static char *special_symbols[] = { + static const char * const special_symbols[] = { "kallsyms_addresses", "kallsyms_offsets", "kallsyms_relative_base", @@ -208,12 +208,12 @@ static int symbol_valid(struct sym_entry *s) "_SDA2_BASE_", /* ppc */ NULL }; - static char *special_prefixes[] = { + static const char * const special_prefixes[] = { "__crc_", /* modversions */ "__efistub_", /* arm64 EFI stub namespace */ NULL }; - static char *special_suffixes[] = { + static const char * const special_suffixes[] = { "_veneer", /* arm */ "_from_arm", /* arm */ "_from_thumb", /* arm */ @@ -281,7 +281,7 @@ static void read_map(FILE *in) } } -static void output_label(char *label) +static void output_label(const char *label) { printf(".globl %s\n", label); printf("\tALGN\n"); @@ -290,7 +290,7 @@ static void output_label(char *label) /* uncompress a compressed symbol. When this function is called, the best table * might still be compressed itself, so the function needs to be recursive */ -static int expand_symbol(unsigned char *data, int len, char *result) +static int expand_symbol(const unsigned char *data, int len, char *result) { int c, rlen, total=0; @@ -315,7 +315,7 @@ static int expand_symbol(unsigned char *data, int len, char *result) return total; } -static int symbol_absolute(struct sym_entry *s) +static int symbol_absolute(const struct sym_entry *s) { return s->percpu_absolute; } @@ -453,7 +453,7 @@ static void write_src(void) /* table lookup compression functions */ /* count all the possible tokens in a symbol */ -static void learn_symbol(unsigned char *symbol, int len) +static void learn_symbol(const unsigned char *symbol, int len) { int i; @@ -462,7 +462,7 @@ static void learn_symbol(unsigned char *symbol, int len) } /* decrease the count for all the possible tokens in a symbol */ -static void forget_symbol(unsigned char *symbol, int len) +static void forget_symbol(const unsigned char *symbol, int len) { int i; @@ -490,7 +490,7 @@ static void build_initial_tok_table(void) } static unsigned char *find_token(unsigned char *str, int len, - unsigned char *token) + const unsigned char *token) { int i; @@ -503,7 +503,7 @@ static unsigned char *find_token(unsigned char *str, int len, /* replace a given token in all the valid symbols. Use the sampled symbols * to update the counts */ -static void compress_symbols(unsigned char *str, int idx) +static void compress_symbols(const unsigned char *str, int idx) { unsigned int i, len, size; unsigned char *p1, *p2;