Skip to contentSkip to conversation

nbd: Fix 32-bit compilation on BLOCK_STATUS

PATCH In review Eric Blake 3 participants 3 messages Mar 27, 2018 – Mar 28, 2018 Block layer

lore
Share & tools
lore

Eric Blake

author
#0 lore raw

PATCH 1/1 nbd: Fix 32-bit compilation on BLOCK_STATUS

iotests 123 and 209 fail on 32-bit platforms. The culprit:
sizeof(extent) is wrong; we want sizeof(*extent). But since the struct is 8 bytes, it happened to work on 64-bit platforms where the pointer is also 8 bytes (nasty).

Fixes 78a33ab58
---
 block/nbd-client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/nbd-client.c +1 -1
index e64e346d690..e7caf49fbb4 100644
@@ -239,7 +239,7 @@ static int nbd_parse_blockstatus_payload(NBDClientSession *client,
 {
     uint32_t context_id;
 
-    if (chunk->length != sizeof(context_id) + sizeof(extent)) {
+    if (chunk->length != sizeof(context_id) + sizeof(*extent)) {
         error_setg(errp, "Protocol error: invalid payload for "
                          "NBD_REPLY_TYPE_BLOCK_STATUS");
         return -EINVAL;
Signature · 1 line
2.14.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Eric Blake

iotests 123 and 209 fail on 32-bit platforms. The culprit:
sizeof(extent) is wrong; we want sizeof(*extent). But since the struct is 8 bytes, it happened to work on 64-bit platforms where the pointer is also 8 bytes (nasty).

Fixes 78a33ab58
---
 block/nbd-client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/nbd-client.c +0 -0
index e64e346d690..e7caf49fbb4 100644

block/nbd-client.c static int nbd_parse_blockstatus_payload(NBDClientSession *client, · line 245

Quoted 8 lines
block/nbd-client.c +1 -1
@@ -239,7 +239,7 @@ static int nbd_parse_blockstatus_payload(NBDClientSession *client,
 {
     uint32_t context_id;
 
-    if (chunk->length != sizeof(context_id) + sizeof(extent)) {
+    if (chunk->length != sizeof(context_id) + sizeof(*extent)) {
         error_setg(errp, "Protocol error: invalid payload for "
                          "NBD_REPLY_TYPE_BLOCK_STATUS");
         return -EINVAL;
Reviewed-by on v1 1/1
#2 lore raw
In reply to Eric Blake
Quoted 17 lines · Eric Blake

iotests 123 and 209 fail on 32-bit platforms. The culprit:
sizeof(extent) is wrong; we want sizeof(*extent). But since the struct is 8 bytes, it happened to work on 64-bit platforms where the pointer is also 8 bytes (nasty).

Fixes 78a33ab58
---
  block/nbd-client.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
block/nbd-client.c +0 -0
index e64e346d690..e7caf49fbb4 100644

block/nbd-client.c static int nbd_parse_blockstatus_payload(NBDClientSession *client, · line 245

Quoted 8 lines
block/nbd-client.c +1 -1
@@ -239,7 +239,7 @@ static int nbd_parse_blockstatus_payload(NBDClientSession *client,
  {
      uint32_t context_id;
 
-    if (chunk->length != sizeof(context_id) + sizeof(extent)) {
+    if (chunk->length != sizeof(context_id) + sizeof(*extent)) {
          error_setg(errp, "Protocol error: invalid payload for "
                           "NBD_REPLY_TYPE_BLOCK_STATUS");
          return -EINVAL;

my mistake, sorry for it :(

Signature · 2 lines
Best regards,
Vladimir