So, I have this code:
uint8_t* pbytes = pkt->iov[0].iov_base;
which creates a pointer to the start of the ethernet packet in the structure.
And I ask my friend to take a look at the code, and he says: "You do not change this, and it would be really confusing if you did it, so do it const."
And that seems like a good idea, therefore:
const uint8_t* pbytes = pkt->iov[0].iov_base;
or even:
const uint8_t * const pbytes = pkt->iov[0].iov_base;
And now I think, I bet that there are many other places where I could do this, and I bet that the compiler would be better off finding them than me.
Any ideas how I ask this question? (gcc is preferable, but no problem using another compiler or transfusion tool if they work on unix).
source share