Skip to content

Ensure const correctness when reading the configuration - #143

Open
laarmen wants to merge 9 commits into
xebd:masterfrom
laarmen:const_correctness
Open

laarmen wants to merge 9 commits into
xebd:masterfrom
laarmen:const_correctness

Conversation

@laarmen

@laarmen laarmen commented Jun 23, 2020

Copy link
Copy Markdown
Contributor

As they say, "shared mutable state is the root of all evil". This patch series clearly marks the triton code as the owner of the configuration objects, making their content internal. Most of the changes are simply changing the client code to use the proper type, with the exception of pppd_compat.

There, the changes are a bit more involved, as the const char * pointers end up being fed to an API that takes in char * arguments for historical reasons. Detailed explanations can be found in the commit logs.

laarmen added 9 commits June 23, 2020 12:07
Except when loading the configuration, the content of all those strings
is not supposed to change during the execution of the program. Even
then, the mutation should only occur in the triton module before
exposing those strings to consumption.

This patch changes the pppd_compat module to actually reflect this fact
by marking their configuration strings as const.

Signed-off-by: Simon Chopin <s.chopin@alphalink.fr>
Apparently, execve() only has one level of const marker in order not to
break existing code, but it is not supposed to mutate the content, hence
the safety of casting our strings at the last moment.

The general pattern when initializing an array of const structures is to
first generate the instances as we want them, and only when they're
ready do we insert them into the array. That's the reason behind the
changes when filling the argv array, as the previous version did it in
the reverse order.

Signed-off-by: Simon Chopin <s.chopin@alphalink.fr>
The argument sanitation for the various executable paths that can be
provided to this module is very generic, this patch cuts through some of
the boilerplate.

Signed-off-by: Simon Chopin <s.chopin@alphalink.fr>
The only part of the code that should be able to make changes to this
data should be triton itself, as it knows if there are potential
consumers of the data running.

Signed-off-by: Simon Chopin <s.chopin@alphalink.fr>
Signed-off-by: Simon Chopin <s.chopin@alphalink.fr>
Clang emits a warning about the previous syntax, as it might have been a
typo for '-='. This commit simply move the minus operator next to its
operand.

Signed-off-by: Simon Chopin <s.chopin@alphalink.fr>
The configuration option are not for this code to change.

Signed-off-by: Simon Chopin <s.chopin@alphalink.fr>
Signed-off-by: Simon Chopin <s.chopin@alphalink.fr>
Signed-off-by: Simon Chopin <s.chopin@alphalink.fr>
@Neustradamus

Copy link
Copy Markdown

Dear @laarmen,

Can you open a PR at "good" place:

Thanks in advance.

themiron pushed a commit to themiron/accel-ppp that referenced this pull request Jul 29, 2026
ci: use ubuntu 24.04 as default runner in github
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants