Bug 279261 - i2c -sv reports stack garbage in message
Summary: i2c -sv reports stack garbage in message
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 15.0-CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-23 20:10 UTC by John F. Carr
Modified: 2024-05-23 20:10 UTC (History)
0 users

See Also:


Attachments
Initialize i2c_opt.addr to 0 (1.26 KB, patch)
2024-05-23 20:10 UTC, John F. Carr
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John F. Carr 2024-05-23 20:10:51 UTC
Created attachment 250908 [details]
Initialize i2c_opt.addr to 0

# i2c -sv
dev: /dev/iic0, addr: 0x6cfb7d5c, r/w: r, offset: 0x00, width: 8, count: 1
Hardware may not support START/STOP scanning; trying less-reliable read method.
Scanning I2C devices on /dev/iic0:
11

# i2c -f /dev/iic1 -rv
dev: /dev/iic1, addr: 0x1903955c, r/w: r, offset: 0x00, width: 8, count: 1
Resetting I2C controller on /dev/iic1

The address 0x6cfb7d5c or 0x1903955c is an uninitialized field in variable i2c_opt and varies from run to run.  It is not actually relevant when scanning or resetting.

The attached patch avoids printing the "dev:" line when verbose in scan or reset mode.  The bus name is printed elsewhere and the rest of the fields are not relevant.  It also initializes the address to 0 just in case it gets used somehow now or in the future.