4 ms·
I don't understand this one: - (written_out - i) * sizeof *pDecoded); + (written_out - i) * sizeof(*pDecoded)); Edit:
by jancsika 4y ago
I don't understand this one:
- (written_out - i) * sizeof *pDecoded);
+ (written_out - i) * sizeof(*pDecoded));
Edit: just to be clear-- I'm claiming there's no way the addition of parentheses could change the behavior of the program.
I guess I can understand resolving an ambiguity so that the reader doesn't have to look up precedence rules. But when combined with a high-profile bug in a critical piece of infrastructure it looks a bit like the software equivalent of not shaving one's beard in the hopes of winning a sports tournament.
- bewaretheirs 4y agoLooks to me like a coding style fix along for the ride with the correctness fix.
- Retr0id 4y agoI don't think that's security-relevant, likely just keeping a linter happy.
- jancsika 4y agoAh, I didn't think about a linter. I'll take a look at the code later to see if that's the case.
- nurettin 4y agosizeof is a keyword because of some terrible reason, but I'd parenthesize it just to make the intention clear.
- Sohcahtoa82 4y agoAgreed. sizeof FEELS like a function, and so I use parentheses with it, even though I know it's not actually a function.
- krylon 4y agoWasn't there some subtle difference between using sizeof with vs without parens? Something like if you pass a type to sizeof -- e.g. sizeof(*int) -- you must use parents anyway? It's been years since I've used C, I'm probably not remembering it correctly.
- scatters 4y agoYes, exactly that. `sizeof(int)` OK, `sizeof(i)` OK, `sizeof i` OK, `sizeof int` not OK. One of those weird rules.
- sapiogram 4y agoWhy is sizeof a terrible keyword? Just think of it as an operator rather than a function.
- nurettin 4y agoShould have been a callable, or should have had consistent syntax to prevent people from being clever.
- deleted 4y ago[deleted]