sim: common: add basic model assert
authorMike Frysinger <vapier@gentoo.org>
Sat, 20 Jun 2015 09:36:26 +0000 (15:21 +0545)
committerMike Frysinger <vapier@gentoo.org>
Sun, 21 Jun 2015 17:56:24 +0000 (13:56 -0400)
If the configured in default doesn't match a known value, throw an
assertion failure rather than segfaulting deeper down.

sim/common/ChangeLog
sim/common/sim-model.c

index 30a121c..722ad98 100644 (file)
@@ -1,5 +1,9 @@
 2015-06-21  Mike Frysinger  <vapier@gentoo.org>
 
+       * sim-model.c (sim_model_init): Assert model is not NULL.
+
+2015-06-21  Mike Frysinger  <vapier@gentoo.org>
+
        * sim-types.h: Move SIM_TYPES_H define to top of file.  Include
        stdint.h.  Replace all signed/unsigned typedefs with int#_t and
        uint#_t.
index a33bd2a..db5f323 100644 (file)
@@ -204,6 +204,7 @@ sim_model_init (SIM_DESC sd)
     {
       /* Set the default model.  */
       const MODEL *model = sim_model_lookup (WITH_DEFAULT_MODEL);
+      SIM_ASSERT (model != NULL);
       sim_model_set (sd, NULL, model);
     }