From 586acbe45c64b352917c24b792b276a888fc11a4 Mon Sep 17 00:00:00 2001 From: dwarning Date: Fri, 6 Aug 2010 07:50:20 +0000 Subject: [PATCH] fallback for not handled enumeration values in switch --- src/frontend/com_measure2.c | 8 ++++++++ src/frontend/inp.c | 11 +++++++++++ src/frontend/inpcom.c | 5 +++++ src/frontend/vectors.c | 6 ++++++ 4 files changed, 30 insertions(+) diff --git a/src/frontend/com_measure2.c b/src/frontend/com_measure2.c index f493be266..ede5550a6 100644 --- a/src/frontend/com_measure2.c +++ b/src/frontend/com_measure2.c @@ -17,6 +17,8 @@ #include "dotcards.h" #include "com_measure2.h" +#include "error.h" /* controlled_exit() */ + typedef enum { MEASUREMENT_OK = 0, MEASUREMENT_FAILURE = 1 @@ -1686,6 +1688,12 @@ get_measure2( printf("\tfunction '%s' currently not supported\n", mFunction); break; } + + default: + { + fprintf(stderr, "ERROR: enumeration value `AT_UNKNOWN' not handled in get_measure2\nAborting...\n" ); + controlled_exit(EXIT_FAILURE); + } } return MEASUREMENT_FAILURE; } diff --git a/src/frontend/inp.c b/src/frontend/inp.c index cdfcaceaa..a7b8c29cb 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -34,6 +34,7 @@ $Id$ #include "variable.h" #include "breakp2.h" #include "../misc/util.h" /* dirname() */ +#include "error.h" /* controlled_exit() */ #ifdef XSPICE /* include new stuff */ @@ -757,6 +758,11 @@ inp_dodeck( break; case CP_STRING: break; + default: + { + fprintf(stderr, "ERROR: enumeration value `CP_LIST' not handled in inp_dodeck\nAborting...\n" ); + controlled_exit(EXIT_FAILURE); + } } /* switch . . . */ } options = opt_beg; // back to the beginning @@ -899,6 +905,11 @@ inp_dodeck( if_option(ct->ci_ckt, eev->va_name, eev->va_type, eev->va_string); break; + default: + { + fprintf(stderr, "ERROR: enumeration value `CP_LIST' not handled in inp_dodeck\nAborting...\n" ); + controlled_exit(EXIT_FAILURE); + } } // switch . . . } } // if (!noparse) . . . diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 2c0c341f4..84f9d874c 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -220,6 +220,11 @@ inp_pathopen(char *name, char *mode) case CP_REAL: /* This is foolish */ (void) sprintf(buf, "%g%s%s", v->va_real, DIR_PATHSEP, name); break; + default: + { + fprintf(stderr, "ERROR: enumeration value `CP_BOOL' or `CP_LIST' not handled in inp_pathopen\nAborting...\n" ); + controlled_exit(EXIT_FAILURE); + } } if ((fp = fopen(buf, mode))) return (fp); diff --git a/src/frontend/vectors.c b/src/frontend/vectors.c index 68a2987fc..95aaea4af 100644 --- a/src/frontend/vectors.c +++ b/src/frontend/vectors.c @@ -19,6 +19,7 @@ $Id$ #include "variable.h" #include "vectors.h" #include "plotting/plotting.h" +#include "error.h" /* controlled_exit() */ #ifdef XSPICE /* gtri - begin - add function prototype for EVTfindvec */ @@ -519,6 +520,11 @@ vec_get(const char *vec_name) case CP_NUM: fprintf(stdout,"%s=%d\n",nv->va_name,nv->va_num); break; + default: + { + fprintf(stderr, "ERROR: enumeration value `CP_BOOL' or `CP_LIST' not handled in vec_get\nAborting...\n" ); + controlled_exit(EXIT_FAILURE); + } } nv = nv->va_next;