qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Fam Zheng <famz@redhat.com>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] scsi: Don't deference in_buf if NULL
Date: Thu, 4 Jan 2018 11:02:25 -0600	[thread overview]
Message-ID: <a288c5a1-e9ff-b50a-ee1e-1b48ab29e31a@redhat.com> (raw)
In-Reply-To: <20180104024228.11780-1-famz@redhat.com>

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

On 01/03/2018 08:42 PM, Fam Zheng wrote:
> scsi_disk_emulate_command passes in_buf=NULL and in_len=0 in the
> REQUEST_SENSE branch. Inline the fixed_in evaluation and put it after
> the in_len test.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  scsi/utils.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/scsi/utils.c b/scsi/utils.c
> index ddae650a99..9a0a925ef9 100644
> --- a/scsi/utils.c
> +++ b/scsi/utils.c
> @@ -320,10 +320,8 @@ int scsi_convert_sense(uint8_t *in_buf, int in_len,
>                         uint8_t *buf, int len, bool fixed)
>  {
>      SCSISense sense;
> -    bool fixed_in;
>  
> -    fixed_in = (in_buf[0] & 2) == 0;
> -    if (in_len && fixed == fixed_in) {
> +    if (in_len && !!fixed == ((in_buf[0] & 2) == 0)) {

Huh?  'fixed' is already a bool, so '!!fixed' is just extra typing that
makes things harder to read.  Did you mean:

if (in_len && fixed == !(in_buf[0] & 2))

as something that is slightly more legible (the LHS is already bool, the
RHS uses a single ! to convert a bitwise test into a bool with the
correct sense)?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

  reply	other threads:[~2018-01-04 17:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-04  2:42 [Qemu-devel] [PATCH] scsi: Don't deference in_buf if NULL Fam Zheng
2018-01-04 17:02 ` Eric Blake [this message]
2018-01-05 16:45   ` Anthoine Bourgeois
2018-01-04 17:41 ` Eric Blake
2018-01-05  1:49   ` Fam Zheng

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=a288c5a1-e9ff-b50a-ee1e-1b48ab29e31a@redhat.com \
    --to=eblake@redhat.com \
    --cc=famz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.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).