SUN_LEN(addr) vs. SUN_LEN(addr) + 1.

Nine Forty pm940 at yahoo.com
Wed Mar 2 14:26:31 PST 2005


/usr/include/sys/un.h says:

/*
 * Definitions for UNIX IPC domain.
 */
struct  sockaddr_un {
        u_char  sun_len;                /* sockaddr
len including null */
        u_char  sun_family;             /* AF_UNIX */
        char    sun_path[104];          /* path name
(gag) */
};


... but it also says:

/* actual length of an initialized sockaddr_un */
#define SUN_LEN(su) \
        (sizeof(*(su)) - sizeof((su)->sun_path) +
strlen((su)->sun_path))


Which doesn't include the nul at the end of sun_path.


When calling bind(2) or sendmsg(2), is SUN_LEN(addr)
valid, or should it be SUN_LEN(addr) + 1?  Various
programs under /usr/src use plain SUN_LEN(addr).

Is there a problem with the comment, the macro, the
applications, or none of the above?


Thanks.



	
		
__________________________________ 
Celebrate Yahoo!'s 10th Birthday! 
Yahoo! Netrospective: 100 Moments of the Web 
http://birthday.yahoo.com/netrospective/


More information about the freebsd-questions mailing list