Page MenuHomeFreeBSD

Disable errors for -Wnonnull for the kernel for GCC 12.
ClosedPublic

Authored by jhb on Dec 7 2022, 8:36 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 23 2024, 12:21 AM
Unknown Object (File)
Feb 23 2024, 12:21 AM
Unknown Object (File)
Feb 23 2024, 12:21 AM
Unknown Object (File)
Feb 23 2024, 12:08 AM
Unknown Object (File)
Dec 27 2023, 8:42 PM
Unknown Object (File)
Dec 23 2023, 12:26 AM
Unknown Object (File)
Nov 4 2023, 6:49 PM
Unknown Object (File)
Nov 4 2023, 6:48 PM
Subscribers

Details

Summary

The USB code and some other places raise false positives when a NULL
pointer is passed to an inlined function along with a separate length
and the compiler can't determine that the separate length of 0
prevents the use of the NULL pointer.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 48644
Build 45530: arc lint + arc unit

Event Timeline

jhb requested review of this revision.Dec 7 2022, 8:36 PM
jhb created this revision.
This revision was not accepted when it landed; it landed in state Needs Review.Dec 21 2022, 6:51 PM
This revision was automatically updated to reflect the committed changes.

What are the functions? Generally, passing a null pointer to a standard string function invokes UB regardless of the passed size, and some compilers do make optimizations based on this assumption.

I built with gcc12 in Cirrus-CI and get a few Wnonnull warnings. D39947 is a fix for one of them, PR271227 is a bug report for one of them, and the last one is:

In file included from /tmp/cirrus-ci-build/sys/sys/bus.h:169,
                 from /tmp/cirrus-ci-build/sys/crypto/ccp/ccp_hardware.c:37:
In function 'ccp_do_xts',
    inlined from 'ccp_do_blkcipher' at /tmp/cirrus-ci-build/sys/crypto/ccp/ccp_hardware.c:1614:11,
    inlined from 'ccp_authenc' at /tmp/cirrus-ci-build/sys/crypto/ccp/ccp_hardware.c:1707:11:
/tmp/cirrus-ci-build/sys/sys/systm.h:266:33: warning: argument 2 null where non-null expected [-Wnonnull]
  266 | #define memcpy(to, from, len)   __builtin_memcpy((to), (from), (len))
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/cirrus-ci-build/sys/crypto/ccp/ccp_hardware.c:1433:25: note: in expansion of macro 'memcpy'
 1433 |                         memcpy(&qp->completions_ring[qp->cq_tail], cctx,
      |                         ^~~~~~
/tmp/cirrus-ci-build/sys/sys/systm.h:266:33: note: in a call to built-in function '__builtin_memcpy'
  266 | #define memcpy(to, from, len)   __builtin_memcpy((to), (from), (len))
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/cirrus-ci-build/sys/crypto/ccp/ccp_hardware.c:1433:25: note: in expansion of macro 'memcpy'
 1433 |                         memcpy(&qp->completions_ring[qp->cq_tail], cctx,
      |                         ^~~~~~
In function 'ccp_do_blkcipher',
    inlined from 'ccp_authenc' at /tmp/cirrus-ci-build/sys/crypto/ccp/ccp_hardware.c:1707:11:
/tmp/cirrus-ci-build/sys/sys/systm.h:266:33: warning: argument 2 null where non-null expected [-Wnonnull]
  266 | #define memcpy(to, from, len)   __builtin_memcpy((to), (from), (len))
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/cirrus-ci-build/sys/crypto/ccp/ccp_hardware.c:1631:25: note: in expansion of macro 'memcpy'
 1631 |                         memcpy(&qp->completions_ring[qp->cq_tail], cctx,
      |                         ^~~~~~
/tmp/cirrus-ci-build/sys/sys/systm.h:266:33: note: in a call to built-in function '__builtin_memcpy'
  266 | #define memcpy(to, from, len)   __builtin_memcpy((to), (from), (len))
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/cirrus-ci-build/sys/crypto/ccp/ccp_hardware.c:1631:25: note: in expansion of macro 'memcpy'
 1631 |                         memcpy(&qp->completions_ring[qp->cq_tail], cctx,
      |                         ^~~~~~