From: "Jörg Sommer" <joerg@jo-so.de>
To: zsh-workers@zsh.org
Subject: Extend usage of const char*
Date: Mon, 1 Jan 2024 19:10:15 +0100 [thread overview]
Message-ID: <20240101182608.432886-1-joerg@jo-so.de> (raw)
The compiler option `-Wwrite-strings` brings up many places where a string
literal (`const char*`) gets assigned to a variable whose type (`char*`)
allows modifications of the string content. If the DATA segment of the ELF
binary is mapped as read-only, this leads to a segmentation violation and
crashes the process. But even without a crash, the compiler could do better
checks and optimizations, if the variables have the appropriate type.
These patches are the beginning of a series of many commits—if you like. So,
please tell, if I should merge commits, reorder or rewrite them. Many of
them are trivial changes of adding `const` to the variable declaration. But
some of them require code rearrangements or rewrites. Hence, I plan to
commit one file at a time, if possible.
[PATCH 1/6] zle.textobjects: Mark variables as const
[PATCH 2/6] lex: Mark variables with const init as const
[PATCH 3/6] zle_vi: Mark variables with const init as const
[PATCH 4/6] zle_main: mark statusline as const
[PATCH 5/6] module: Mark name argument of some functions const
[PATCH 6/6] zsh: mark hookdef.name as const
Src/Zle/textobjects.c | 6 +++---
Src/Zle/zle_main.c | 2 +-
Src/Zle/zle_vi.c | 2 +-
Src/lex.c | 6 +++---
Src/module.c | 15 ++++++++-------
Src/zsh.h | 2 +-
6 files changed, 17 insertions(+), 16 deletions(-)
next reply other threads:[~2024-01-01 18:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-01 18:10 Jörg Sommer [this message]
2024-01-01 18:10 ` [PATCH 1/6] zle.textobjects: Mark variables as const Jörg Sommer
2024-01-01 18:10 ` [PATCH 2/6] lex: Mark variables with const init " Jörg Sommer
2024-01-26 7:39 ` Oliver Kiddle
2024-01-27 6:41 ` Jörg Sommer
2024-01-28 0:18 ` Oliver Kiddle
2024-01-01 18:10 ` [PATCH 3/6] zle_vi: " Jörg Sommer
2024-01-01 18:10 ` [PATCH 4/6] zle_main: mark statusline " Jörg Sommer
2024-01-01 18:10 ` [PATCH 5/6] module: Mark name argument of some functions const Jörg Sommer
2024-01-01 18:10 ` [PATCH 6/6] zsh: mark hookdef.name as const Jörg Sommer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240101182608.432886-1-joerg@jo-so.de \
--to=joerg@jo-so.de \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).