* [PATCH] virtio-blk: do not use C99 mixed declarations
@ 2024-02-06 14:04 Stefan Hajnoczi
2024-02-06 15:14 ` Hanna Czenczek
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2024-02-06 14:04 UTC (permalink / raw)
To: qemu-devel
Cc: Hanna Reitz, qemu-block, Stefan Hajnoczi, Michael S. Tsirkin,
Kevin Wolf
QEMU's coding style generally forbids C99 mixed declarations.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
hw/block/virtio-blk.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 227d83569f..f6009cd9b3 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -661,16 +661,16 @@ static void virtio_blk_zone_report_complete(void *opaque, int ret)
int64_t zrp_size, n, j = 0;
int64_t nz = data->zone_report_data.nr_zones;
int8_t err_status = VIRTIO_BLK_S_OK;
-
- trace_virtio_blk_zone_report_complete(vdev, req, nz, ret);
- if (ret) {
- err_status = VIRTIO_BLK_S_ZONE_INVALID_CMD;
- goto out;
- }
-
struct virtio_blk_zone_report zrp_hdr = (struct virtio_blk_zone_report) {
.nr_zones = cpu_to_le64(nz),
};
+
+ trace_virtio_blk_zone_report_complete(vdev, req, nz, ret);
+ if (ret) {
+ err_status = VIRTIO_BLK_S_ZONE_INVALID_CMD;
+ goto out;
+ }
+
zrp_size = sizeof(struct virtio_blk_zone_report)
+ sizeof(struct virtio_blk_zone_descriptor) * nz;
n = iov_from_buf(in_iov, in_num, 0, &zrp_hdr, sizeof(zrp_hdr));
@@ -898,13 +898,14 @@ static int virtio_blk_handle_zone_append(VirtIOBlockReq *req,
int64_t offset = virtio_ldq_p(vdev, &req->out.sector) << BDRV_SECTOR_BITS;
int64_t len = iov_size(out_iov, out_num);
+ ZoneCmdData *data;
trace_virtio_blk_handle_zone_append(vdev, req, offset >> BDRV_SECTOR_BITS);
if (!check_zoned_request(s, offset, len, true, &err_status)) {
goto out;
}
- ZoneCmdData *data = g_malloc(sizeof(ZoneCmdData));
+ data = g_malloc(sizeof(ZoneCmdData));
data->req = req;
data->in_iov = in_iov;
data->in_num = in_num;
@@ -1191,14 +1192,15 @@ static void virtio_blk_dma_restart_cb(void *opaque, bool running,
{
VirtIOBlock *s = opaque;
uint16_t num_queues = s->conf.num_queues;
+ g_autofree VirtIOBlockReq **vq_rq = NULL;
+ VirtIOBlockReq *rq;
if (!running) {
return;
}
/* Split the device-wide s->rq request list into per-vq request lists */
- g_autofree VirtIOBlockReq **vq_rq = g_new0(VirtIOBlockReq *, num_queues);
- VirtIOBlockReq *rq;
+ vq_rq = g_new0(VirtIOBlockReq *, num_queues);
WITH_QEMU_LOCK_GUARD(&s->rq_lock) {
rq = s->rq;
@@ -1924,6 +1926,7 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIOBlock *s = VIRTIO_BLK(dev);
VirtIOBlkConf *conf = &s->conf;
+ BlockDriverState *bs;
Error *err = NULL;
unsigned i;
@@ -1969,7 +1972,7 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
return;
}
- BlockDriverState *bs = blk_bs(conf->conf.blk);
+ bs = blk_bs(conf->conf.blk);
if (bs->bl.zoned != BLK_Z_NONE) {
virtio_add_feature(&s->host_features, VIRTIO_BLK_F_ZONED);
if (bs->bl.zoned == BLK_Z_HM) {
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] virtio-blk: do not use C99 mixed declarations
2024-02-06 14:04 [PATCH] virtio-blk: do not use C99 mixed declarations Stefan Hajnoczi
@ 2024-02-06 15:14 ` Hanna Czenczek
2024-02-06 15:57 ` Michael S. Tsirkin
2024-02-07 14:09 ` Kevin Wolf
2 siblings, 0 replies; 5+ messages in thread
From: Hanna Czenczek @ 2024-02-06 15:14 UTC (permalink / raw)
To: Stefan Hajnoczi, qemu-devel; +Cc: qemu-block, Michael S. Tsirkin, Kevin Wolf
On 06.02.24 15:04, Stefan Hajnoczi wrote:
> QEMU's coding style generally forbids C99 mixed declarations.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> hw/block/virtio-blk.c | 25 ++++++++++++++-----------
> 1 file changed, 14 insertions(+), 11 deletions(-)
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] virtio-blk: do not use C99 mixed declarations
2024-02-06 14:04 [PATCH] virtio-blk: do not use C99 mixed declarations Stefan Hajnoczi
2024-02-06 15:14 ` Hanna Czenczek
@ 2024-02-06 15:57 ` Michael S. Tsirkin
2024-02-06 18:52 ` Stefan Hajnoczi
2024-02-07 14:09 ` Kevin Wolf
2 siblings, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2024-02-06 15:57 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: qemu-devel, Hanna Reitz, qemu-block, Kevin Wolf
On Tue, Feb 06, 2024 at 09:04:09AM -0500, Stefan Hajnoczi wrote:
> QEMU's coding style generally forbids C99 mixed declarations.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
or maybe it's time we moved on?
> ---
> hw/block/virtio-blk.c | 25 ++++++++++++++-----------
> 1 file changed, 14 insertions(+), 11 deletions(-)
>
> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> index 227d83569f..f6009cd9b3 100644
> --- a/hw/block/virtio-blk.c
> +++ b/hw/block/virtio-blk.c
> @@ -661,16 +661,16 @@ static void virtio_blk_zone_report_complete(void *opaque, int ret)
> int64_t zrp_size, n, j = 0;
> int64_t nz = data->zone_report_data.nr_zones;
> int8_t err_status = VIRTIO_BLK_S_OK;
> -
> - trace_virtio_blk_zone_report_complete(vdev, req, nz, ret);
> - if (ret) {
> - err_status = VIRTIO_BLK_S_ZONE_INVALID_CMD;
> - goto out;
> - }
> -
> struct virtio_blk_zone_report zrp_hdr = (struct virtio_blk_zone_report) {
> .nr_zones = cpu_to_le64(nz),
> };
> +
> + trace_virtio_blk_zone_report_complete(vdev, req, nz, ret);
> + if (ret) {
> + err_status = VIRTIO_BLK_S_ZONE_INVALID_CMD;
> + goto out;
> + }
> +
> zrp_size = sizeof(struct virtio_blk_zone_report)
> + sizeof(struct virtio_blk_zone_descriptor) * nz;
> n = iov_from_buf(in_iov, in_num, 0, &zrp_hdr, sizeof(zrp_hdr));
> @@ -898,13 +898,14 @@ static int virtio_blk_handle_zone_append(VirtIOBlockReq *req,
>
> int64_t offset = virtio_ldq_p(vdev, &req->out.sector) << BDRV_SECTOR_BITS;
> int64_t len = iov_size(out_iov, out_num);
> + ZoneCmdData *data;
>
> trace_virtio_blk_handle_zone_append(vdev, req, offset >> BDRV_SECTOR_BITS);
> if (!check_zoned_request(s, offset, len, true, &err_status)) {
> goto out;
> }
>
> - ZoneCmdData *data = g_malloc(sizeof(ZoneCmdData));
> + data = g_malloc(sizeof(ZoneCmdData));
> data->req = req;
> data->in_iov = in_iov;
> data->in_num = in_num;
> @@ -1191,14 +1192,15 @@ static void virtio_blk_dma_restart_cb(void *opaque, bool running,
> {
> VirtIOBlock *s = opaque;
> uint16_t num_queues = s->conf.num_queues;
> + g_autofree VirtIOBlockReq **vq_rq = NULL;
> + VirtIOBlockReq *rq;
>
> if (!running) {
> return;
> }
>
> /* Split the device-wide s->rq request list into per-vq request lists */
> - g_autofree VirtIOBlockReq **vq_rq = g_new0(VirtIOBlockReq *, num_queues);
> - VirtIOBlockReq *rq;
> + vq_rq = g_new0(VirtIOBlockReq *, num_queues);
>
> WITH_QEMU_LOCK_GUARD(&s->rq_lock) {
> rq = s->rq;
> @@ -1924,6 +1926,7 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
> VirtIODevice *vdev = VIRTIO_DEVICE(dev);
> VirtIOBlock *s = VIRTIO_BLK(dev);
> VirtIOBlkConf *conf = &s->conf;
> + BlockDriverState *bs;
> Error *err = NULL;
> unsigned i;
>
> @@ -1969,7 +1972,7 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
> return;
> }
>
> - BlockDriverState *bs = blk_bs(conf->conf.blk);
> + bs = blk_bs(conf->conf.blk);
> if (bs->bl.zoned != BLK_Z_NONE) {
> virtio_add_feature(&s->host_features, VIRTIO_BLK_F_ZONED);
> if (bs->bl.zoned == BLK_Z_HM) {
> --
> 2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] virtio-blk: do not use C99 mixed declarations
2024-02-06 15:57 ` Michael S. Tsirkin
@ 2024-02-06 18:52 ` Stefan Hajnoczi
0 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2024-02-06 18:52 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel, Hanna Reitz, qemu-block, Kevin Wolf
[-- Attachment #1: Type: text/plain, Size: 763 bytes --]
On Tue, Feb 06, 2024 at 10:57:37AM -0500, Michael S. Tsirkin wrote:
> On Tue, Feb 06, 2024 at 09:04:09AM -0500, Stefan Hajnoczi wrote:
> > QEMU's coding style generally forbids C99 mixed declarations.
> >
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
>
> or maybe it's time we moved on?
I sent a patch to allow C99 mixed declarations but a number of people
spoke out against changing the coding style so it didn't seem like a
good thing to pursue:
https://lore.kernel.org/qemu-devel/20240205171819.474283-1-stefanha@redhat.com/
Instead, I just want to make virtio-blk consistent with the coding
style...especially because I introduced one of the recent violations
:-).
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] virtio-blk: do not use C99 mixed declarations
2024-02-06 14:04 [PATCH] virtio-blk: do not use C99 mixed declarations Stefan Hajnoczi
2024-02-06 15:14 ` Hanna Czenczek
2024-02-06 15:57 ` Michael S. Tsirkin
@ 2024-02-07 14:09 ` Kevin Wolf
2 siblings, 0 replies; 5+ messages in thread
From: Kevin Wolf @ 2024-02-07 14:09 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: qemu-devel, Hanna Reitz, qemu-block, Michael S. Tsirkin
Am 06.02.2024 um 15:04 hat Stefan Hajnoczi geschrieben:
> QEMU's coding style generally forbids C99 mixed declarations.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-07 14:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-06 14:04 [PATCH] virtio-blk: do not use C99 mixed declarations Stefan Hajnoczi
2024-02-06 15:14 ` Hanna Czenczek
2024-02-06 15:57 ` Michael S. Tsirkin
2024-02-06 18:52 ` Stefan Hajnoczi
2024-02-07 14:09 ` Kevin Wolf
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).