wkz / phytool

Linux MDIO register access
GNU General Public License v2.0
143 stars 75 forks source link

Avoid %#x printf pattern #18

Closed neocturne closed 1 month ago

neocturne commented 1 month ago

The alternate form pattern %#x will not add the 0x prefix when the value is 0, leading to inconsistent output. This behavior is not documented in the linux-manpages page for printf, however both glibc and musl agree on it.

wkz commented 1 month ago

At least the version of printf(3) installed on my system states that the 0x prefix is only added to non-zero values. Still, I agree that its better to have the output be consistent.

Thanks! :+1: