> [...] > uuid_enc_be(void *buf, const struct uuid *uuid) > { > uint8_t *p = buf;
> "p" technically only points to one byte, Not really. p may point to any number of bytes from zero upwards; the actual number cannot be determined without inspecting uuid_enc_be's caller, since it is a property of the passed-in pointer. But, really, this is a kernel. Almost by definition it will include `unsafe' code. (Admittedly, I don't know whether this code is an example.) Expecting a code-safety tool to not misfire is IMO foolish. Yes, some of the code in the kernel can lead to what is formally undefined behaviour. A compiler that takes advantage of that to do something surprising just is not suitable for building the kernel, as simple as that. Some compilers are unsuited to some tasks. Trying to work around compiler "optimization" is a fool's errand. The compiler should not be springing code-breaking surprises on programmers, whether in the name of optimization or anything else. I would not have thought I'd ever be recommending something djb wrote, but his piece at http://blog.cr.yp.to/20240803-clang.html, while written about clang and with a specific focus on timing attacks against crypto code, is very much worth reading for the more general lessons in it. Compiler authors need to learn that compilers need to be useful tools first and foremost; the correct response to "but the standard allows it!" is "it's not useful - we're rolling back until you fix it". This is not to say that such automated tools are useless on a kernel. It's entirely possible that some, maybe even most, of the tool's complaints point out real bugs. But trying to "fix" the kernel just to shut up each and every complaint is, IMO, misguided. (I don't know which case this particular instance is. It's just that mrg's text makes me feel it's a case of trying to contort the code to shut up the tool for the sake of shutting up the tool, not for the sake of fixing a bug.) /~\ The ASCII Mouse \ / Ribbon Campaign X Against HTML mo...@rodents-montreal.org / \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B