Advanced

Linux: Debating Coding Style

Posted by tadelste on · Post a comment
KernelTrap
Mail this story
Print this story

The Linux kernel coding style document was recently upgraded to say "the preferred form for passing a size of a struct is the following: p = kmalloc(sizeof(*p), ...);". Russell King [interview] disagreed with this suggestion, listing several reasons it was problematic. He was quickly joined by others including Al Viro, Robert Love [interview] and Alan Cox [interview], who agreed and added additional reasons why this coding convention could be problematic, suggesting instead to use "p = kmalloc(sizeof(struct foo), ...)". The reasons cited included the difficulty in grepping for such allocations and initializations, confusion over the fact the sizeof(*p) is the size of for example a void *, not the full space for the object allocated and overall readability.

Full Story

  Nav
» Read more about: Story Type: Interview; Groups: Kernel

» Get new stories by e-mail: nightly or as they are published

« Return to the newswire homepage

  Related stories
» More like this

Comments

No comments yet. Be the first.

Post a comment

A free account is needed to post. Write your comment here first: your text is kept in this browser while you sign up or log in, and is waiting for you when you come back.

Your message:
|||||
10
Markdown: **bold**, *italic*, [text](https://link), - lists, > quotes, $x^2$ for math. Formatting help

Sign up and post (it is free)  or  Log in and post