From: sebastian@pipping.org (Sebastian Pipping)
To: kernelnewbies@lists.kernelnewbies.org
Subject: struct nbd_reply not packed => trouble?
Date: Thu, 10 Jan 2013 17:09:33 +0100 [thread overview]
Message-ID: <50EEE7BD.1040306@pipping.org> (raw)
Hello kernel hackers,
I noticed that in [linux]/include/uapi/linux/nbd.h the structure
struct nbd_request {
__be32 magic;
__be32 type; /* == READ || == WRITE */
char handle[8];
__be64 from;
__be32 len;
} __attribute__((packed));
is packed but its reply counter part
struct nbd_reply {
__be32 magic;
__be32 error; /* 0 = ok, else error */
char handle[8]; /* handle you got from request */
};
is not. Since Linux seems to read sizeof(nbd_reply) bytes from the
network (see [1]), the number of bytes read varies with the number of
bytes of the structure.
So my understanding is that if the size of struct nbd_reply varies from
platform/compiler to another that means trouble. I wonder:
- Is there anything about struct nbd_reply that would keep its size
equal everywhere or a reason why variance in size is no problem here?
- Any ideas for a platform where you would expect struct nbd_reply to
be other than 4 + 4 + 8 = 16 bytes in size?
Best,
Sebastian
[1] http://lxr.linux.no/#linux+v3.7.1/drivers/block/nbd.c#L336
next reply other threads:[~2013-01-10 16:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-10 16:09 Sebastian Pipping [this message]
2013-01-10 16:36 ` struct nbd_reply not packed => trouble? Yann Droneaud
2013-01-13 16:45 ` Sebastian Pipping
2013-01-14 23:59 ` 卜弋天
2013-01-15 9:59 ` Yann Droneaud
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50EEE7BD.1040306@pipping.org \
--to=sebastian@pipping.org \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).