[RFC]: tautological compares in amd64 GENERIC

From: Roman Divacky <rdivacky_at_freebsd.org>
Date: Mon, 17 Jan 2011 19:56:15 +0100
hi,

clang found these problems in our amd64 GENERIC:

some of these may be real bugs lurking in our code - can the respective owners
of the subsystems take a look? The bugs cover all areas from ufs/vm to 
net*/security.

Thank you!

roman

cam/cam_periph.c:530:28: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
        else if (periph->refcount < 0)
                 ~~~~~~~~~~~~~~~~ ^ ~

kern/uipc_syscalls.c:347:16: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
                if (*namelen < 0)
                    ~~~~~~~~ ^ ~

kern/uipc_syscalls.c:1472:12: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
        if (*alen < 0)
            ~~~~~ ^ ~

kern/uipc_syscalls.c:1572:12: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
        if (*alen < 0)
            ~~~~~ ^ ~

ufs/ffs/ffs_inode.c:538:24: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
        if (DIP(ip, i_blocks) < 0)                      /* sanity */
            ~~~~~~~~~~~~~~~~~ ^ ~

ufs/ufs/ufs_quota.c:329:44: warning: comparison of unsigned expression >= 0 is always true [-Wtautological-compare]
                        if (dq->dq_curinodes != 0 && ncurinodes >= 0)
                                                     ~~~~~~~~~~ ^  ~

ufs/ufs/ufs_quota.c:367:21: warning: comparison of unsigned expression >= 0 is always true [-Wtautological-compare]
                                            ncurinodes >= 0)
                                            ~~~~~~~~~~ ^  ~

vm/vm_pageout.c:1701:14: warning: comparison of unsigned expression >= 0 is always true [-Wtautological-compare]
                        if (limit >= 0 && size >= limit) {
                            ~~~~~ ^  ~

amd64/amd64/sys_machdep.c:562:16: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
                    uap->num < 0 || largest_ld > max_ldt_segment)
                    ~~~~~~~~ ^ ~


netinet6/in6_mcast.c:1849:30: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
                        if (mreq.ipv6mr_interface < 0 ||
                            ~~~~~~~~~~~~~~~~~~~~~ ^ ~

netinet6/in6_mcast.c:2196:15: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
                if (ifindex < 0 || V_if_index < ifindex)
                    ~~~~~~~ ^ ~

netinet6/in6_mcast.c:2354:14: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
        if (ifindex < 0 || V_if_index < ifindex)
            ~~~~~~~ ^ ~

netinet6/ip6_output.c:2542:29: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
                    pktinfo->ipi6_ifindex < 0) {
                    ~~~~~~~~~~~~~~~~~~~~~ ^ ~

netinet6/scope6.c:391:15: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
                        if (zoneid < 0 || V_if_index < zoneid)
                            ~~~~~~ ^ ~

security/audit/audit_syscalls.c:306:39: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
                            (udata.au_qctrl64.aq64_minfree < 0) ||


security/mac/mac_framework.c:589:20: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
        if (mac->m_buflen < 0 ||
            ~~~~~~~~~~~~~ ^ ~

dev/acpica/acpi_pci.c:284:24: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
        if (pcib_get_bus(dev) < 0)
            ~~~~~~~~~~~~~~~~~ ^ ~

dev/buslogic/bt.c:978:16: warning: comparison of unsigned enum expression >= 0 is always true [-Wtautological-compare]
        if (bio_index >= 0 && bio_index < BT_NUM_ISAPORTS)
            ~~~~~~~~~ ^  ~

dev/cs/if_cs.c:367:12: warning: comparison of unsigned expression >= 0 is always true [-Wtautological-compare]
                        if (irq >= 0 || irq < 16)
                            ~~~ ^  ~

dev/sym/sym_hipd.c:3449:10: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
        if (fak < 0)    {fak = 0; ret = -1;}
            ~~~ ^ ~

dev/usb/serial/usb_serial.c:1056:18: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
        if (t->c_ospeed < 0) {
            ~~~~~~~~~~~ ^ ~




Received on Mon Jan 17 2011 - 17:56:18 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:10 UTC