Re: lsof vs. clang

From: Niclas Zeising <zeising_at_daemonic.se>
Date: Tue, 06 Nov 2012 15:14:31 +0100
On 11/06/12 14:42, Larry Rosenman wrote:
> It appears that we've (mostly) cleaned up the clang/system interface
> such that sysutils/lsof works with cc as clang.
>
> Can someone tell me what we need to do to shut these up?
>
>
> # LSOFCC=cc CC=cc make LSOFCC=cc CC=cc
> ===> lsof-4.87.a,7 depends on file: /usr/local/sbin/pkg - found
> ===> Extracting for lsof-4.87.a,7
> => SHA256 Checksum OK for lsof_4.87A.freebsd.tar.bz2.
> ===> Patching for lsof-4.87.a,7
> ===> Configuring for lsof-4.87.a,7
> Creating ./lockf_owner.h from /usr/src/sys/kern/kern_lockf.c
> ./lockf_owner.h creation succeeded.
> rm -f ddev.c dfile.c dlsof.h dmnt.c dnode*.c dproc.c dproto.h dsock.c
> dstore.c dzfs.h kernelbase.h machine.h machine.h.old new_machine.h
> __lseek.s Makefile Makefile.zfs ./tests/config.cflags
> rm -f ./tests/config.cc ./tests/config.xobj ./tests/config.ldflags
> Testing C library for localtime() and strftime(), using cc ... present
> ln -s dialects/freebsd/dlsof.h dlsof.h
> ln -s dialects/freebsd/dmnt.c dmnt.c
> ln -s dialects/freebsd/dnode.c dnode.c
> ln -s dialects/freebsd/dnode1.c dnode1.c
> ln -s dialects/freebsd/dnode2.c dnode2.c
> ln -s dialects/freebsd/dproc.c dproc.c
> ln -s dialects/freebsd/dproto.h dproto.h
> ln -s dialects/freebsd/dsock.c dsock.c
> ln -s dialects/freebsd/dstore.c dstore.c
> ln -s dialects/freebsd/dzfs.h dzfs.h
> ln -s dialects/freebsd/machine.h machine.h
> Makefile and lib/Makefile created.
> Makefile.zfs created.
> ./tests/config.cc created
> ./tests/config.cflags created
> ./tests/config.ldflags created
> ./tests/config.xobj created
> ===> Building for lsof-4.87.a,7
> (cd lib; make DEBUG="-O2" CFGF="-pipe -fno-omit-frame-pointer
> -fno-strict-aliasing -fno-omit-frame-pointer -DHASEFFNLINK=i_effnlink
> -DHASF_VNODE -DHASSBSTATE -DHAS_KVM_VNODE -DHAS_UFS1_2
> -DHAS_VM_MEMATTR_T -DHAS_CDEV2PRIV -DHAS_NO_SI_UDEV -DHAS_SYS_SX_H
> -DHAS_ZFS -DHAS_V_LOCKF -DHAS_LOCKF_ENTRY -DHAS_NO_6PORT -DHAS_NO_6PPCB
> -DNEEDS_BOOLEAN_T -DFREEBSDV=10000 -DHASFDESCFS=2 -DHASPSEUDOFS
> -DHASNULLFS -DHASIPv6 -DHASUTMPX -DHAS_STRFTIME
> -DLSOF_VSTR=\"10.0-CURRENT\"")
> cc -pipe -fno-omit-frame-pointer -fno-strict-aliasing
> -fno-omit-frame-pointer -DHASEFFNLINK=i_effnlink -DHASF_VNODE
> -DHASSBSTATE -DHAS_KVM_VNODE -DHAS_UFS1_2 -DHAS_VM_MEMATTR_T
> -DHAS_CDEV2PRIV -DHAS_NO_SI_UDEV -DHAS_SYS_SX_H -DHAS_ZFS -DHAS_V_LOCKF
> -DHAS_LOCKF_ENTRY -DHAS_NO_6PORT -DHAS_NO_6PPCB -DNEEDS_BOOLEAN_T
> -DFREEBSDV=10000 -DHASFDESCFS=2 -DHASPSEUDOFS -DHASNULLFS -DHASIPv6
> -DHASUTMPX -DHAS_STRFTIME -DLSOF_VSTR="10.0-CURRENT" -I/usr/src/sys -O2
> -c ckkv.c
> In file included from ckkv.c:43:
> In file included from ./../lsof.h:195:
> In file included from ./../dlsof.h:190:
> In file included from /usr/src/sys/ufs/ufs/ufsmount.h:36:
> /usr/src/sys/sys/buf.h:392:2: warning: implicit declaration of function
> 'KASSERT' is invalid in C99 [-Wimplicit-function-declaration]
> KASSERT(bp->b_bufobj != NULL, ("bwrite: no bufobj bp=%p", bp));
> ^
As this hints on, KASSERT is undeclared.  You should either declare 
KASSERT manually or include the proper header file.
With that said, KASSERT look very much like kernel code, and should 
probably not be used in userland utilities at all, but I am no expert on 
this.
> /usr/src/sys/sys/buf.h:392:33: warning: expression result unused
> [-Wunused-value]
> KASSERT(bp->b_bufobj != NULL, ("bwrite: no bufobj bp=%p", bp));
> ^~~~~~~~~~~~~~~~~~~~~~~~~
> /usr/src/sys/sys/buf.h:393:41: warning: expression result unused
> [-Wunused-value]
> KASSERT(bp->b_bufobj->bo_ops != NULL, ("bwrite: no bo_ops bp=%p", bp));
> ^~~~~~~~~~~~~~~~~~~~~~~~~
> /usr/src/sys/sys/buf.h:395:7: warning: expression result unused
> [-Wunused-value]
> ("bwrite: no bop_write bp=%p", bp));
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /usr/src/sys/sys/buf.h:403:33: warning: expression result unused
> [-Wunused-value]
> KASSERT(bp->b_bufobj != NULL, ("bstrategy: no bufobj bp=%p", bp));
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /usr/src/sys/sys/buf.h:405:7: warning: expression result unused
> [-Wunused-value]
> ("bstrategy: no bo_ops bp=%p", bp));
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /usr/src/sys/sys/buf.h:407:7: warning: expression result unused
> [-Wunused-value]
> ("bstrategy: no bop_strategy bp=%p", bp));
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 7 warnings generated.

The rest of the warnings are probably follow-up warnings since clang 
doesn't know the function prototype for KASSERT.
Regards!
-- 
Niclas Zeising
Received on Tue Nov 06 2012 - 13:15:02 UTC

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