From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: "Benoît Monin" <benoit.monin@bootlin.com>
Cc: linux-i2c@vger.kernel.org, Jean Delvare <jdelvare@suse.de>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH i2c-tools v3 2/2] i2ctransfer: Add optional message modifier flags
Date: Mon, 8 Jun 2026 11:21:30 +0200 [thread overview]
Message-ID: <aiaJmtl-n-mNtsDt@shikoro> (raw)
In-Reply-To: <oyWrZgMUT2iRI0tfI5ARxw@bootlin.com>
[-- Attachment #1: Type: text/plain, Size: 1577 bytes --]
Hi Benoît,
> @@ -202,6 +202,20 @@ static int add_flag_if_supported(__u16 *flags, unsigned long funcs, char arg)
> break;
> #endif
>
> + case '0':
> + case '1':
> + case '2':
> + case '3':
> + case '4':
> + case '5':
> + case '6':
> + case '7':
> + case '8':
> + case '9':
> + case '?':
> + case '@':
> + return 0;
> +
> default:
>
>
> With this we get out of the flags parsing and the "Missing direction flag"
> error message is shown. What's your opinion on this?
Basically fine with me, but we need another adaption then because this
documentation is not precise anymore:
+ * 0 if the argument is a valid and supported optional flag
Doesn't fit anymore because for the above cases, the argument is not
valid.
I think we should return a dedicated value for this 'unexpected' case.
Which brings something again to the table I was close to suggesting last
time already but back then refrained from doing so. Now, it might be
good after all:
It is about not using magic numbers for the return values of that
function but an enum with descriptive entries. Example:
enum supported_flags_retval {
FLAGS_GOT_RW,
FLAGS_GOT_OPTIONAL,
FLAGS_UNEXPECTED,
FLAGS_UNKNOWN,
};
I think this will make life for future hackers quite easier. What do you
think?
Happy hacking,
Wolfram
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-06-08 9:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-27 9:25 [PATCH i2c-tools v3 0/2] Add support for message modifier flags Benoît Monin
2026-01-27 9:25 ` [PATCH i2c-tools v3 1/2] i2cdetect: Display mangling and nostart support Benoît Monin
2026-06-03 7:33 ` Wolfram Sang
2026-01-27 9:25 ` [PATCH i2c-tools v3 2/2] i2ctransfer: Add optional message modifier flags Benoît Monin
2026-06-03 7:33 ` Wolfram Sang
2026-06-04 16:00 ` Benoît Monin
2026-06-08 9:21 ` Wolfram Sang [this message]
2026-06-08 13:26 ` Benoît Monin
2026-02-17 12:13 ` [PATCH i2c-tools v3 0/2] Add support for " Jean Delvare
2026-03-23 9:12 ` Benoît Monin
2026-05-29 19:58 ` Wolfram Sang
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=aiaJmtl-n-mNtsDt@shikoro \
--to=wsa+renesas@sang-engineering.com \
--cc=benoit.monin@bootlin.com \
--cc=jdelvare@suse.de \
--cc=linux-i2c@vger.kernel.org \
--cc=thomas.petazzoni@bootlin.com \
/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