From patchwork Wed Oct 5 07:20:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 1712 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp473900wrs; Wed, 5 Oct 2022 00:21:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7fgbljHws7AlPm38XW2hzHQXQzKuEf0SZBqquq0pXybzcanA2XBiD968s0KvlA0+/ik8gx X-Received: by 2002:a17:907:1dd9:b0:77a:341b:88cb with SMTP id og25-20020a1709071dd900b0077a341b88cbmr22628502ejc.753.1664954505826; Wed, 05 Oct 2022 00:21:45 -0700 (PDT) Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id r24-20020a170906549800b00741757d62adsi11804410ejo.993.2022.10.05.00.21.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 00:21:45 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=djQQPjIP; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 41E8E3858005 for ; Wed, 5 Oct 2022 07:21:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 41E8E3858005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664954504; bh=RtSJnUVRppuZ6XK+Qu/A6Fp5nzWhqEYNnSRHovHBytI=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=djQQPjIPDpeqyXWLFbv7yaM0ZFu17jTx0/JdfZYfyWFXuIYp+kflvmSRhE89YDOaB 04dZMz5DgJ77q1o/WIDr9h6CTqBjpDTNWx/ouo8rfmt/Ks0qjXUAGiXQblzo52hE8O GLlqx6tq4snv6HsEUcGvov1F3mMbwmKInShop4lE= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150057.outbound.protection.outlook.com [40.107.15.57]) by sourceware.org (Postfix) with ESMTPS id 414A73858D37 for ; Wed, 5 Oct 2022 07:20:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 414A73858D37 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XUynDFu+ssS+DFykQo4bpRjoJirGHkZzk/dnt/D0nuy8C+BoK9j0PNXSWbbFfxoLjDLv86IxmX0ISM5MgQ+JHagOrE9IUlkcGbvzcbaLBIFXLvWHIxciUDZPVHEjCkpuTslhi1O6r2jrj9jnu0EYksFOz+4d++m+jBMLOVaBczgxD0iNTDWGHaviz0+Q8HkPpDkifzq4n6KkcFpCbGqaqXX0/4vfSvxc1WkVIbV6eOVKImyUVcs55aBG73oFbhGSf8HlXW28vugoMptQET04xGUIoi5XLiZBlj633DijeptnjNVZwtRRsCNO/ZuG9FFQgbJLtWsI79rOs1ROKYRMhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RtSJnUVRppuZ6XK+Qu/A6Fp5nzWhqEYNnSRHovHBytI=; b=UOm14aFjEmPd302xKft/NDhjfAJBDASrFv7iNaSEx2MzTQ3a9TCYA2L1zBcaNr3Dgw/9GAlU+85POMX4r8VkLa/beNiX3OpBuxoqGWDoRz6P/tdpDWA03/xa66+cY5Ce7LX0p6JirwiW9VNyqtbuL1U2LSnkmuVBbRGpcxWT52PjQKG9u67Rk8yYn00OwIqhm7lODHP1tkE5AhpT7WLFz7DOLqx6cPrXb9eX/6oE72ZoJOlk85m6cECxFhUQOEXFvwuVNWA68D8pZbvXFy9POmHl7QqeGzoqxbBJvK5frkb30F5Z6W+m03X4IJp4ffzswXK4D9wdLgDBZyPMn3l05w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by PA4PR04MB8047.eurprd04.prod.outlook.com (2603:10a6:102:cf::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.26; Wed, 5 Oct 2022 07:20:48 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2459:15ae:e6cb:218a]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2459:15ae:e6cb:218a%7]) with mapi id 15.20.5676.031; Wed, 5 Oct 2022 07:20:48 +0000 Message-ID: <02d747d2-f57b-0fb5-b893-842b6cc41f2f@suse.com> Date: Wed, 5 Oct 2022 09:20:47 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: [PATCH v3 1/7] x86: constify parse_insn()'s input Content-Language: en-US To: Binutils References: <20e2773a-2e47-869b-1900-709f8ad4cd6b@suse.com> In-Reply-To: <20e2773a-2e47-869b-1900-709f8ad4cd6b@suse.com> X-ClientProxiedBy: FR0P281CA0115.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a8::14) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|PA4PR04MB8047:EE_ X-MS-Office365-Filtering-Correlation-Id: f2a23b6e-ffdb-45b6-5e51-08daa6a22029 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ArgTd4OOmkb6L1AMnEMGCBVtazVIEQnKbAwrmvOMdJXpG6in74XuKrbF7l0WTxZW0CGm0lHT2weeIzlWdLQSNCao0qYevsSZCrJtd4Cp8/J9ZTQ8QWPCpWawprtzIC30rIwMxQOt4koJM6wEQXn0Cn3bjpfdzmZ6MKvYT1QRQKMMakNOGSwEL5etwJiIJWzJE2aaKGHKRDkjQluZGdSXrBbLUFuobcmfSX1gx5tZ36Dt+SB9QYaDKibKBY4iDof4zkD77NhbCmIS3sTdM4cvk4ysK1NbUvc032SJ6DGCCHZ68HJl7tYhjC1/LQ5CxsIXKeA5hdUpmMR5N7Mu/wDELqHU0jAtXs+YNf24s2z5MTRJhDhWx4VZpDY/EfD/QjyT5espbYr7VIXFaxjdu6UCfeutmfSyQeH78NQqu1aysare4HFFyhKcs0P/IG2IWSJH7J6ZCN/kdcBSpSzIkUcHVa2g4PhRbmmw5a220cn6BTu9mFPVBhq2uo/8fV30KWqKPDnELGayW36pUvOEDLhiq5YHHdJvEM5N3WdsI67vHD6Lz8GsnRDvUTZHYJxsw0tm7+7ZOY4IrraV61n6qYq6GqsHp7q8IRxDfG/CeqQ1jaIskR1AcTKKHiJxpXrW4Nm9SgDOmvQwdgu0EQKsDgtR3jfCBFbRlEDbKl6qTlvhO4j8XTLg3kU/6wncmOib2AawrnlR6rXASSmsRtUlAvY5FnDPZT58trodpC8QZQm8ZgZBOfSt2cBKGXaBt8eZkeao5PQ2zBGMuhc/PezY8jva13QMjsf00nUZidFkmqASZM4= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR04MB6560.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(39860400002)(396003)(136003)(346002)(366004)(376002)(451199015)(2906002)(38100700002)(316002)(478600001)(6506007)(6916009)(26005)(36756003)(41300700001)(6512007)(186003)(6486002)(31696002)(2616005)(86362001)(5660300002)(66556008)(66476007)(8936002)(31686004)(66946007)(4326008)(83380400001)(8676002)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?z2J6CnevZk6OLtbuhe8Ra61qhLhA?= =?utf-8?q?HC2ROgzGzRuUfs/o3uKbCw3HhoonChIOl9Hanj1h30557Pk/hY9fWze0Jdmm8BoUB?= =?utf-8?q?K3EQ4uSih5kDHsaZIYNNPdDFpIj7SEtAZDDQwSXvvBNSmBtLDZuQoQXMbtKkcYBa+?= =?utf-8?q?57KrSEaq7oAO6I+XhAcIePtIJFv1/mMZfqwuJSkvi+c1Swd+5v9IUMnTz9E+27IAz?= =?utf-8?q?03QsHvuzXUXTRJYtEm4zGxk7zlxyz3B5qcHxYe+2ekYByjLYdiw3KdAEvv74MNSHU?= =?utf-8?q?6rFJrT8c0FoYeN/begCGGEhMVGnQ1xjDDlpiDksHAbeu05FWaBiMnkRTVAnRYGng6?= =?utf-8?q?b3ATTRU1MVe1+3A7jsGVGzSLMSJaIPCvKo7qxkIlHFg2bC6wZHE1rZFj5uHjL0JaT?= =?utf-8?q?JNACP55Q/WIZWd8tsvttmcCgX/za9ksB+PlX2/OnY3qvPws93f1P5MJU7LuBi9BFy?= =?utf-8?q?7+4n5vKDAvOs5jAa/rclHk2qzCo1aHYEl6SJJCN2I8B73PfaJKrHkHTue/rK+BKVY?= =?utf-8?q?wm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J7enPxSTgzca44Q2gs6bf4qXQBtUX+BjVdzmBV2aU2inPKTMqH4J?= =?utf-8?q?FgQxIXYOHGyJvObDO1BpCd/E4ZW4YtMPNvYNR2ECkMUKsncuK2L0iqgIgUAnU0L6w?= =?utf-8?q?SCExUE1nB9Fs?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2a23b6e-ffdb-45b6-5e51-08daa6a22029 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 07:20:48.2403 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fOUWoLq8idwisX8GdaJPNiRdUzJ7hM/RvGt2x2X97HGnMUbMDffd0jKVeBDQZXfVd5mJbLGi+IbL5ZMlfGXTZQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB8047 X-Spam-Status: No, score=-3029.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jan Beulich via Binutils From: Jan Beulich Reply-To: Jan Beulich Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1745831335966673835?= X-GMAIL-MSGID: =?utf-8?q?1745831335966673835?= The function doesn't alter its input buffer: Reflect this in its prototype. To avoid using any kind of cast, simply calculate the update of "line" from the function's input and output. --- Avoiding a cast the way it's done here is going to be useful in subsequent patches (there'll be code added between the call and the update of "line"), so switching to a cast is not really an option. --- v3: New. --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -157,7 +157,7 @@ static int i386_intel_operand (char *, i static int i386_intel_simplify (expressionS *); static int i386_intel_parse_name (const char *, expressionS *); static const reg_entry *parse_register (char *, char **); -static char *parse_insn (char *, char *); +static const char *parse_insn (const char *, char *); static char *parse_operands (char *, const char *); static void swap_operands (void); static void swap_2_operands (unsigned int, unsigned int); @@ -4820,6 +4820,7 @@ md_assemble (char *line) { unsigned int j; char mnemonic[MAX_MNEM_SIZE], mnem_suffix; + const char *end; const insn_template *t; /* Initialize globals. */ @@ -4835,9 +4836,10 @@ md_assemble (char *line) We assume that the scrubber has arranged it so that line[0] is the valid start of a (possibly prefixed) mnemonic. */ - line = parse_insn (line, mnemonic); - if (line == NULL) + end = parse_insn (line, mnemonic); + if (end == NULL) return; + line += end - line; mnem_suffix = i.suffix; line = parse_operands (line, mnemonic); @@ -5217,11 +5219,10 @@ md_assemble (char *line) last_insn.kind = last_insn_other; } -static char * -parse_insn (char *line, char *mnemonic) +static const char * +parse_insn (const char *line, char *mnemonic) { - char *l = line; - char *token_start = l; + const char *l = line, *token_start = l; char *mnem_p; int supported; const insn_template *t;