On Mon, 2012-09-03 at 11:14 +0100, Peter Geoghegan wrote: > Come to think of it, the whole convention of using a lower-case > variant of the original pointer variable name seems like a foot-gun, > given the harmful and indeed very subtle consequences of making this > error.
With some inventive macro magic, you could probably make this safer. I'm thinking something along the lines of replacing SpinLockAcquire(&xlogctl->info_lck); with SpinLockAcquire(XLogCtl, info_lck); which expands to { volatile typeof(XLogCtl) *XLogCtl_volatile = XLogCtl; void *XLogCtl = NULL; // compiler error or crash at run time if used OldSpinLockAcquire(XLogCtl_volatile->info_lock); ... and then something corresponding for SpinLockRelease. This will likely only work with modern compilers, but it could give you some amount of static checking against this problem. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers