From: Markus Elfring <Markus.Elfring@web.de>
To: Paolo Bonzini <pbonzini@redhat.com>,
Xianting Tian <xianting_tian@126.com>,
linux-scsi@vger.kernel.org,
virtualization@lists.linux-foundation.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
"James E. J. Bottomley" <jejb@linux.ibm.com>,
Jason Wang <jasowang@redhat.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [PATCH] scsi: virtio_scsi: Remove unnecessary condition checks
Date: Fri, 10 Jul 2020 06:32:33 +0000 [thread overview]
Message-ID: <8eb9a827-45f1-e71c-0cbf-1c29acd8e310@web.de> (raw)
In-Reply-To: <e87746e6-813e-7c0e-e21e-5921e759da5d@redhat.com>
>>> + mempool_destroy(virtscsi_cmd_pool);
>>> + virtscsi_cmd_pool = NULL;
>>> + kmem_cache_destroy(virtscsi_cmd_cache);
>>> + virtscsi_cmd_cache = NULL;
>>> return ret;
>>> }
>>
>> How do you think about to add a jump target so that the execution
>> of a few statements can be avoided according to a previous
>> null pointer check?
>
> The point of the patch is precisely to simplify the code,
I suggest to reconsider also Linux coding style aspects
for the implementation of the function “init”.
https://elixir.bootlin.com/linux/v5.8-rc4/source/drivers/scsi/virtio_scsi.c#L980
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/scsi/virtio_scsi.c?id=42f82040ee66db13525dc6f14b8559890b2f4c1c#n980
if (!virtscsi_cmd_cache) {
pr_err("kmem_cache_create() for virtscsi_cmd_cache failed\n");
- goto error;
+ return -ENOMEM;
}
See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=42f82040ee66db13525dc6f14b8559890b2f4c1c#n461
> executing a couple more instruction is not an issue.
With which update steps would like to achieve such a code variant?
destroy_pool:
mempool_destroy(virtscsi_cmd_pool);
virtscsi_cmd_pool = NULL;
destroy_cache:
kmem_cache_destroy(virtscsi_cmd_cache);
virtscsi_cmd_cache = NULL;
return ret;
Regards,
Markus
next prev parent reply other threads:[~2020-07-10 6:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-09 17:16 [PATCH] scsi: virtio_scsi: Remove unnecessary condition checks Markus Elfring
2020-07-09 17:25 ` Paolo Bonzini
2020-07-09 20:55 ` Markus Elfring
2020-07-10 6:32 ` Markus Elfring [this message]
2020-07-10 7:17 ` Paolo Bonzini
2020-07-10 7:40 ` Markus Elfring
2020-07-10 7:46 ` Paolo Bonzini
2020-07-10 8:11 ` Markus Elfring
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=8eb9a827-45f1-e71c-0cbf-1c29acd8e310@web.de \
--to=markus.elfring@web.de \
--cc=jasowang@redhat.com \
--cc=jejb@linux.ibm.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=xianting_tian@126.com \
/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).