qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	qemu-devel@nongnu.org
Cc: Fam Zheng <fam@euphon.net>,
	qemu-trivial@nongnu.org, Hannes Reinecke <hare@suse.com>,
	qemu-block@nongnu.org
Subject: Re: [PATCH 5/6] hw/scsi/megasas: Silent GCC9 duplicated-cond warning
Date: Tue, 7 Jan 2020 17:20:05 +0100	[thread overview]
Message-ID: <e0029fc5-882f-1d63-15e3-1c3dbe9b6a2c@suse.de> (raw)
In-Reply-To: <8e06e74a-901d-acb3-67f0-006732abdba9@redhat.com>

On 1/7/20 3:56 PM, Paolo Bonzini wrote:
> On 18/12/19 05:03, Richard Henderson wrote:
>>>      if (!s->hba_serial) {
>>>          s->hba_serial = g_strdup(MEGASAS_HBA_SERIAL);
>>>      }
>>> -    if (s->fw_sge >= MEGASAS_MAX_SGE - MFI_PASS_FRAME_SIZE) {
>>> +    if (MEGASAS_MAX_SGE > 128
>>> +        && s->fw_sge >= MEGASAS_MAX_SGE - MFI_PASS_FRAME_SIZE) {
>>>          s->fw_sge = MEGASAS_MAX_SGE - MFI_PASS_FRAME_SIZE;
>>>      } else if (s->fw_sge >= 128 - MFI_PASS_FRAME_SIZE) {
>>>          s->fw_sge = 128 - MFI_PASS_FRAME_SIZE;
>>>      } else {
>>>          s->fw_sge = 64 - MFI_PASS_FRAME_SIZE;
>>>      }
>>
>> I'm not keen on this.  It looks to me like the raw 128 case should be removed
>> -- surely that's the point of the symbolic constant.  But I'll defer if a
>> maintainer disagrees.
> 
> I don't really understand this chain of ifs.  Hannes, does it make sense
> to just remove the "if (s->fw_sge >= 128 - MFI_PASS_FRAME_SIZE)" case,
> or does Phil's variation (quoted in the patch fragment above) makes sense?
> 
> Or perhaps this rewrite:
> 
>         max_sge = s->fw_sge + MFI_PASS_FRAME_SIZE;
>         if (max_sge < MEGASAS_MAX_SGE) {
>             if (max_sge < 64) {
>                 error(...);
>             } else {
>                 max_sge = max_sge < 128 ? 64 : 128;
>             }
>         }
> 	s->fw_sge = max_sge - MFI_PASS_FRAME_SIZE;
> 
Yeah, do it.
The original code assumed that one could change MFI_PASS_FRAME_SIZE, but
it turned out not to be possible as it's being hardcoded in the drivers
themselves (even though the interface provides mechanisms to query it).
So we can remove the duplicate lines.
But then I prefer to stick with the define, and avoid having to check
the magic '128' value directly; rather use the define throughout the code.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      Teamlead Storage & Networking
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer


  reply	other threads:[~2020-01-07 16:21 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-17 17:34 [PATCH 0/6] Fix more GCC9 -O3 warnings Philippe Mathieu-Daudé
2019-12-17 17:34 ` [PATCH 1/6] audio/audio: Add missing fall through comment Philippe Mathieu-Daudé
2019-12-18  3:45   ` Richard Henderson
2019-12-18  8:02   ` Aleksandar Markovic
2019-12-18 10:22     ` Philippe Mathieu-Daudé
2019-12-17 17:34 ` [PATCH 2/6] hw/display/tcx: Add missing fall through comments Philippe Mathieu-Daudé
2019-12-18  3:57   ` Richard Henderson
2019-12-18  7:54   ` Aleksandar Markovic
2019-12-18 10:23     ` Philippe Mathieu-Daudé
2019-12-17 17:34 ` [PATCH 3/6] hw/net/imx_fec: Rewrite " Philippe Mathieu-Daudé
2019-12-17 17:55   ` Thomas Huth
2019-12-18 19:35     ` Thomas Huth
2019-12-18  3:45   ` Richard Henderson
2019-12-18  8:00   ` Aleksandar Markovic
2019-12-17 17:34 ` [PATCH 4/6] hw/timer/aspeed_timer: Add a fall through comment Philippe Mathieu-Daudé
2019-12-17 17:54   ` Cédric Le Goater
2019-12-18  8:26   ` Aleksandar Markovic
2019-12-17 17:34 ` [PATCH 5/6] hw/scsi/megasas: Silent GCC9 duplicated-cond warning Philippe Mathieu-Daudé
2019-12-18  4:03   ` Richard Henderson
2019-12-18 17:52     ` Philippe Mathieu-Daudé
2019-12-18 19:02       ` Richard Henderson
2020-01-07 14:56     ` Paolo Bonzini
2020-01-07 16:20       ` Hannes Reinecke [this message]
2019-12-17 17:34 ` [PATCH 6/6] qemu-io-cmds: Silent GCC9 format-overflow warning Philippe Mathieu-Daudé
2019-12-18  4:15   ` Richard Henderson
2019-12-18 17:45     ` Philippe Mathieu-Daudé
2019-12-18 19:21       ` Richard Henderson

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=e0029fc5-882f-1d63-15e3-1c3dbe9b6a2c@suse.de \
    --to=hare@suse.de \
    --cc=fam@euphon.net \
    --cc=hare@suse.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=richard.henderson@linaro.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).