On Mon, May 21, 2018 at 4:36 PM, Tom Lane <t...@sss.pgh.pa.us> wrote: > ... 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.
Here's an experimental way to do that, if you don't mind depending on gory details of libc implementations (ie knowledge of what it expands too). Not sure how to avoid that since it's a macro on all modern systems, and we don't have a way to temporarily redefine a macro. If you enable it for just ereport(), it compiles cleanly after 81256cd (but fails on earlier commits). If you enable it for elog() too then it finds problems with exec.c. Another idea: if there are any systems in the build farm where it isn't a macro as permitted by the standard (#ifndef errno), you could perhaps define it as something uncompilable and then undefined it at the end of the scope, so we'd at least have a post-commit canary. -- Thomas Munro http://www.enterprisedb.com
prevent-errno.patch
Description: Binary data