From patchwork Fri Nov 4 10:50:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 15465 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp316894wru; Fri, 4 Nov 2022 03:51:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4OhFuTnF78xDq0qt6Kdsn6peH6uRT1RT894EsE2sFINu2VBrvoBvD/JMEaYNJiyNA3MS2r X-Received: by 2002:a05:6402:754:b0:463:67da:3dc with SMTP id p20-20020a056402075400b0046367da03dcmr25775935edy.386.1667559071361; Fri, 04 Nov 2022 03:51:11 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id bb6-20020a1709070a0600b007835897050esi5221396ejc.404.2022.11.04.03.51.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 03:51:11 -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=DGG64TUD; 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 5D2623858288 for ; Fri, 4 Nov 2022 10:51:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5D2623858288 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667559070; bh=87IFQvyu4nCd7AsTCbao7eH5zSQH8HLcIOiQeYvwxmY=; 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=DGG64TUDxR9qfASnMqfdSwes1Dyr0c7MWZMb1B/9n4Nf8hpUPL960Cn5nDEDR+BvZ QCZpqrhOQ2GfCY/M69sZ9lUioJK+XXzjxpz7d3K8iGvDkvego5NJMf21L9cRQNpPiC v7ZvcqAzqHlYEk8h2w+E+TqVE/QZeZvd9lCYXyeM= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2066.outbound.protection.outlook.com [40.107.22.66]) by sourceware.org (Postfix) with ESMTPS id 4FEB33858425 for ; Fri, 4 Nov 2022 10:50:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4FEB33858425 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BFpTMWynwd8XquHyK+VYHK4AEY8G0jH1hgkh94btv+BR7QklEHQHlc++aDPRDKUoHUrpVmpQBmBgvJLbz8KoaXeZv0V7VuyPT8HGcg9EYLbu+0UqDBm/4NpiewcevMeWQeyiwlPJRX8saK6U0t7ZOFTk/Q9Y/tcVcDzgSjThj4JafK+wH8EG7Lhe2BUJXujkk/wGgExjfX8VRLDZtu5aG5NJzkgI2KN21XZDThGt7PYGXsdrNxqnKwiBwd0PDtIWAed3qxO84xVrXOebRckStar9/D8zIBC363ZIY8ZauWipYvdk6Dzi7lLoXuu4LBvru90s3TA/ZpA6ft4ULE9VVQ== 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=87IFQvyu4nCd7AsTCbao7eH5zSQH8HLcIOiQeYvwxmY=; b=Jw31ej8Ma7tI0JLTlkE6sU26WNoZ0ig53nRMeDAWXGqUkTnNVsvDCCZ0Fr2a+2NZxtM1/CP2RLshgQ4QqnT+aHpxHvYYvOgAbqxSn9kqvctUjspUF1mAfqjFnbbyf8LKp2JY8s8HTbRKouiGCQHpcQg0whaCrDRN5BjioAiWhOJ63rIW3jtbxJCDda8gdrIoU6w7zfVs05y0xxmh9/TjcIXAwC+SSs5f62oaBBNSUkQ20j5QCcPhDYpFI4uqJJu+6ePdQt9gmX43fhPwC/P5g41+ND7ByTOH7EZwsEDkB5YWx8yHXaorhvfaDa54R2iP5cyVoFUsfPx7b4wkNkr0sw== 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 DB9PR04MB8378.eurprd04.prod.outlook.com (2603:10a6:10:25f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.22; Fri, 4 Nov 2022 10:50:40 +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.5791.022; Fri, 4 Nov 2022 10:50:40 +0000 Message-ID: <926e5154-b40b-9df8-d770-a8bf7d40e40e@suse.com> Date: Fri, 4 Nov 2022 11:50:38 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: [PATCH v6 1/7] x86: constify parse_insn()'s input Content-Language: en-US To: Binutils References: <6d71dc80-91c8-7bc8-c57f-4f771ca59fab@suse.com> In-Reply-To: <6d71dc80-91c8-7bc8-c57f-4f771ca59fab@suse.com> X-ClientProxiedBy: FR3P281CA0087.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1f::9) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|DB9PR04MB8378:EE_ X-MS-Office365-Filtering-Correlation-Id: e1d773b0-8d5b-4ac7-0246-08dabe5269fa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 50rEFy2MXopln8Kbk+9qnudnKeBLn0J9I8TBINq0ZS/7fkBP7ZnVy3c1RC/DOkrrU5A9VT6tIxLeMHvL9WqY2nDk9LMsdFxy7QVEvcBluwaX+Io5WqAfy+rFySuhTc5DQLokd8u9n/jipuSLvOfjG3pTfV4LXDPjx+ov/D7BDWk6XprmIjA/tZii5s4JQADcq5RTT9inQl9gfT4nqkcxNguy14FOF8dgm0GEy2Vwv2VKO3ZT2BcOZp7CneVrKZqogFSU/DTx4nwrdGFsn/g00Juk3A1ETDtafxndfMAbYDxPjcVQsNVEUNIS2evh6VHXfI/nNNPeZ7aSduQU2prOjKFLXnAgx49uuhSxUqYQ8NqTy+WKUB2W0imDKqgWjIoyNql7XkNioh2EsuV4ToU5TWy1v7l8DvGTZNV13BksQ25GDomvc1mG3RCdBFAS0BpWhE2VadPgPEPjeXvu9IgTDRgY2Ted/9/jgKWuXP5+zTIUhC5KJqH/jOJ/faLY5+dtkZJuFxK2dUI9FgBBRMfN/2gqWfbkZ4E/UoEOZgMm4H4udG19mNqCEvCgr/3v26jgST9kLK48rSyISd0GVudBYkmEhQa73Y620T+IchyluZfv4a3CEmEigWIUxxzMfRhou5LDG7TRHaj8AJM8go7eK6LCHFnatEgnN+peIyDA5YhQGISwiZ9fSi4OQgfoN2JQn+Pd4bk0nnMdXS6fRbpaeyxpNlNKJiKEXaChZsh0ngZtGL8kDdRB1qrfj12iFND6ivuT/9Md77kckdIAbfQ6FVTCazV8X+T3ZOgJOfYG2Yk= 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)(346002)(366004)(39860400002)(136003)(396003)(376002)(451199015)(36756003)(31696002)(86362001)(31686004)(83380400001)(38100700002)(186003)(6486002)(478600001)(6512007)(6506007)(26005)(66476007)(8936002)(316002)(41300700001)(66946007)(8676002)(2906002)(66556008)(4326008)(6916009)(5660300002)(2616005)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?byR6z4Sj6B1Zfnu5RijYy51BMGnw?= =?utf-8?q?qgJHTIYOyceO0rJxH4NuQuYuFH0w8LtISiSuMRH0dUE9kg3U5Xz47PR1mtmILbFtQ?= =?utf-8?q?I/tkEAhOMNZJXnTCqIEPxNJw757vDHYXuHPnXnnPK3k5DoIqVR/qmVtYbuq3LiryO?= =?utf-8?q?FxfSYKHXzNBUyDsCxcmXRQH/laJ6Mof6Gfnh4S2VNQ9JhM/SWSnw0hCOmRjyDD6fX?= =?utf-8?q?c+FmQYgzVWmqtO1SRB3xsglSlcbms1W0aGsc5cMsDgSfANAIUwgFqcUUUr4fzkV7m?= =?utf-8?q?1GQWpVSXRSaAYwbQJeStz/N04JO3Te6r32QpCjl5RjVdTI2QdvaNPaOK6RzpfLWIc?= =?utf-8?q?Sco9xyQpBdYA2K4u/l6IOWHiQfL3j4+9n0y7bDXk4K81ZHuS/iMsygBRT/0rrugi+?= =?utf-8?q?baWQoy+ieQcEUkbmNvoL2XMIgGDZPyCAnKzQJYP+T69SUhN5ltK/BJahvw7NZNge0?= =?utf-8?q?anyoc59wOATt1976fOyrI8VSjzW3Wx7Vu7EwWY2HcpsmDqcLfJJugqG8psqGxMQOP?= =?ut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?q?64dAEieJsIqjUu4ed8kxF8jNZxC+l6vpwGksQhAsO9kycCvtF5LDfYmBwcLHJ8UpJ?= =?utf-8?q?aL/ailLZAcCO4rFHPEJT4icWShhnDHFQb6xzP1oUFs0ESUvufeEx361y+923hkpdY?= =?utf-8?q?po7/IlJ2Tc2c?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: e1d773b0-8d5b-4ac7-0246-08dabe5269fa X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2022 10:50:40.2496 (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: Zy8fXuHrjAwBXKMBvc2DFaMirw0IpnHDWGT8EQ0BLgIQkqIgqsqqhINXFw9f6rhcoch1mcuC2ydJDGpgvHD5Bg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8378 X-Spam-Status: No, score=-3029.5 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?1748562420743972584?= X-GMAIL-MSGID: =?utf-8?q?1748562420743972584?= 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); @@ -4839,6 +4839,7 @@ md_assemble (char *line) { unsigned int j; char mnemonic[MAX_MNEM_SIZE], mnem_suffix; + const char *end; const insn_template *t; /* Initialize globals. */ @@ -4854,9 +4855,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); @@ -5241,11 +5243,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;