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)
Mar 11 2024, 11:11 PM
Unknown Object (File)
Mar 8 2024, 3:48 AM
Unknown Object (File)
Mar 8 2024, 3:48 AM
Unknown Object (File)
Mar 8 2024, 3:35 AM
Unknown Object (File)
Dec 20 2023, 6:34 AM
Unknown Object (File)
Dec 10 2023, 8:02 PM
Unknown Object (File)
Sep 2 2023, 9:18 AM
Unknown Object (File)
Sep 2 2023, 9:16 AM

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 Not Applicable
Unit
Tests Not Applicable

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.