From: Dan Carpenter <dan.carpenter@oracle.com>
To: walter harms <wharms@bfs.de>
Cc: "Nicholas A. Bellinger" <nab@linux-iscsi.org>,
Andy Grover <agrover@redhat.com>, Christoph Hellwig <hch@lst.de>,
linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [patch] target/iscsi: precedence bug in iscsit_set_dataout_sequence_values()
Date: Tue, 02 Oct 2012 12:27:00 +0000 [thread overview]
Message-ID: <20121002122700.GF13767@mwanda> (raw)
In-Reply-To: <506AD4A9.2050702@bfs.de>
On Tue, Oct 02, 2012 at 01:48:57PM +0200, walter harms wrote:
>
>
> Am 02.10.2012 10:22, schrieb Dan Carpenter:
> > Clang warns about this bug:
> > drivers/target/iscsi/iscsi_target_erl0.c:52:45: warning: operator '?:'
> > has lower precedence than '+'; '+' will be evaluated first
> > [-Wparentheses]
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > Please review this very carefully because I haven't tested it. It could
> > be that the check should be:
> > (data_done + data_length > FirstBurstLength) ? FirstBurstLength : data_length);
> > Instead of what I have which is:
> > data_done + (data_length > FirstBurstLength ? FirstBurstLength : data_length);
> >
> > diff --git a/drivers/target/iscsi/iscsi_target_erl0.c b/drivers/target/iscsi/iscsi_target_erl0.c
> > index 1a02016..2067efd 100644
> > --- a/drivers/target/iscsi/iscsi_target_erl0.c
> > +++ b/drivers/target/iscsi/iscsi_target_erl0.c
> > @@ -48,9 +48,9 @@ void iscsit_set_dataout_sequence_values(
> > if (cmd->unsolicited_data) {
> > cmd->seq_start_offset = cmd->write_data_done;
> > cmd->seq_end_offset = (cmd->write_data_done +
> > - (cmd->se_cmd.data_length >
> > - conn->sess->sess_ops->FirstBurstLength) ?
> > - conn->sess->sess_ops->FirstBurstLength : cmd->se_cmd.data_length);
> > + ((cmd->se_cmd.data_length >
> > + conn->sess->sess_ops->FirstBurstLength) ?
> > + conn->sess->sess_ops->FirstBurstLength : cmd->se_cmd.data_length));
> > return;
> > }
> >
>
> the ?: operator is nice but at a certain length is starts to become unreadable,
> the end is normally calculated by end= start+len; Therefor i suggest:
>
> if ( cmd->se_cmd.data_length > conn->sess->sess_ops->FirstBurstLength )
> cmd->seq_end_offset = cmd->seq_start_offset + conn->sess->sess_ops->FirstBurstLength;
> else
> cmd->seq_end_offset = cmd->seq_start_offset + cmd->se_cmd.data_length;
>
Yeah. It's not beautiful.
Doing a "struct iscsi_sess_ops *ops = conn->sess->sess_ops;" at the
start of the function would help as well.
regards,
dan carpenter
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: walter harms <wharms@bfs.de>
Cc: "Nicholas A. Bellinger" <nab@linux-iscsi.org>,
Andy Grover <agrover@redhat.com>, Christoph Hellwig <hch@lst.de>,
linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [patch] target/iscsi: precedence bug in iscsit_set_dataout_sequence_values()
Date: Tue, 2 Oct 2012 15:27:00 +0300 [thread overview]
Message-ID: <20121002122700.GF13767@mwanda> (raw)
In-Reply-To: <506AD4A9.2050702@bfs.de>
On Tue, Oct 02, 2012 at 01:48:57PM +0200, walter harms wrote:
>
>
> Am 02.10.2012 10:22, schrieb Dan Carpenter:
> > Clang warns about this bug:
> > drivers/target/iscsi/iscsi_target_erl0.c:52:45: warning: operator '?:'
> > has lower precedence than '+'; '+' will be evaluated first
> > [-Wparentheses]
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > Please review this very carefully because I haven't tested it. It could
> > be that the check should be:
> > (data_done + data_length > FirstBurstLength) ? FirstBurstLength : data_length);
> > Instead of what I have which is:
> > data_done + (data_length > FirstBurstLength ? FirstBurstLength : data_length);
> >
> > diff --git a/drivers/target/iscsi/iscsi_target_erl0.c b/drivers/target/iscsi/iscsi_target_erl0.c
> > index 1a02016..2067efd 100644
> > --- a/drivers/target/iscsi/iscsi_target_erl0.c
> > +++ b/drivers/target/iscsi/iscsi_target_erl0.c
> > @@ -48,9 +48,9 @@ void iscsit_set_dataout_sequence_values(
> > if (cmd->unsolicited_data) {
> > cmd->seq_start_offset = cmd->write_data_done;
> > cmd->seq_end_offset = (cmd->write_data_done +
> > - (cmd->se_cmd.data_length >
> > - conn->sess->sess_ops->FirstBurstLength) ?
> > - conn->sess->sess_ops->FirstBurstLength : cmd->se_cmd.data_length);
> > + ((cmd->se_cmd.data_length >
> > + conn->sess->sess_ops->FirstBurstLength) ?
> > + conn->sess->sess_ops->FirstBurstLength : cmd->se_cmd.data_length));
> > return;
> > }
> >
>
> the ?: operator is nice but at a certain length is starts to become unreadable,
> the end is normally calculated by end= start+len; Therefor i suggest:
>
> if ( cmd->se_cmd.data_length > conn->sess->sess_ops->FirstBurstLength )
> cmd->seq_end_offset = cmd->seq_start_offset + conn->sess->sess_ops->FirstBurstLength;
> else
> cmd->seq_end_offset = cmd->seq_start_offset + cmd->se_cmd.data_length;
>
Yeah. It's not beautiful.
Doing a "struct iscsi_sess_ops *ops = conn->sess->sess_ops;" at the
start of the function would help as well.
regards,
dan carpenter
next prev parent reply other threads:[~2012-10-02 12:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-02 8:22 [patch] target/iscsi: precedence bug in iscsit_set_dataout_sequence_values() Dan Carpenter
2012-10-02 8:22 ` Dan Carpenter
2012-10-02 11:48 ` walter harms
2012-10-02 11:48 ` walter harms
2012-10-02 12:27 ` Dan Carpenter [this message]
2012-10-02 12:27 ` Dan Carpenter
2012-10-02 20:30 ` Nicholas A. Bellinger
2012-10-02 20:30 ` Nicholas A. Bellinger
2012-10-03 8:00 ` walter harms
2012-10-03 8:00 ` walter harms
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=20121002122700.GF13767@mwanda \
--to=dan.carpenter@oracle.com \
--cc=agrover@redhat.com \
--cc=hch@lst.de \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=nab@linux-iscsi.org \
--cc=target-devel@vger.kernel.org \
--cc=wharms@bfs.de \
/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.