hw/block/virtio-blk.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)
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
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
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
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
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>
© 2016 - 2024 Red Hat, Inc.