From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 3/5] mkfs: constify various strings
Date: Wed, 14 Oct 2020 22:31:48 -0700 [thread overview]
Message-ID: <20201015053148.GO9832@magnolia> (raw)
In-Reply-To: <20201015032925.1574739-4-david@fromorbit.com>
On Thu, Oct 15, 2020 at 02:29:23PM +1100, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> Because the ini parser uses const strings and so the opt parsing
> needs to be told about it to avoid compiler warnings.
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
> include/linux.h | 2 +-
> mkfs/xfs_mkfs.c | 28 ++++++++++++++--------------
> 2 files changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/include/linux.h b/include/linux.h
> index 57726bb12b74..03b3278bb895 100644
> --- a/include/linux.h
> +++ b/include/linux.h
> @@ -92,7 +92,7 @@ static __inline__ void platform_uuid_unparse(uuid_t *uu, char *buffer)
> uuid_unparse(*uu, buffer);
> }
>
> -static __inline__ int platform_uuid_parse(char *buffer, uuid_t *uu)
> +static __inline__ int platform_uuid_parse(const char *buffer, uuid_t *uu)
> {
> return uuid_parse(buffer, *uu);
> }
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index e84be74fb100..99ce0dc48d3b 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -975,8 +975,8 @@ respec(
>
> static void
> unknown(
> - char opt,
> - char *s)
> + const char opt,
> + const char *s)
> {
> fprintf(stderr, _("unknown option -%c %s\n"), opt, s);
> usage();
> @@ -1387,7 +1387,7 @@ getnum(
> */
> static char *
> getstr(
> - char *str,
> + const char *str,
> struct opt_params *opts,
> int index)
> {
> @@ -1396,14 +1396,14 @@ getstr(
> /* empty strings for string options are not valid */
> if (!str || *str == '\0')
> reqval(opts->name, opts->subopts, index);
> - return str;
> + return (char *)str;
Hmm do any of the getstr callers actually change the return value?
Er... holy $bovine you have to change a lot of stuff everywhere to make
the const stick.
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> }
>
> static int
> block_opts_parser(
> struct opt_params *opts,
> int subopt,
> - char *value,
> + const char *value,
> struct cli_params *cli)
> {
> switch (subopt) {
> @@ -1420,7 +1420,7 @@ static int
> cfgfile_opts_parser(
> struct opt_params *opts,
> int subopt,
> - char *value,
> + const char *value,
> struct cli_params *cli)
> {
> switch (subopt) {
> @@ -1437,7 +1437,7 @@ static int
> data_opts_parser(
> struct opt_params *opts,
> int subopt,
> - char *value,
> + const char *value,
> struct cli_params *cli)
> {
> switch (subopt) {
> @@ -1506,7 +1506,7 @@ static int
> inode_opts_parser(
> struct opt_params *opts,
> int subopt,
> - char *value,
> + const char *value,
> struct cli_params *cli)
> {
> switch (subopt) {
> @@ -1541,7 +1541,7 @@ static int
> log_opts_parser(
> struct opt_params *opts,
> int subopt,
> - char *value,
> + const char *value,
> struct cli_params *cli)
> {
> switch (subopt) {
> @@ -1587,7 +1587,7 @@ static int
> meta_opts_parser(
> struct opt_params *opts,
> int subopt,
> - char *value,
> + const char *value,
> struct cli_params *cli)
> {
> switch (subopt) {
> @@ -1621,7 +1621,7 @@ static int
> naming_opts_parser(
> struct opt_params *opts,
> int subopt,
> - char *value,
> + const char *value,
> struct cli_params *cli)
> {
> switch (subopt) {
> @@ -1650,7 +1650,7 @@ static int
> rtdev_opts_parser(
> struct opt_params *opts,
> int subopt,
> - char *value,
> + const char *value,
> struct cli_params *cli)
> {
> switch (subopt) {
> @@ -1680,7 +1680,7 @@ static int
> sector_opts_parser(
> struct opt_params *opts,
> int subopt,
> - char *value,
> + const char *value,
> struct cli_params *cli)
> {
> switch (subopt) {
> @@ -1700,7 +1700,7 @@ static struct subopts {
> struct opt_params *opts;
> int (*parser)(struct opt_params *opts,
> int subopt,
> - char *value,
> + const char *value,
> struct cli_params *cli);
> } subopt_tab[] = {
> { 'b', &bopts, block_opts_parser },
> --
> 2.28.0
>
next prev parent reply other threads:[~2020-10-15 5:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-15 3:29 [PATCH 0/5] mkfs: Configuration file defined options Dave Chinner
2020-10-15 3:29 ` [PATCH 1/5] build: add support for libinih for mkfs Dave Chinner
2020-10-15 5:40 ` Darrick J. Wong
2020-10-15 3:29 ` [PATCH 2/5] mkfs: add initial ini format config file parsing support Dave Chinner
2020-10-15 5:46 ` Darrick J. Wong
2020-10-15 6:09 ` Dave Chinner
2020-10-15 3:29 ` [PATCH 3/5] mkfs: constify various strings Dave Chinner
2020-10-15 5:31 ` Darrick J. Wong [this message]
2020-10-15 3:29 ` [PATCH 4/5] mkfs: hook up suboption parsing to ini files Dave Chinner
2020-10-15 5:24 ` Darrick J. Wong
2020-10-15 3:29 ` [PATCH 5/5] mkfs: document config files in mkfs.xfs(8) Dave Chinner
2020-10-15 5:36 ` Darrick J. Wong
2020-10-15 5:13 ` [PATCH 0/5] mkfs: Configuration file defined options Darrick J. Wong
2020-10-15 5:32 ` Dave Chinner
2020-10-15 5:39 ` Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201015053148.GO9832@magnolia \
--to=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox