btrfs-progs: fix dropped 'const' qualifiers exposed by the latest GCC (15.2.1)
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest3 patches 2 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | btrfs-progs: enhance find_option()common/ | +17 | 1 reply | |
| 2/3 | btrfs-progs: constify the @dots variable inside parse_range_u64()common/ | +2 | 0 replies | |
| 3/3 | btrfs-progs: drop the 'const' qualifier from bconf_save_param()common/ common/ | +2 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/3] btrfs-progs: fix dropped 'const' qualifiers exposed by the latest GCC (15.2.1)
It looks lile the latest gcc has taken the 'const' qualifier checks one step further, a char pointer that points into a string that has 'const' qualifier should also has 'const'.
This will expose unexpected modification like the following:
void my_func(const char *options)
{
char *dot;
dot = strchr(options, '.');
if (!dot)
*dot = '\0';}
In above example, @dot is either NULL or points to a location inside @options. For the later case, since @dot itself is not const, we can modify the content, resulting modification of the content of @options. The latest GCC is able to detect such proxy modification and gives us warning on them.
And in fact, btrfs-progs has exactly such proxied modification in bconf_save_param(), fixed in the last patch by dropping the 'const' quailifer.
Other than that, most are just false alerts and we can fix them by adding a const quailifer.
Qu Wenruo (3):
btrfs-progs: enhance find_option()
btrfs-progs: constify the @dots variable inside parse_range_u64()
btrfs-progs: drop the 'const' qualifier from bconf_save_param()
common/parse-utils.c | 4 ++-- common/utils.c | 24 ++++++++++++++++++------ common/utils.h | 2 +- 3 files changed, 21 insertions(+), 9 deletions(-)
--
2.53.0