... and, while we're thinking about this, how can we prevent the reverse problem of using strerror(errno) where you should have used %m? That is evidently not academic either, cf 81256cd.
I am wondering whether the elog/ereport macros can locally define some version of "errno" that would cause a compile failure if it's referenced within the macro args. But I'm too tired to work it out in detail. regards, tom lane