A tale of two data-corruption bugs
A tale of two data-corruption bugs
Posted May 28, 2015 0:24 UTC (Thu) by alankila (guest, #47141)In reply to: A tale of two data-corruption bugs by cesarb
Parent article: A tale of two data-corruption bugs
I assert that chances of mistakes like these are almost definitely increased when macros look like function calls. If sector_div had actually been a function, it couldn't have altered the input argument given the way it was called. Because it looks like a function, it dupes programmers with a false expectation. To crystallize, things that are different in behavior should also look different. Therefore, having upper-case named macros is prudent (especially when they do macroy stuff that is impossible for functions to do) and it would increase the likelihood that someone checks the implementation because a macro can really do very strange things that break syntactic expectations. You don't know about a C macro where exactly the argument is expanded, or how many times it will be evaluated.
Anyway, macros are evil and should die, especially macros for which inline functions are a perfectly acceptable substitute.
