From patchwork Thu Oct 13 08:16:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 1976 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp152676wrs; Thu, 13 Oct 2022 01:17:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7C50F5UYAq7EquSYuB6EJB0xuiJEIRqooNt7eugtT4r11h6T2sOf9l/AJiS3587SDO3adQ X-Received: by 2002:a17:907:2cf5:b0:78d:f9cc:794a with SMTP id hz21-20020a1709072cf500b0078df9cc794amr4451688ejc.577.1665649053195; Thu, 13 Oct 2022 01:17:33 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ho38-20020a1709070ea600b0078d484e0e79si18967934ejc.481.2022.10.13.01.17.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 01:17:33 -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="K/ACyixu"; 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 B7E3D382E28F for ; Thu, 13 Oct 2022 08:17:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B7E3D382E28F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665649022; 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=K/ACyixuWfMCHAtPzyyAkpSEV4cAgeKVso+O0xE/+1bIaOa2tGemIsprnAM/2RaZ+ S4DhwUIpwCKe0sa2QtysqyoZsdaOcqzLDpUMhdIy5UIUfiWS+XHc25R6UrNd762Z0b FR2ZlBixsejZW1ddpI2WieRsT2f6SjPZ1jgIbJD0= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2048.outbound.protection.outlook.com [40.107.20.48]) by sourceware.org (Postfix) with ESMTPS id BC80E382E291 for ; Thu, 13 Oct 2022 08:16:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BC80E382E291 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=STjyYXL5juzshJoYREBl5pMQfsiTUm0xrnTvybvJ/4JoiUxxIR9cHOmxGWJdnzBEiOLrW8ctcQoKo8UjEimc14BFibOAwA9t1HFJMAYj9cC0YTYo2nHHOz09p3ZHFwflYYSiJPZ0TdTrm7TLiwT3lZ2DMSroPf36CZXaFBbo+bftGajrcFNr/7MEdclOGy+6PRKh97kWDHvVE6UvlDhNySfJmabfDRtLzzR4a5FrLdcvbLtgJMQC92Wad/VT8BgJRqtGdYTlvBxh5RI2dnk0+fXWxhyJxwFMf7XwWYq4d4TmC96BxS5TfJrOd/7ceMzide/qNij968W5EA8cn5knBg== 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=cO9E/LZMXlqOrCtd+dQnOyaKjtZji8IjJUYGE6YN7fdR8O5Q4gSf4rwOSxZliRIzKPwxpqeErSS7NfckIz5G3Gl9ljT9BoSWyzc9wRLXveXwL0G8h21JstkSZjcGmY1XTgw/12W2ruIzBdMi7ihJYO4XVOL2aGrRf8lZLMoeq85SOShseOpZthSUcdVeszusM+eLRcquG+OiX0hZKGoRjCkxeiu5LR2fy6h7eFHZJD3Tcm4uGZ3bXtehzX01vadRr1/AcmnPic5F7P9zdXg2Irb3tMxMzqUkuKkEN2rjP/7H2SeldntK6rLqfWIJgFffd6FX7WyehUzs1Dkv82dSwA== 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 PAXPR04MB9220.eurprd04.prod.outlook.com (2603:10a6:102:228::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.19; Thu, 13 Oct 2022 08:16:50 +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.5723.026; Thu, 13 Oct 2022 08:16:50 +0000 Message-ID: <1216a3f8-2273-8681-f528-9493a66891f0@suse.com> Date: Thu, 13 Oct 2022 10:16:49 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.2 Subject: [PATCH v4 1/8] x86: constify parse_insn()'s input Content-Language: en-US To: Binutils References: <4aa2665c-535f-da2d-1edb-4eb1f4195c3e@suse.com> In-Reply-To: <4aa2665c-535f-da2d-1edb-4eb1f4195c3e@suse.com> X-ClientProxiedBy: FR3P281CA0121.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:94::8) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|PAXPR04MB9220:EE_ X-MS-Office365-Filtering-Correlation-Id: 560e4f72-587a-4cf3-81ee-08daacf347b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2suCi3VJEzgW3F779wKszWAVFP7u8zwE7ff37k4vrHDbsSbo3LbBqfYqiPIrTSfYF5jpX1mU48UH9Rv7DkPDdbL7bf5qCgIdK0U8dTdEKpaHEjLmiZ/4I8TuB3kuHUSWjpDAvZiVmXbC2y5dTWbEVFU7uHoeIYIe/pcyuybuaLBV1ZPN4TQI4Hh0zWal0jQpt6SF9B2IOvhy/B7nv5qm80HzhBGeQSIQc0vakLThNwVvPZPVgQERI0ua4fxjcGblLWD1fdRBl4N+tjOSVUs/Is9fupNA5P4NTyxfZXhQ51loyMKNaogZiDtC/IjJ7cTs2nm4mc9A0ZBB6TEgaOPiDLkoO2/xBD2Te8RHUPcwshnJ6EstBQhTHkR2S++w6OHIiO+ZlEm7TQQxUA9+4RB6xgqEJhLliUkY2+t6L8gDk+Z5xH/6n0LqG1jo4dSFMD29yPqE7O5McdDQ3fcjV01l6NYI/eA0Eg3Q/8UB58L8Z15+iW55Ow5H6AJlLlkhjNPFdalNCHBt7nFm0nE75FKsInAaO5bNieaInT0WXEkrGMar4s9Vthxtust0XLPWI0QeQ67AhUjhHPzFBi4V7NFn/mhoqDj8X4cFOa0rfx7gDBOozCt6dVHmfkmNyo1TEH7zSyLv3U8MYr0LxE5w/iJeZrbGUZqZfp5Mma9NsfoPwYea530qN91A5U22fSJrElEb3mbRqreOlnr2wFldL20X7ckxsQXeQRHS0L5NPC0Le6B7p6ZmSllzQxWwDwHJI2Cm4en7HajhIzc08PUugVpHvCuAl6l5cMBP2QqIC0Do7E4= 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)(396003)(376002)(136003)(39860400002)(451199015)(36756003)(31686004)(31696002)(86362001)(5660300002)(38100700002)(2616005)(186003)(2906002)(6506007)(478600001)(26005)(66476007)(66946007)(66556008)(6512007)(316002)(83380400001)(8676002)(6916009)(8936002)(4326008)(41300700001)(6486002)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?v1Bmn9Z56BmFRy2rm21fhDkbZY+S?= =?utf-8?q?CrqqA6fBsNLG/nJxvtbquxX01f795aKZPeuVx4OFr6VKTZKIOyRfxKSsqTdO43cqP?= =?utf-8?q?+m+dR8I0b3DFmJNzTh3mdtAjRpJ4pYqTsyyUyq7INZIITaAihS3yup22xnTGaU0pZ?= =?utf-8?q?5/cGISzfyYjhl8MAQ2LUotFNXYfb65chMQyhHoq0ivh6salduib4qXaG1kv+9A8fN?= =?utf-8?q?oPMr9p8tqgKGrwtadhoO2nYKvrNx3akFa+zbp2sPDjTQ+K87M9s9N38XfAyFNweJi?= =?utf-8?q?YlzBAgGxZIurHoJ4oe7e8laeQXpVUOW6XWDXjhxsvrQzFNM04llUhG/3fQzCzA1/1?= =?utf-8?q?RZW9Z3BGgG5C6YBVaYufLI+7LiKr00cximhGbB7ZO2KF/eUe84Pi8wGN2SFXseb8q?= =?utf-8?q?ZUco4S4fUCTSl773B7M9/61cQduzSkFzCFjW/1UpTTDBtTT5InHQDaoVfXX6FXYGu?= =?utf-8?q?CCt412sw/A4OCEf6BcBzvW29F5JzP2lU2gwMWa5f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yct8rtlDiJrsgUXM2ogur5?= =?utf-8?q?TanhdlN+ckuLxVXdimyjfIIPVVc/t1fNOLJ+uZUKXJexXKrxtIhObmbG5I3DmV9vl?= =?utf-8?q?L9uFM+94i4zS+6F2HLLiPiXBzkQKSaA6fgnyOCmqFbuQfs+tnaG8TYhsmQZ2FZIDn?= =?utf-8?q?zxLkWaJmkl7H?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 560e4f72-587a-4cf3-81ee-08daacf347b2 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2022 08:16:50.7820 (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: WlPycbBBp9cl46Cz6urw9snMBGNmSYpj6oAi4hGnTm8HC5ziY8zzE9ZN+KYruyQHP9lIiihAw5oXZoeA9HNVRQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9220 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?1746559622074820723?= X-GMAIL-MSGID: =?utf-8?q?1746559622074820723?= 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;