There are instances in the code where sizeof(*ptr) is used. e.g. in net/802/garp.c const struct garp_msg_hdr *gm; if (!pskb_may_pull(skb, sizeof(*gm))) return -1; i want to ask is there any sense in using sizeof(struct garp_msg_hdr) instead of sizeof(*gm) in the above example. Thanks -- Sukrit Sangwan IIT Roorkee
On Sun, Jan 22, 2012 at 8:14 PM, Sukrit Sangwan <sukritsangwan@gmail.com> wrote:
There are instances in the code where sizeof(*ptr) is used. e.g. in net/802/garp.c const struct garp_msg_hdr *gm; if (!pskb_may_pull(skb, sizeof(*gm))) return -1; i want to ask is there any sense in using sizeof(struct garp_msg_hdr) instead of sizeof(*gm) in the above example.
Imagine what would happen if you change the name of struct garp_msg_hdr; thanks, Daniel.
also i want to ask why not use simply 8 instead of sizeof(u8). -- Sukrit Sangwan IIT Roorkee
On Sun, Jan 22, 2012 at 11:58:30PM +0530, Sukrit Sangwan wrote:
also i want to ask why not use simply 8 instead of sizeof(u8).
That would be 1 most of the time. sizeof returns the size in bytes (according to the C reference manual in K&R's book). Apart from that, sizeof(u8) is more explicit about the intention. HTH, Jonathan Neuschäfer
On Son, 2012-01-22 at 23:58 +0530, Sukrit Sangwan wrote:
also i want to ask why not use simply 8 instead of sizeof(u8).
Because it is wrong. Bernd -- Bernd Petrovitsch Email : bernd@petrovitsch.priv.at LUGA : http://www.luga.at
participants (4)
-
Bernd Petrovitsch -
Daniel Baluta -
Jonathan Neuschäfer -
Sukrit Sangwan