Page MenuHomeFreeBSD

pfctl: Fix superblock printf format mismatch
ClosedPublic

Authored by vegeta_tuxpowered.net on Mar 5 2023, 8:37 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 13, 5:27 PM
Unknown Object (File)
Sun, Dec 8, 4:31 PM
Unknown Object (File)
Tue, Dec 3, 6:21 PM
Unknown Object (File)
Tue, Dec 3, 6:48 AM
Unknown Object (File)
Thu, Nov 21, 10:37 AM
Unknown Object (File)
Nov 9 2024, 2:54 AM
Unknown Object (File)
Oct 16 2024, 1:12 AM
Unknown Object (File)
Oct 16 2024, 12:50 AM
Subscribers

Details

Summary

It is impossible to compile pfctl with OPT_DEBUG due to integer width mismatch:

/usr/home/kajetan.staszkiewicz/freebsd.git/sbin/pfctl/pfctl_optimize.c:1479:9: error: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Werror,-Wformat]
                                    i - pf_rule_desc[closest].prf_off--- pfctl_optimize.o ---
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/home/kajetan.staszkiewicz/freebsd.git/sbin/pfctl/pfctl_optimize.c:52:44: note: expanded from macro 'DEBUG'
        printf("%s: " str "\n", __FUNCTION__ , ## v)
                      ~~~                         ^
1 error generated.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

ok, in this case commit message should reference openbsd, like so: "Obtained from: OpenBSD (pfctl_optimize.c 1.15)"

With the patch that seems to fail to build on armv6 (and I suspect on i386 as well):

/usr/src/sbin/pfctl/pfctl_optimize.c:1482:9: error: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Werror,-Wformat]
                                    i - pf_rule_desc[closest].prf_off^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/src/sbin/pfctl/pfctl_optimize.c:52:44: note: expanded from macro 'DEBUG'
        printf("%s: " str "\n", __FUNCTION__ , ## v)
                      ~~~                         ^
1 error generated.
*** [pfctl_optimize.o] Error code 1

I believe we want %zxh, because 'z' is specifically intended to print size_t, whereas 'l' implies an unsigned long, which isn't always what size_t is.
I've kicked off another make universe with z rather than l.

This revision was not accepted when it landed; it landed in state Needs Review.Mar 6 2023, 7:27 PM
This revision was automatically updated to reflect the committed changes.