From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 7FA3121311 for ; Fri, 26 Jan 2024 08:40:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-ID:Date: Content-Transfer-Encoding:Content-ID:Content-Type:MIME-Version:Subject:To: References:From:In-reply-to:cc:Reply-To:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=XDjO66QxsSt/ZxZFV5Yi97nga5svc3eRls/CsrnbClg=; b=qbq0FKrqa/7mAa2ZvSLmFCZl7w xbBknQsTPaz9G0rXCx8tq03b7yPkyPEAPkQJBPaOsQz+FQ40XFg8hSs7VkPKW/cDw7vg9KCISdNZn okMlkMQraMZe8zHda/PBMVCePkoDg3nERTEWK4Pn1LTh6nNczmtTXpdTRQpuaz5Th03fekCmjC5/6 qYZ6oBsJvsIII93QwAPPDPEpOkMrqxtVPfFXy6eJ51HWGKq/8yoFYxT3fQKQzgYvL1ElV8zeDQ8BC t40Wb9ylZX3zCOx9chFMHeyijJB6M3YAxK8pLQ1jiBU9tI0xwVpHJGFQHL5zR8CS450SnpaszpLQi j4g0aZYQ==; Received: by zero.zsh.org with local id 1rTGoq-0001F5-Lu; Fri, 26 Jan 2024 07:40:08 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1rTGoY-0000vD-GI; Fri, 26 Jan 2024 07:39:53 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.97.1) (envelope-from ) id 1rTGoX-000000000lT-1PhL; Fri, 26 Jan 2024 08:39:49 +0100 cc: zsh-workers@zsh.org In-reply-to: From: Oliver Kiddle References: <8a1e39c6b8f061ce6d2e37c86e6d889309250f13.1704132620.git.joerg@jo-so.de> To: =?UTF-8?q?J=C3=B6rg=20Sommer?= Subject: Re: [PATCH 2/6] lex: Mark variables with const init as const MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2941.1706254789.1@hydra> Content-Transfer-Encoding: 8bit Date: Fri, 26 Jan 2024 08:39:49 +0100 Message-ID: <2942-1706254789.333425@NzBz.rL2-.PsQC> X-Seq: 52503 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On 1 Jan, Jörg Sommer wrote: > Because these variables are initialized with as constant string, they should > be marked as *const* to make the compiler running with `-Wwrite-strings` > more happy. Applying this patch series causes a couple of fresh warnings: zle_thingy.c: In function 'bin_zle_refresh': zle_thingy.c:420:15: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 420 | char *s = statusline; | lex.c: In function 'exalias': lex.c:1964:20: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 1964 | zshlextext = tokstrings[tok]; | clang describes these as "initializing 'char *' with an expression of type 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]". I have no objection to adding const in more places where possible. You may find we have code that is not really modifying its parameter but relies on being able to temporarily swap a nul in for a character as part of parsing. I also tend to find the old issue that you can't safely cast a char ** to const char** tends to get in the way. Oliver