public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] btrfs-progs: fix dropped 'const' qualifiers exposed by the latest GCC (15.2.1)
@ 2026-02-22 23:12 Qu Wenruo
  2026-02-22 23:12 ` [PATCH 1/3] btrfs-progs: enhance find_option() Qu Wenruo
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Qu Wenruo @ 2026-02-22 23:12 UTC (permalink / raw)
  To: linux-btrfs

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


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

end of thread, other threads:[~2026-03-17 16:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-22 23:12 [PATCH 0/3] btrfs-progs: fix dropped 'const' qualifiers exposed by the latest GCC (15.2.1) Qu Wenruo
2026-02-22 23:12 ` [PATCH 1/3] btrfs-progs: enhance find_option() Qu Wenruo
2026-03-17 16:39   ` David Sterba
2026-02-22 23:12 ` [PATCH 2/3] btrfs-progs: constify the @dots variable inside parse_range_u64() Qu Wenruo
2026-02-22 23:13 ` [PATCH 3/3] btrfs-progs: drop the 'const' qualifier from bconf_save_param() Qu Wenruo
2026-03-17 16:43 ` [PATCH 0/3] btrfs-progs: fix dropped 'const' qualifiers exposed by the latest GCC (15.2.1) David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox