Skip to contentSkip to conversation

block: Minor cleanups

PATCH In review Kevin Wolf 2 participants 5 messages Sep 5, 2023

Subsystems (2)
lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

cover block: Minor cleanups

I had to go through all block drivers and noticed some details that aren't as expected, so I thought I might as well fix them...

Kevin Wolf (2):
block/meson.build: Restore alphabetical order of files
block: Make more BlockDriver definitions static

 block/copy-before-write.c |  2 +-
 block/preallocate.c       |  2 +-
 block/snapshot-access.c   |  2 +-
 block/meson.build         | 12 ++++++------
 4 files changed, 9 insertions(+), 9 deletions(-)
Signature · 1 line
2.41.0
author
#1 lore raw

PATCH 1/2 block/meson.build: Restore alphabetical order of files

When commit 5e5733e5999 created block/meson.build, the list of unconditionally added files was in alphabetical order. Later commits added new files in random places. Reorder the list to be alphabetical again. (As for ordering foo.c against foo-*.c, there are both ways used currently; standardise on having foo.c first, even though this is different from the original commit 5e5733e5999.)

---
 block/meson.build | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
block/meson.build +6 -6
index 529fc172c6..f351b9d0d3 100644
@@ -4,41 +4,41 @@ block_ss.add(files(
   'aio_task.c',
   'amend.c',
   'backup.c',
-  'copy-before-write.c',
   'blkdebug.c',
   'blklogwrites.c',
   'blkverify.c',
   'block-backend.c',
   'block-copy.c',
-  'graph-lock.c',
   'commit.c',
+  'copy-before-write.c',
   'copy-on-read.c',
-  'preallocate.c',
-  'progress_meter.c',
   'create.c',
   'crypto.c',
   'dirty-bitmap.c',
   'filter-compress.c',
+  'graph-lock.c',
   'io.c',
   'mirror.c',
   'nbd.c',
   'null.c',
   'plug.c',
+  'preallocate.c',
+  'progress_meter.c',
   'qapi.c',
+  'qcow2.c',
   'qcow2-bitmap.c',
   'qcow2-cache.c',
   'qcow2-cluster.c',
   'qcow2-refcount.c',
   'qcow2-snapshot.c',
   'qcow2-threads.c',
-  'qcow2.c',
   'quorum.c',
   'raw-format.c',
   'reqlist.c',
   'snapshot.c',
   'snapshot-access.c',
-  'throttle-groups.c',
   'throttle.c',
+  'throttle-groups.c',
   'write-threshold.c',
 ), zstd, zlib, gnutls)
 
Signature · 1 line
2.41.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] block/meson.build: Restore alphabetical order of files

Quoted 11 lines · Kevin Wolf

When commit 5e5733e5999 created block/meson.build, the list of unconditionally added files was in alphabetical order. Later commits added new files in random places. Reorder the list to be alphabetical again. (As for ordering foo.c against foo-*.c, there are both ways used currently; standardise on having foo.c first, even though this is different from the original commit 5e5733e5999.)

---
  block/meson.build | 12 ++++++------
  1 file changed, 6 insertions(+), 6 deletions(-)
author
#3 lore raw

PATCH 2/2 block: Make more BlockDriver definitions static

In reply to Kevin Wolf

Most block driver implementations don't have any reason for their BlockDriver to be public. The only exceptions are bdrv_file, bdrv_raw and bdrv_qcow2, which are actually used in other source files.

Make all other BlockDriver definitions static if they aren't yet.

---
 block/copy-before-write.c | 2 +-
 block/preallocate.c       | 2 +-
 block/snapshot-access.c   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
block/copy-before-write.c +1 -1
index b866e42271..9a0e2b69d9 100644
@@ -503,7 +503,7 @@ static void cbw_close(BlockDriverState *bs)
     s->bcs = NULL;
 }
 
-BlockDriver bdrv_cbw_filter = {
+static BlockDriver bdrv_cbw_filter = {
     .format_name = "copy-before-write",
     .instance_size = sizeof(BDRVCopyBeforeWriteState),
 
block/preallocate.c +1 -1
index 4d82125036..3d0f621003 100644
@@ -535,7 +535,7 @@ static void preallocate_child_perm(BlockDriverState *bs, BdrvChild *c,
     }
 }
 
-BlockDriver bdrv_preallocate_filter = {
+static BlockDriver bdrv_preallocate_filter = {
     .format_name = "preallocate",
     .instance_size = sizeof(BDRVPreallocateState),
 
block/snapshot-access.c +1 -1
index 67ea339da9..8d4e8932b8 100644
@@ -108,7 +108,7 @@ static void snapshot_access_child_perm(BlockDriverState *bs, BdrvChild *c,
     *nshared = BLK_PERM_ALL;
 }
 
-BlockDriver bdrv_snapshot_access_drv = {
+static BlockDriver bdrv_snapshot_access_drv = {
     .format_name = "snapshot-access",
 
     .bdrv_open                  = snapshot_access_open,
Signature · 1 line
2.41.0
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] block: Make more BlockDriver definitions static

Quoted 4 lines · Kevin Wolf

Most block driver implementations don't have any reason for their BlockDriver to be public. The only exceptions are bdrv_file, bdrv_raw and bdrv_qcow2, which are actually used in other source files.

Quoted 8 lines

Make all other BlockDriver definitions static if they aren't yet.

---
  block/copy-before-write.c | 2 +-
  block/preallocate.c       | 2 +-
  block/snapshot-access.c   | 2 +-
  3 files changed, 3 insertions(+), 3 deletions(-)