Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Jan 2013 14:32:15 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-net@freebsd.org
Cc:        Alfred Perlstein <bright@mu.org>
Subject:   Re: [PATCH] Don't imply TCP and UDP socket options are bitmasks
Message-ID:  <201301151432.15347.jhb@freebsd.org>
In-Reply-To: <50F483E8.2040107@mu.org>
References:  <201301141550.13577.jhb@freebsd.org> <201301141656.37175.jhb@freebsd.org> <50F483E8.2040107@mu.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Monday, January 14, 2013 5:17:12 pm Alfred Perlstein wrote:
> On 1/14/13 4:56 PM, John Baldwin wrote:
> > On Monday, January 14, 2013 4:42:16 pm Alfred Perlstein wrote:
> >> Wouldn't a comment over the code suffice?
> >>
> >> Something like your email as a header would actually work very nicely!
> >>
> >> I think just using decimal would be more confusing than explicitly
> >> calling it out like:
> >>
> >> /* begin enumerated (not bitmask) socket option specifiers */
> >> #define	TCP_MAXSEG	0x02	/* set maximum segment size */
> >> #define TCP_NOPUSH	0x04	/* don't push last block of write */
> >> #define TCP_NOOPT	0x08	/* don't use TCP options */
> >> #define TCP_MD5SIG	0x10	/* use MD5 digests (RFC2385) */
> >> /* end enumerated socket option specifiers */
> > I have a patch I'll post next which will add a new option as '3'.  I think that
> > will make it more obvious and avoid having new options follow the old pattern.
> >
> Any objection to adding the contents of that email as a comment 
> section?  It really would help.

We don't generally do this for other enumerations like ioctl values as it
is generally obvious to the reader.  I think for UDP having one constant
called '1' should be obvious enough.  TCP might indeed warrany a comment
since it has several existing values that are powers of 2.  How about
this:

/*
 * User-settable options (used with setsockopt).  These are discrete
 * values and should not be masked together.  Many values appear to be
 * bitmasks for legacy reasons.
 */


-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201301151432.15347.jhb>