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, Apr 12, 12:10 AM
Unknown Object (File)
Wed, Apr 10, 3:58 AM
Unknown Object (File)
Mon, Apr 8, 6:32 AM
Unknown Object (File)
Mon, Apr 1, 1:14 PM
Unknown Object (File)
Feb 22 2024, 8:35 AM
Unknown Object (File)
Feb 19 2024, 2:32 PM
Unknown Object (File)
Jan 24 2024, 2:43 AM
Unknown Object (File)
Dec 24 2023, 3:50 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.