|
|
Log in / Subscribe / Register

A tale of two data-corruption bugs

A tale of two data-corruption bugs

Posted May 25, 2015 20:50 UTC (Mon) by jzbiciak (guest, #5246)
In reply to: A tale of two data-corruption bugs by josh
Parent article: A tale of two data-corruption bugs

I guess for a function like this, which effectively returns two values (in this case, sector_div is a specialized divmod function), you'd replace it with a static inline that requires you to take the address of the left argument? ie. something like this?

/* Compute bar / baz and bar % baz.  Put bar / baz into bar, and return bar % baz. */
foo = divmod( &bar, baz );

With inlining, the reference/dereference will get optimized away, most certainly, and the required & would make the in-out characteristic of bar more obvious.

I have to admit, the in-out nature of sector_div would not have been apparent to me. I sat up in my chair and shoot my head when I read the bug description in the article.


The LWN site is currently under high scraper load, so comment display has been suppressed for anonymous users. If you are a human, you may read the comments by clicking the button below:

Note: you can avoid this step in the future by logging into your LWN account.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds