• Nils Goroll's avatar
    Add VSA_getsockname() · 2b63ee2d
    Nils Goroll authored
    Flexelint on Linux exhibits exactly the problem described by phk in
    his rant at the top of vsa.c, quote:
    
    	Do I need to tell you that static code analysis tools have a
    	really hard time coping with (struct suckaddr_storage), and
    	that they give a lot of false negatives which confuse people ?
    
    One instance of this issue:
    
    --- Module:   cache/cache_acceptor.c (C)
                                                   _
     #... _assert(!!((getsockname(sp->fd, (void*)&ss, &sl)) == 0)) /*lint -restore *
     #... getsockname(sp->fd, (void*)&ss, &sl)) == 0); } while (0)
    	AZ(getsockname(sp->fd, (void*)&ss, &sl));
    cache/cache_acceptor.c  330  Error 64: Type mismatch (arg. no. 2) (union
        __SOCKADDR_ARG = void *)
                                     _
     #... SA_Build(sa, &ss, sl)) != 0); } while (0)
    	AN(VSA_Build(sa, &ss, sl));
    cache/cache_acceptor.c  332  Warning 603: Symbol 'ss' (line 318) not
        initialized
    cache/cache_acceptor.c  318  Info 830: Location cited in prior message
                                                                      _
    			i = accept(ls->sock, (void*)&wa.acceptaddr,
    cache/cache_acceptor.c  458  Error 64: Type mismatch (arg. no. 2) (union
        __SOCKADDR_ARG = void *)
    
    There is one more in cache/cache_backend_probe.c
    
    As the purpose of VSA is to avoid exactly this kind of trouble, we
    provide a VSA-wrapper for getsockname.
    2b63ee2d
vsa.h 2.93 KB