Bug 206762 - -Wtautilogical-pointer-compare issues with drm(4) code
Summary: -Wtautilogical-pointer-compare issues with drm(4) code
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-30 19:08 UTC by Ngie Cooper
Modified: 2016-02-02 19:50 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ngie Cooper freebsd_committer 2016-01-30 19:08:23 UTC
Ran into these issues on amd64 with buildkernel:

$ svnversion
295081
$ env SRCCONF=/dev/null make tinderbox KERNCONF=LINT -j4
...
--- all_subdir_i915kms ---^M
/usr/src/svn/sys/modules/drm2/i915kms/../../../dev/drm2/i915/i915_gem.c:680:12: warning: comparison of address of 'obj->base' equal to a null pointer is always false [-Wtautological-pointer-compare]^M
        if (&obj->base == NULL) {^M
             ~~~~~^~~~    ~~~~^M
/usr/src/svn/sys/modules/drm2/i915kms/../../../dev/drm2/i915/i915_gem.c:1040:12: warning: comparison of address of 'obj->base' equal to a null pointer is always false [-Wtautological-pointer-compare]^M
        if (&obj->base == NULL) {^M
             ~~~~~^~~~    ~~~~^M
/usr/src/svn/sys/modules/drm2/i915kms/../../../dev/drm2/i915/i915_gem.c:1259:12: warning: comparison of address of 'obj->base' equal to a null pointer is always false [-Wtautological-pointer-compare]^M
        if (&obj->base == NULL) {^M
             ~~~~~^~~~    ~~~~^M
/usr/src/svn/sys/modules/drm2/i915kms/../../../dev/drm2/i915/i915_gem.c:1299:12: warning: comparison of address of 'obj->base' equal to a null pointer is always false [-Wtautological-pointer-compare]^M
        if (&obj->base == NULL) {^M
             ~~~~~^~~~    ~~~~^M
/usr/src/svn/sys/modules/drm2/i915kms/../../../dev/drm2/i915/i915_gem.c:1725:12: warning: comparison of address of 'obj->base' equal to a null pointer is always false [-Wtautological-pointer-compare]^M
        if (&obj->base == NULL) {^M
             ~~~~~^~~~    ~~~~^M
/usr/src/svn/sys/modules/drm2/i915kms/../../../dev/drm2/i915/i915_gem.c:3595:12: warning: comparison of address of 'obj->base' equal to a null pointer is always false [-Wtautological-pointer-compare]^M
        if (&obj->base == NULL) {^M
             ~~~~~^~~~    ~~~~^M
--- all_subdir_drm ---^M
--- drm.ko ---^M
ld -d -warn-common -r -d -o drm.ko ati_pcigart.o drm_agpsupport.o drm_auth.o drm_bufs.o drm_context.o drm_dma.o drm_drawable.o drm_drv.o drm_fops.o drm_hashtab.o drm_ioctl.o drm_irq.o drm_lock.o drm_memory.o drm_mm.o drm_pci.o drm_scatter.o drm_sman.o drm_sysctl.o drm_vm.o^M
--- all_subdir_drm2 ---^M
/usr/src/svn/sys/modules/drm2/i915kms/../../../dev/drm2/i915/i915_gem.c:3632:12: warning: comparison of address of 'obj->base' equal to a null pointer is always false [-Wtautological-pointer-compare]^M
        if (&obj->base == NULL) {^M
             ~~~~~^~~~    ~~~~^M
/usr/src/svn/sys/modules/drm2/i915kms/../../../dev/drm2/i915/i915_gem.c:3685:12: warning: comparison of address of 'obj->base' equal to a null pointer is always false [-Wtautological-pointer-compare]^M
        if (&obj->base == NULL) {^M
             ~~~~~^~~~    ~~~~^M
--- all_subdir_drm ---^M
--- all_subdir_i915kms ---^M
/usr/src/svn/sys/modules/drm2/i915kms/../../../dev/drm2/i915/i915_gem_execbuffer.c:798:13: warning: comparison of address of 'obj->base' equal to a null pointer is always false [-Wtautological-pointer-compare]^M
                if (&obj->base == NULL) {^M
                     ~~~~~^~~~    ~~~~^M
--- all_subdir_i915kms ---^M
/usr/src/svn/sys/modules/drm2/i915kms/../../../dev/drm2/i915/i915_gem_execbuffer.c:1275:13: warning: comparison of address of 'obj->base' equal to a null pointer is always false [-Wtautological-pointer-compare]^M
                if (&obj->base == NULL) {^M
                     ~~~~~^~~~    ~~~~^M
--- all_subdir_i915kms ---^M
/usr/src/svn/sys/modules/drm2/i915kms/../../../dev/drm2/i915/i915_gem_tiling.c:311:12: warning: comparison of address of 'obj->base' equal to a null pointer is always false [-Wtautological-pointer-compare]^M
        if (&obj->base == NULL)^M
             ~~~~~^~~~    ~~~~^M
/usr/src/svn/sys/modules/drm2/i915kms/../../../dev/drm2/i915/i915_gem_tiling.c:418:12: warning: comparison of address of 'obj->base' equal to a null pointer is always false [-Wtautological-pointer-compare]^M
        if (&obj->base == NULL)^M
             ~~~~~^~~~    ~~~~^M
/usr/src/svn/sys/modules/drm2/i915kms/../../../dev/drm2/i915/intel_display.c:5161:12: warning: comparison of address of 'obj->base' equal to a null pointer is always false [-Wtautological-pointer-compare]^M
        if (&obj->base == NULL)^M
             ~~~~~^~~~    ~~~~^M
/usr/src/svn/sys/modules/drm2/i915kms/../../../dev/drm2/i915/intel_display.c:6731:12: warning: comparison of address of 'obj->base' equal to a null pointer is always false [-Wtautological-pointer-compare]^M
        if (&obj->base == NULL)^M
             ~~~~~^~~~    ~~~~^M
--- all_subdir_drm2 ---^M
/usr/src/svn/sys/modules/drm2/i915kms/../../../dev/drm2/i915/intel_overlay.c:1153:15: warning: comparison of address of 'new_bo->base' equal to a null pointer is always false [-Wtautological-pointer-compare]^M
        if (&new_bo->base == NULL) {^M
             ~~~~~~~~^~~~    ~~~~^M
Comment 1 Ngie Cooper freebsd_committer 2016-01-30 20:31:41 UTC
Uh... hmmm...

 800 /** driver private structure attached to each drm_gem_object */
 801 struct drm_i915_gem_object {
 802         struct drm_gem_object base;
 803
Comment 2 Jean-Sébastien Pédron freebsd_committer 2016-01-31 20:20:26 UTC
Hi!

I guess I will silence this particular warning for DRM (maybe i915 only).

Thank you!
Comment 3 Ngie Cooper freebsd_committer 2016-02-01 06:39:18 UTC
Here's the complete list according to Jenkins, BTW: https://jenkins.freebsd.org/job/FreeBSD_HEAD/95/warnings7Result/package.1163104811/ .

The warnings seem valid though -- why is a scalar being compared against NULL?
Comment 4 Jean-Sébastien Pédron freebsd_committer 2016-02-01 10:22:28 UTC
Yes, the check looks wrong. Some time ago, I verified in later versions of Linux and it was still there. I didn't look again recently if it was fixed. I had no time to report this yet.
Comment 5 Dimitry Andric freebsd_committer 2016-02-02 19:50:59 UTC
Some people add this type of null check as a sort of "defensive programming" practice. For example, if the obj->base member was a pointer instead of an array, you would definitely need such a null check.  So maybe the rationale is 'better safe than sorry'...