DNA: ensure new names exist when renaming

Fail to build on errors in new names - without this renamed values
would be written to DNA breaking backwards & forwards compatibility.

Note that errors in old names aren't detected.
This commit is contained in:
Campbell Barton
2019-02-16 12:54:33 +11:00
parent 2f737c4f47
commit ae375b4cdc
2 changed files with 23 additions and 0 deletions

View File

@@ -33,6 +33,9 @@
* All references to the previous destination name can be removed since they're
* never written to disk.
*
* - Old names aren't sanity checked (since this file is the only place that knows about them)
* typos in the old names will break both backwards & forwards compatibility **TAKE CARE**.
*
* \see versioning_dna.c for a actual version patching.
*/

View File

@@ -1464,3 +1464,23 @@ int main(int argc, char **argv)
/* end of list */
/** \} */
/* -------------------------------------------------------------------- */
/** \name DNA Renaming Sanity Check
*
* Without this it's possible to reference struct members that don't exist,
* breaking backward & forward compatibility.
*
* \{ */
static void UNUSED_FUNCTION(dna_rename_defs_ensure)(void)
{
#define DNA_STRUCT_RENAME(old, new) (void)sizeof(new);
#define DNA_STRUCT_RENAME_ELEM(struct_name, old, new) (void)offsetof(struct_name, new);
#include "dna_rename_defs.h"
#undef DNA_STRUCT_RENAME
#undef DNA_STRUCT_RENAME_ELEM
}
/** \} */