Bug 279261

Summary: i2c -sv reports stack garbage in message
Product: Base System Reporter: John F. Carr <jfc>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: New ---    
Severity: Affects Only Me    
Priority: ---    
Version: 15.0-CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Initialize i2c_opt.addr to 0 none

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.