Page MenuHomeFreeBSD

Use correct sscanf() format string for uint64_t
ClosedPublic

Authored by dim on Dec 17 2016, 6:07 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 20, 11:53 AM
Unknown Object (File)
Tue, Dec 3, 3:50 AM
Unknown Object (File)
Nov 16 2024, 6:00 PM
Unknown Object (File)
Oct 31 2024, 3:21 PM
Unknown Object (File)
Oct 31 2024, 3:21 PM
Unknown Object (File)
Oct 31 2024, 3:20 PM
Unknown Object (File)
Oct 31 2024, 3:20 PM
Unknown Object (File)
Oct 31 2024, 3:02 PM
Subscribers

Details

Summary

After rS310171, the kernel version of sscanf() now has format string
checking enabled. This now results in a -Werror warning in mlx4ib:

/usr/src/sys/modules/mlx4ib/../../dev/mlx4/mlx4_ib/mlx4_ib_sysfs.c:90:22: error: format specifies type 'unsigned long long *' but the argument has type 'u64 *' (aka 'unsigned long *') [-Werror,-Wformat]
        sscanf(buf, "%llx", &sysadmin_ag_val);
                 ~~~~   ^~~~~~~~~~~~~~~~

Since u64 is a uint64_t, let's use the SCNx64 macro from inttypes.h
instead.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

dim retitled this revision from to Use correct sscanf() format string for uint64_t.
dim updated this object.
dim edited the test plan for this revision. (Show Details)
dim added reviewers: hselasky, rstone.
hselasky edited edge metadata.

Is machine/_inttypes.h the correct header file to include?

I think it is also fine to change the sysadmin_ag_val to unsigned long long, which is currently 64-bit for i386 and amd64 which the mlx4 driver is compiled on.

Don't forget to MFC.

--HPS

This revision is now accepted and ready to land.Dec 18 2016, 8:44 AM

Is machine/_inttypes.h the correct header file to include?

This is what other drivers appear to include, if they want to get at PRI/SCN macros. Though this isn't a Linux thing.

I think it is also fine to change the sysadmin_ag_val to unsigned long long, which is currently 64-bit for i386 and amd64 which the mlx4 driver is compiled on.

Yes, if that is also acceptable, we don't need the additional include.

dim edited edge metadata.

Just change sysadmin_ag_val to unsigned long long instead.

This revision now requires review to proceed.Dec 18 2016, 3:18 PM
This revision was automatically updated to reflect the committed changes.