From patchwork Tue Oct 25 07:24:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 10536 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp857161wru; Tue, 25 Oct 2022 00:25:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Rde3pcKo8pGfO6NJon3Ko11PLuFdEg4pAcYu+diWoS+BkrKTHc8GCWJ+Zq+HGEjgFGHBN X-Received: by 2002:aa7:c78d:0:b0:454:fe1d:8eb1 with SMTP id n13-20020aa7c78d000000b00454fe1d8eb1mr34307267eds.59.1666682709145; Tue, 25 Oct 2022 00:25:09 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id jg18-20020a170907971200b007804f3dafbesi2272476ejc.587.2022.10.25.00.25.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 00:25:09 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=FU6fmXZK; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 7B8533857BBC for ; Tue, 25 Oct 2022 07:25:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7B8533857BBC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666682707; bh=mwhuDxNdqxnFfQ14G7Ad6WKLACKeLiDADn4EpDsZvQk=; 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=FU6fmXZKwHh6ddNSRcJ2SeAfBGYOtB1Id1mbieOyv8QrHDG1mYL6ZaHrLjb6j7KSk BbWYUq7Of3ZU7GfMYEMy5gsZXlV4C6kokvvyDbiDQlESXSC9LLV3g7/Z/Ux/P8JWIn ooML9AQkWbwdYf3w6ofZz5ScORgYPFRCGXeGkHbo= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2045.outbound.protection.outlook.com [40.107.247.45]) by sourceware.org (Postfix) with ESMTPS id 16083385843E for ; Tue, 25 Oct 2022 07:24:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 16083385843E ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AhGdnQUy42Vh3aU0M/zePbDi/oBdruFPTUgnoWKLiU3hUndJj+KSIFPSWmU2/cozAv58DOlIoaEljuPR5CLnGmBXF6OBCXUrNHdNwi+6ntPbpHyOwM2qxcZDkkNQHqwIr12x5UQtZ8mM/G17xGer/ryBedFII2SYAD+avVZVjrFG1870KIBKDYwC3O6pr5/jz1G0yXUsSk12Wx8KECGkOjUjGoibdHkaD42nF63nak89c0OS4SnGyZdRWOJVTF4Qntbra5GgsJHREBQAWh60r8oASeWhBjp4y3YUy+wNEfh4x0FhaCStn0wHYbg6IwgfDgOBgD4+H6xgyEaDIiREFA== 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=mwhuDxNdqxnFfQ14G7Ad6WKLACKeLiDADn4EpDsZvQk=; b=Gav7crHwKwqK2QrUQt88fKjRAcc96GZRT5eC15peA8b+VGmXEIpFXu8UCjgYSkLOljCSa4chKvdM8ccVSqFLs9DI9KSmTNYen4ko4Hg49SXuXGfVpJ/1wDXKBiWO9tUUuYwcPQ8sJ8jF1KXzLkFg9UYvylkQ0Sb6UcVhDZstr5T95gr1jWUjVQgQUGXxYsguV0yN4LFlCDxxfDrl44uBBEKtemmJICFYPB8y/WlLeG/IJtwjC6wG/j9YaXfKraLg9L6c220/sOcl9bn3cr3BiRC7j9dOk+JON9WoeGuNMiN+tbVEBHo/p5Zt4MjGXLoZ9g0LQPnXXIXTUDaCYOQp1g== 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 PA4PR04MB7933.eurprd04.prod.outlook.com (2603:10a6:102:b9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.21; Tue, 25 Oct 2022 07:24:57 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::4da2:ea8b:e71e:b8d8]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::4da2:ea8b:e71e:b8d8%4]) with mapi id 15.20.5746.021; Tue, 25 Oct 2022 07:24:57 +0000 Message-ID: Date: Tue, 25 Oct 2022 09:24:56 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: [PATCH v5 1/8] x86: constify parse_insn()'s input Content-Language: en-US To: Binutils References: In-Reply-To: X-ClientProxiedBy: FR3P281CA0065.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4b::20) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|PA4PR04MB7933:EE_ X-MS-Office365-Filtering-Correlation-Id: 9cbe6df9-1376-4635-c462-08dab65a04ee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: O3nGgnRDYON6WW/nUAWaJkx9eH8KTjYEtP4J/VXfGXNXc+SOPLUVo2Ne4pvrabawu9r0jkX/EtBVmRYMSMGTZaVSDYy/y11vSMpr9S/UJW7qxuNXud60+RqfchnA4TkH0NrzpcGZj9CqQxRswB77aC9Q2vQaIE5fvId5Zprb65CakbpaXPvsJfhzpb0qKK0GwHMtCH7fU/G3ehVsP9ScIw1BJfzVtbav6QshRDCQNJolMrxhOWpd82ct8m0EukVRJGRL+nquAyHruETbnMmZhCsw/dha1vNtCfmqzxrgo4kT6ZoOqqbaRNTriL1nDb7IBCHrY2t5lWoKVDXGzlS1q1alS7YOQFJmz5ZIYQuVgmoizTxILz2SIIRMjP8Vh73S5i3N2EzdhzwZwJXsvhdxWLcv6LxKnSqwwD4O8CYM/M7TrKRHeBsc3tYU/VTSpcoBHLohaM4ZztcjcYt6JcyHw1A3LnaTzthOpnWqkXUbz6fB9ImVBg0GvJbktMfgcoxXe+MubI8LzH3AAcIK532hgAZ1o5IPTFLcFubJ+7TsCQT60QlZuRGV1eUxYceLqg/Sht8uMUZ1EL5okD4jU88ZBRiHx/mcZdUi98+VyV21lj7pIwhTvP8CGY49lRnMF8rfU0swjgLYQQsCjM8fGCPFgmCWiwA+nCAf0qMXK5CEYVGAxtZomUZdAo8BI+dtsRL5vAP0awrTD6fXsxFOKZbvGvwhMpSyN/Wct3XnHFghZMVJS+jWb81ksQeqQJ6K4rJqJmxllssYKO5eyaczilbtgOuuMZhm3Z1NPI5XCTdKp3c= 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)(366004)(376002)(346002)(451199015)(86362001)(316002)(38100700002)(83380400001)(31696002)(6916009)(6512007)(66476007)(41300700001)(26005)(186003)(2616005)(8936002)(5660300002)(2906002)(8676002)(4326008)(66556008)(66946007)(6506007)(36756003)(6486002)(31686004)(478600001)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?u41o2iq5I1ciEqcLBdVkAhB6RQtZ?= =?utf-8?q?hjdJD6JCe8VVS7r3OHjtYBYkXIpAtTYbwUkd8HpfUk7ckGvQ0UA0J11+sg1meMYwv?= =?utf-8?q?Mg92bHS03qUy57TP8/ual7I2r+QYQGkHaQuGrrdk0+w8es1V09CblNz/QBxf8djez?= =?utf-8?q?tL3xKcqibBy5jeNKx2+p+CRDcG46gocj0GfyKtSvb0poF0ufTdYq2HYpWASq9daSl?= =?utf-8?q?H9A4XrYZERVjljAQVGYw/l6a/oN9ygfAfad+pywiS07gNONd1EykEsgTSJdLEbwcp?= =?utf-8?q?RQIasDOd1fbPRkxaebYX3eYrC+0c/GOnwN6CzQTNUlLrp41xCnqFtNsK07fwwUMCi?= =?utf-8?q?IXsKmL6Jd3pQg+Ap8+6zMmOlj8RQevdaTdmzRIOgHS8rF+JJ94/HmtkOSmaJXAsNg?= =?utf-8?q?enMmCMWKDIkm6EH3n91I921XYNVhjEcJ7cfUNPFUPh4QfKpHX6txzRPRbIMFvpVcd?= =?utf-8?q?HX5ec4JP2A7B7NUvEpxCHo0T6NR542izzTjkMSlFG6zLk60hrQZXm7w1YRek6aeqF?= =?utf-8?q?GVt9XTVRDFiucQYelVZyIXr5GLs0uDv4/NDl7tGlc8yUe4iysupqA17GKL1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9XiLSaBDaRklomQq/?= =?utf-8?q?pj2HvHRI+L/jPB97lvDHTq0psNU7y/Sz2LjTWNF8ZYbNRH9I2mOC0S4xuUYikz7fy?= =?utf-8?q?RcdSt9NgAQ1D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9cbe6df9-1376-4635-c462-08dab65a04ee X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2022 07:24:57.3665 (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: Ry4ChgRCjcNaKl4fRy6abtXDAc5ZCx7R2XIWy6oaFKc/nU9rEzZTgrjGWuaT15ZODTZiCyE0RNIRsr9XacFyEQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7933 X-Spam-Status: No, score=-3029.7 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?1747643488317645180?= X-GMAIL-MSGID: =?utf-8?q?1747643488317645180?= 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); @@ -4819,6 +4819,7 @@ md_assemble (char *line) { unsigned int j; char mnemonic[MAX_MNEM_SIZE], mnem_suffix; + const char *end; const insn_template *t; /* Initialize globals. */ @@ -4834,9 +4835,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); @@ -5216,11 +5218,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;