All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Benjamin <mbenjamin@redhat.com>
To: Willem Jan Withagen <wjw@digiware.nl>
Cc: ceph-devel@vger.kernel.org
Subject: Re: compiling stops at od compare
Date: Sat, 30 Jan 2016 17:57:24 -0500 (EST)	[thread overview]
Message-ID: <959618990.28815879.1454194644164.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <56ACB8FF.5000605@digiware.nl>

Should we use std::min here (that might require a cast, iirc)?

Matt

----- Original Message -----
> From: "Willem Jan Withagen" <wjw@digiware.nl>
> To: ceph-devel@vger.kernel.org
> Sent: Saturday, January 30, 2016 8:22:07 AM
> Subject: compiling stops at od compare
> 
> When trying to compile on CentOS 7, gcc = 4.8.3
> 
> os/bluestore/BlueFS.cc: In member function ‘int
> BlueFS::_read(BlueFS::FileReader*, BlueFS::FileReaderBuffer*, uint64_t,
> size_t, ceph::bufferlist*, char*)’:
> os/bluestore/BlueFS.cc:731:31: warning: comparison between signed and
> unsigned integer expressions [-Wsign-compare]
>      int r = MIN((int)len, left);
> 
> This MIN is used to determine the amount of buffer that is still left
> to be filed.
> And here len and left are both size_t..., suggesting that both cannot be
> negative. So either both need to be promoted/cast, or neither.
> 
> The cast (int)len suggests that len could be negative.
> The part where that could happen is at line 750:
> 
>    off += r;
>     len -= r;
>     ret += r;
> 
> So there the loop exit needs len to be exactly equal to r. Even if the
> loop specifies while(len>0). if len gets "negative" it grows into
> something rather big.
> 
> Now if len never gets negative then it also does not need to get cast to
> int. If it does, then in the unsigned case it will always be larger than
> left.
> 
> So bottomline is that the cast serves no purpose?
> Removing it fixes compilation.
> 
> --WjW
> 
> --
> To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

-- 
-- 
Matt Benjamin
Red Hat, Inc.
315 West Huron Street, Suite 140A
Ann Arbor, Michigan 48103

http://www.redhat.com/en/technologies/storage

tel.  734-707-0660
fax.  734-769-8938
cel.  734-216-5309
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2016-01-30 22:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-30 13:22 compiling stops at od compare Willem Jan Withagen
2016-01-30 22:57 ` Matt Benjamin [this message]
2016-01-30 23:13   ` Willem Jan Withagen
2016-01-31 12:25     ` [patch] " Willem Jan Withagen

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=959618990.28815879.1454194644164.JavaMail.zimbra@redhat.com \
    --to=mbenjamin@redhat.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=wjw@digiware.nl \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.