netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] NET: Remove unneeded type cast in skb_truesize_check()
Date: Mon, 05 Nov 2007 18:59:26 -0500	[thread overview]
Message-ID: <472FAE5E.8030701@oracle.com> (raw)
In-Reply-To: <20071102.142717.157261554.davem@davemloft.net>

[-- Attachment #1: Type: text/plain, Size: 1170 bytes --]

David Miller wrote:
> From: Chuck Lever <chuck.lever@oracle.com>
> Date: Fri, 02 Nov 2007 15:14:26 -0400
> 
>> The (int) type cast in skb_truesize_check() is unneeded: without it, all
>> the variable types in the conditional expression are unsigned integers.  As
>> it stands, the type cast causes a comparison between a signed and an
>> unsigned integer, which can produce unexpected results.
>>
>> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> 
> This is checking for skb->truesize being decremented too much by other
> code, which could cause a wraparound below zero, so we do want
> negaitve checks here.

If that's truly the case, document the requirement (perhaps using
something the compiler itself can verify) instead of using a clever
type cast trick.

Here's the problem with leaving these little surprises in commonly used 
kernel headers.  Suppose the developer of a network driver or network 
file system that uses one of these headers wants to employ static code 
analysis to identify issues introduced by new patches to their 
subsystem.  The tool warnings generated in kernel headers are just 
noise, and make using such code analysis difficult.

[-- Attachment #2: chuck.lever.vcf --]
[-- Type: text/x-vcard, Size: 259 bytes --]

begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Oracle Corporation;Corporate Architecture: Linux Projects Group
adr:;;1015 Granger Avenue;Ann Arbor;MI;48104;USA
title:Principal Member of Staff
tel;work:+1 248 614 5091
x-mozilla-html:FALSE
version:2.1
end:vcard


  reply	other threads:[~2007-11-06  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-02 19:14 [PATCH] NET: Remove unneeded type cast in skb_truesize_check() Chuck Lever
2007-11-02 21:27 ` David Miller
2007-11-05 23:59   ` Chuck Lever [this message]
2007-11-06  0:33     ` David Miller
2007-11-07 15:11       ` Chuck Lever
2007-11-08  0:15         ` David Miller

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=472FAE5E.8030701@oracle.com \
    --to=chuck.lever@oracle.com \
    --cc=davem@davemloft.net \
    --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).