Linux I2C development
 help / color / mirror / Atom feed
From: "Gero Schwäricke" <gero.schwaericke@sevenlab.de>
To: "Wolfram Sang" <wsa+renesas@sang-engineering.com>
Cc: "Brigham Campbell" <me@brighamcampbell.com>,
	"Jean Delvare" <jdelvare@suse.de>, <linux-i2c@vger.kernel.org>
Subject: Re: [PATCH v4 1/2] i2c-tools: Allow passing device file paths
Date: Mon, 13 Jul 2026 11:23:34 +0200	[thread overview]
Message-ID: <DJXC1KBY7IXJ.32N5ILIXL8J4N@sevenlab.de> (raw)
In-Reply-To: <alKYhB6PKffxI2vt@shikoro>

Hi Wolfram,

On Sat Jul 11, 2026 at 9:24 PM CEST, Wolfram Sang wrote:
>> > -	i2cbus = lookup_i2c_bus(argv[optind]);
>> > -	if (i2cbus < 0) {
>> > -		help();
>> > -		exit(1);
>> > -	}
>> >  
>> >  	/* read address range if present */
>> >  	if (argc == optind + 3 && mode != MODE_FUNC) {
>> > @@ -321,7 +317,7 @@ int main(int argc, char *argv[])
>> >  		exit(1);
>> >  	}
>> >  
>> > -	file = open_i2c_dev(i2cbus, filename, sizeof(filename), 0);
>> > +	file = open_i2c_dev(argv[optind], &filename, sizeof(filename_buf), 0);
>> >  	if (file < 0) {
>> >  		exit(1);
>> >  	}
>> 
>> Removing this will change the error path, so a call that would
>> previously fail in lookup_i2c_bus() may now fail somewhere else,
>> changing error code and message. Same for all other tools.
>
> You mean that help() is not printed in some cases then? The error code
> is 1 in all cases, or am I missing something?

You're right, all error codes are converted to 1, so the error codes are
fine. Yes, I meant that a call with the current version may have failed
in the lookup_i2c_bus() call and printed for example

  Error: I2C bus name is not unique!

but with the new patch the lookup is done later, so it may fail in a
diffent location and print for example

  Error: No address specified!

instead. (Example for i2cdump)

This would be a problem, e.g., if someone wrote a script to check if
they have non-unique I2C bus names which uses i2cdump and evaluates
stderr for the string and if instead it returned the no address string
it assumed the check passed and all names are unique. Something like
this:

  i2cdetect -l | cut -f3 | sort -u | while read -r n; do
    i2cdump -y "$n" 2>&1 >/dev/null | grep -qF "Error: I2C bus name is not unique!" && echo "DUP: $n"
  done

That is the most reasonable example I found which may run into trouble
with the change.

Best,
Gero

-- 


sevenlab engineering GmbH <https://sevenlab.de>
serious engineering.

Geschäftsführer: Christian J. Pereira
Amtsgericht Köln, HRB 121730
Anschrift: Hansaring 20, 50670 Köln

  reply	other threads:[~2026-07-13  9:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06  4:27 [PATCH v4 0/2] i2c-tools: Make tools accept bus path Brigham Campbell
2026-07-06  4:27 ` [PATCH v4 1/2] i2c-tools: Allow passing device file paths Brigham Campbell
2026-07-09 12:18   ` Wolfram Sang
2026-07-09 12:40   ` Gero Schwäricke
2026-07-11 19:24     ` Wolfram Sang
2026-07-13  9:23       ` Gero Schwäricke [this message]
2026-07-13 15:06         ` Wolfram Sang
2026-07-14  9:30           ` Gero Schwäricke
2026-07-14 10:13             ` Wolfram Sang
2026-07-13  9:37   ` Gero Schwäricke
2026-07-13 15:38     ` Brigham Campbell
2026-07-14  9:42       ` Gero Schwäricke
2026-07-06  4:27 ` [PATCH v4 2/2] i2c-tools: Document device paths as I2CBUS arg Brigham Campbell
2026-07-11 19:43   ` 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=DJXC1KBY7IXJ.32N5ILIXL8J4N@sevenlab.de \
    --to=gero.schwaericke@sevenlab.de \
    --cc=jdelvare@suse.de \
    --cc=linux-i2c@vger.kernel.org \
    --cc=me@brighamcampbell.com \
    --cc=wsa+renesas@sang-engineering.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