xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	xen-devel@lists.xenproject.org, ian.campbell@citrix.com,
	ian.jackson@eu.citrix.com, jbeulich@suse.com, tim@xen.org,
	keir@xen.org
Subject: Re: [PATCH v1 3/3] blktap2: Silence warnings under GCC 5.1.1
Date: Mon, 5 Oct 2015 09:49:07 +0100	[thread overview]
Message-ID: <56123983.5040406@citrix.com> (raw)
In-Reply-To: <1443897590-5663-4-git-send-email-konrad.wilk@oracle.com>

On 03/10/15 19:39, Konrad Rzeszutek Wilk wrote:
> I get compile warnings telling me that
>    s->connections[i].fd == fd
>
> 'i' may be past the array. Adding in an extra condition
> on the loop fixes that.
>
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

Furthermore, I can't see any logic which prevents s->connected getting
larger than MAX_CONNECTIONS

> ---
>  tools/blktap2/drivers/block-log.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/blktap2/drivers/block-log.c b/tools/blktap2/drivers/block-log.c
> index 5330cdc..1934227 100644
> --- a/tools/blktap2/drivers/block-log.c
> +++ b/tools/blktap2/drivers/block-log.c
> @@ -359,7 +359,7 @@ static int ctl_close_sock(struct tdlog_state* s, int fd)
>  {
>    int i;
>  
> -  for (i = 0; i < s->connected; i++) {
> +  for (i = 0; i < s->connected && i < MAX_CONNECTIONS; i++) {
>      if (s->connections[i].fd == fd) {
>        tapdisk_server_unregister_event(s->connections[i].id);
>        close(s->connections[i].fd);
> @@ -545,7 +545,7 @@ static inline int ctl_find_connection(struct tdlog_state *s, event_id_t id)
>  {
>    int i;
>  
> -  for (i = 0; i < s->connected; i++)
> +  for (i = 0; i < s->connected && i < MAX_CONNECTIONS; i++)
>      if (s->connections[i].id == id)
>        return s->connections[i].fd;
>  

  reply	other threads:[~2015-10-05  8:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-03 18:39 [PATCH] Various fixes - libelf, paging, blktap Konrad Rzeszutek Wilk
2015-10-03 18:39 ` [PATCH v1 1/3] libelf: Preserve log callback after elf_init Konrad Rzeszutek Wilk
2015-10-05 10:36   ` Jan Beulich
2015-10-05 14:23     ` Konrad Rzeszutek Wilk
2015-10-05 14:39       ` Jan Beulich
2015-10-05 14:48         ` Konrad Rzeszutek Wilk
2015-10-03 18:39 ` [PATCH v1 2/3] paging: Fix compile error when DEBUG_TRACE_DUMP is enabled Konrad Rzeszutek Wilk
2015-10-05  8:46   ` Andrew Cooper
2015-10-03 18:39 ` [PATCH v1 3/3] blktap2: Silence warnings under GCC 5.1.1 Konrad Rzeszutek Wilk
2015-10-05  8:49   ` Andrew Cooper [this message]
2015-10-05 10:46     ` Jan Beulich
2015-10-05 14:26       ` Konrad Rzeszutek Wilk
2015-10-05 14:46         ` Jan Beulich
2015-10-05 14:57           ` Konrad Rzeszutek Wilk
2015-10-05 15:02             ` Jan Beulich

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=56123983.5040406@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=keir@xen.org \
    --cc=konrad.wilk@oracle.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xenproject.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).