Files
scylladb/tools
Botond Dénes bb7121a1fb Merge 'tools/scylla-nodetools: do not create unowned bpo::value ' from Kefu Chai
in other words, do not create bpo::value unless transfer it to an
option_description.

`boost::program_options::value()` create a new typed_value<T> object,
without holding it with a shared_ptr. boost::program_options expects
developer to construct a `bpo::option_description` right away from it.
and `boost::program_options::option_description` takes the ownership
of the `type_value<T>*` raw pointer, and manages its life cycle with
a shared_ptr. but before passing it to a `bpo::option_description`,
the pointer created by `boost::program_options::value()` is a still
a raw pointer.

before this change, we initialize `operations_with_func` as global
variables using `boost::program_options::value()`. but unfortunately,
we don't always initialize a `bpo::option_description` from it --
we only do this on demand when the corresponding subcommand is
called.

so, if the corresponding subcommand is not called, the created
`typed_value<T>` objects are leaked. hence LeakSanitizer warns us.

after this change, we create the option map as a static
local variable in a function so it is created on demand as well.
as an alternative, we could initialize the options map as local
variable where it used. but to be more consistent with how
`global_option` is specified. and to colocate them in a single
place, let's keep the existing code layout.

this change is quite similar to 374bed8c3d

Fixes https://github.com/scylladb/scylladb/issues/15429

Closes scylladb/scylladb#15430

* github.com:scylladb/scylladb:
  tools/scylla-nodetools: reindent
  tools/scylla-nodetools: do not create unowned bpo::value
2023-09-18 11:09:46 +03:00
..
2023-09-14 10:30:07 +02:00
2023-09-08 17:22:07 +03:00
2023-05-29 23:03:25 +03:00
2023-09-11 21:38:02 +03:00