Skip to contentSkip to conversation

iscsi: Remove pointless runtime check of macro value

PATCH Applied Fam Zheng 3 participants 4 messages May 13, 2015 – May 28, 2015 Block layer

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH 1/1 iscsi: Remove pointless runtime check of macro value

raw_bsd already has QEMU_BUILD_BUG_ON(BDRV_SECTOR_SIZE != 512), so iscsi should relax.

---
 block/iscsi.c | 7 -------
 1 file changed, 7 deletions(-)
block/iscsi.c +0 -7
index 8fca1d3..14e97a6 100644
@@ -1323,13 +1323,6 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
     const char *filename;
     int i, ret = 0;
 
-    if ((BDRV_SECTOR_SIZE % 512) != 0) {
-        error_setg(errp, "iSCSI: Invalid BDRV_SECTOR_SIZE. "
-                   "BDRV_SECTOR_SIZE(%lld) is not a multiple "
-                   "of 512", BDRV_SECTOR_SIZE);
-        return -EINVAL;
-    }
-
     opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
     qemu_opts_absorb_qdict(opts, options, &local_err);
     if (local_err) {
Signature · 1 line
2.4.0
#1 lore raw
Quoted 2 lines · Fam Zheng

raw_bsd already has QEMU_BUILD_BUG_ON(BDRV_SECTOR_SIZE != 512), so iscsi should relax.

It's okay to have the same QEMU_BUILD_BUG_ON in different places. However, you're right that this should be a compile-time check rather than run-time check.

Paolo

Quoted 24 lines
---
 block/iscsi.c | 7 -------
 1 file changed, 7 deletions(-)
block/iscsi.c +0 -7
index 8fca1d3..14e97a6 100644
@@ -1323,13 +1323,6 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
     const char *filename;
     int i, ret = 0;
 
-    if ((BDRV_SECTOR_SIZE % 512) != 0) {
-        error_setg(errp, "iSCSI: Invalid BDRV_SECTOR_SIZE. "
-                   "BDRV_SECTOR_SIZE(%lld) is not a multiple "
-                   "of 512", BDRV_SECTOR_SIZE);
-        return -EINVAL;
-    }
-
     opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
     qemu_opts_absorb_qdict(opts, options, &local_err);
     if (local_err) {
author
#2 lore raw
Quoted 9 lines · Paolo Bonzini
Quoted 2 lines · Fam Zheng

raw_bsd already has QEMU_BUILD_BUG_ON(BDRV_SECTOR_SIZE != 512), so iscsi should relax.

It's okay to have the same QEMU_BUILD_BUG_ON in different places. However, you're right that this should be a compile-time check rather than run-time check.

I agree with you, but I can't imaging this value could ever change, so there is little gain to duplicate in this case.

Fam

Quoted 28 lines

Paolo

Quoted 24 lines
---
 block/iscsi.c | 7 -------
 1 file changed, 7 deletions(-)
block/iscsi.c +0 -7
index 8fca1d3..14e97a6 100644
@@ -1323,13 +1323,6 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
     const char *filename;
     int i, ret = 0;
 
-    if ((BDRV_SECTOR_SIZE % 512) != 0) {
-        error_setg(errp, "iSCSI: Invalid BDRV_SECTOR_SIZE. "
-                   "BDRV_SECTOR_SIZE(%lld) is not a multiple "
-                   "of 512", BDRV_SECTOR_SIZE);
-        return -EINVAL;
-    }
-
     opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
     qemu_opts_absorb_qdict(opts, options, &local_err);
     if (local_err) {
#3 lore raw
In reply to Fam Zheng
Quoted 2 lines · Fam Zheng

raw_bsd already has QEMU_BUILD_BUG_ON(BDRV_SECTOR_SIZE != 512), so iscsi should relax.

Applied to -trivial, thank you!

/mjt