public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Claudio Imbrenda <imbrenda@linux.ibm.com>,
	Janosch Frank <frankja@linux.ibm.com>
Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org,
	david@redhat.com, borntraeger@de.ibm.com
Subject: Re: [kvm-unit-tests PATCH v2 5/5] s390x: SCLP unit test
Date: Fri, 8 Nov 2019 10:35:32 +0100	[thread overview]
Message-ID: <b4344967-54d2-5b57-8d36-dd1361654c8e@redhat.com> (raw)
In-Reply-To: <20191104121901.3b3ab68b@p-imbrenda.boeblingen.de.ibm.com>

On 04/11/2019 12.19, Claudio Imbrenda wrote:
> On Mon, 4 Nov 2019 10:45:07 +0100
> Janosch Frank <frankja@linux.ibm.com> wrote:
[...]
>>> +static void test_toolong(void)
>>> +{
>>> +	uint32_t cmd = SCLP_CMD_WRITE_EVENT_DATA;
>>> +	uint16_t res = SCLP_RC_SCCB_BOUNDARY_VIOLATION;
>>
>> Why use variables for constants that are never touched?
> 
> readability mostly. the names of the constants are rather long.
> the compiler will notice it and do the Right Thing™

I'd like to suggest to add the "const" keyword to both variables in that 
case, then it's clear that they are not used to be modified.

>>> +		h->length = 4096;
>>> +
>>> +		valid_code = commands[i];
>>> +		cc = sclp_service_call(commands[i], h);
>>> +		if (cc)
>>> +			break;
>>> +		if (h->response_code ==
>>> SCLP_RC_NORMAL_READ_COMPLETION)
>>> +			return;
>>> +		if (h->response_code !=
>>> SCLP_RC_INVALID_SCLP_COMMAND)
>>> +			break;
>>
>> Depending on line length you could add that to the cc check.
>> Maybe you could also group the error conditions before the success
>> conditions or the other way around.
> 
> yeah it woud fit, but I'm not sure it would be more readable:
> 
> if (cc || (h->response_code != SCLP_RC_INVALID_SCLP_COMMAND))
>                          break;

In case you go with that solution, please drop the innermost parentheses.

  Thomas

  reply	other threads:[~2019-11-08  9:35 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-25 17:06 [kvm-unit-tests PATCH v2 0/5] s390x: SCLP Unit test Claudio Imbrenda
2019-10-25 17:06 ` [kvm-unit-tests PATCH v2 1/5] s390x: remove redundant defines Claudio Imbrenda
2019-10-25 17:06 ` [kvm-unit-tests PATCH v2 2/5] s390x: improve error reporting for interrupts Claudio Imbrenda
2019-10-25 17:06 ` [kvm-unit-tests PATCH v2 3/5] s390x: sclp: expose ram_size and max_ram_size Claudio Imbrenda
2019-11-04  9:22   ` Janosch Frank
2019-10-25 17:06 ` [kvm-unit-tests PATCH v2 4/5] s390x: sclp: add service call instruction wrapper Claudio Imbrenda
2019-11-04  9:22   ` Janosch Frank
2019-11-04 10:06   ` David Hildenbrand
2019-10-25 17:06 ` [kvm-unit-tests PATCH v2 5/5] s390x: SCLP unit test Claudio Imbrenda
2019-11-04  9:45   ` Janosch Frank
2019-11-04 11:19     ` Claudio Imbrenda
2019-11-08  9:35       ` Thomas Huth [this message]
2019-11-08  9:46         ` Claudio Imbrenda
2019-11-04 10:58   ` David Hildenbrand
2019-11-04 11:29     ` Claudio Imbrenda
2019-11-04 11:31       ` David Hildenbrand
2019-11-04 11:49         ` Claudio Imbrenda
2019-11-04 11:55           ` David Hildenbrand
2019-11-04 12:06             ` Claudio Imbrenda
2019-11-04 13:47               ` David Hildenbrand
2019-11-04 14:24                 ` Claudio Imbrenda
2019-11-04 14:29                   ` David Hildenbrand
2019-11-04 10:10 ` [kvm-unit-tests PATCH v2 0/5] s390x: SCLP Unit test David Hildenbrand

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=b4344967-54d2-5b57-8d36-dd1361654c8e@redhat.com \
    --to=thuth@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.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