zsh-workers
 help / color / mirror / code / Atom feed
* Extend usage of const char*
@ 2024-01-01 18:10 Jörg Sommer
  2024-01-01 18:10 ` [PATCH 1/6] zle.textobjects: Mark variables as const Jörg Sommer
  0 siblings, 1 reply; 10+ messages in thread
From: Jörg Sommer @ 2024-01-01 18:10 UTC (permalink / raw)
  To: zsh-workers

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(-)




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-01-28  0:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-01 18:10 Extend usage of const char* Jörg Sommer
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

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).