From: William Allen Simpson <william.allen.simpson@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Linux Kernel Developers <linux-kernel@vger.kernel.org>,
Linux Kernel Network Developers <netdev@vger.kernel.org>,
Michael Chan <mchan@broadcom.com>
Subject: Re: [PATCH 1/2] net: tcp_header_len_th and tcp_option_len_th
Date: Wed, 13 Jan 2010 03:53:56 -0500 [thread overview]
Message-ID: <4B4D8A24.4070108@gmail.com> (raw)
In-Reply-To: <4B4CB712.8030806@gmail.com>
Eric Dumazet wrote:
> I type my Changelog text, add my signature, then copy/paste patch from external editor
> (this editor must preserve tabulations of course)
>
That doesn't work properly on a Mac, copying from BBEdit to Thunderbird.
BBEdit preserves tabs and even understands and preserves Unix LF (and
I've been using it for a Unix editor since it was included with Xinu in
early '90s), but the MacOS copy and paste seems to mangle it.
I'll try again someday with Thunderbird 3, when it's had time to mature.
> About cast games, maybe following way is the cleanest one.
>
> int tcp_options_len_th(struct tcphdr *th)
> {
> return tcp_header_len_th(th) - sizeof(*th);
> }
>
If you'd have been one of my C students, you'd have failed the exam
question. That's unsigned int tcp_header_len_th() -- subtracting an
untyped constant could be a negative number (stored in an unsigned).
Then demotion to int (which many compilers truncate to a very large
positive number).
It's one of the reasons that folks used to do all this with macros, so
that the types and truncation were handled well by the compiler.
Of course, this is an inline function, which is more like macros. I've
not studied how gcc works internally since egcs.
Let's keep (int)(th->doff * 4) - sizeof(*th) -- self documenting, and
should work with a wide variety of compilers.
next prev parent reply other threads:[~2010-01-13 8:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-06 21:18 [PATCH 0/2] net: replace buggy tcp_optlen, and cleanup William Allen Simpson
2010-01-06 21:28 ` [PATCH 1/2] net: tcp_header_len_th and tcp_option_len_th William Allen Simpson
2010-01-12 10:40 ` Eric Dumazet
2010-01-12 17:42 ` William Allen Simpson
2010-01-12 17:53 ` Eric Dumazet
2010-01-12 20:27 ` Jarek Poplawski
2010-01-13 8:53 ` William Allen Simpson [this message]
2010-01-13 10:00 ` Eric Dumazet
2010-01-13 11:03 ` William Allen Simpson
2010-01-06 21:37 ` [PATCH 2/2] net: remove old tcp_optlen function William Allen Simpson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B4D8A24.4070108@gmail.com \
--to=william.allen.simpson@gmail.com \
--cc=eric.dumazet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mchan@broadcom.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).