Skip to content

btrfs-progs: fix dropped 'const' qualifiers exposed by the latest GCC (15.2.1)

Qu Wenruo linux-btrfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3btrfs-progs: enhance find_option()common/utils.c+17 -51 reply
2/3btrfs-progs: constify the @dots variable inside parse_range_u64()common/parse-utils.c+2 -20 replies
3/3btrfs-progs: drop the 'const' qualifier from bconf_save_param()common/utils.c common/utils.h+2 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

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