summaryrefslogtreecommitdiff
path: root/kicad
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-23 14:46:04 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-23 14:46:04 -0300
commitf5fa04cbf3ac9011f4f144cd68543f8d9536e3fd (patch)
treeac9160ef7ef5963e296144fb75845db56ba62e7c /kicad
parent061dd9094a903be73e3aa7a65aafb8bcb70010b7 (diff)
downloadeeshow-f5fa04cbf3ac9011f4f144cd68543f8d9536e3fd.tar.gz
eeshow-f5fa04cbf3ac9011f4f144cd68543f8d9536e3fd.tar.bz2
eeshow-f5fa04cbf3ac9011f4f144cd68543f8d9536e3fd.zip
misc/diag.h (BUG): more useful diagnostics; replace all "abort" with it
Diffstat (limited to 'kicad')
-rw-r--r--kicad/delta.c5
-rw-r--r--kicad/dwg.c3
-rw-r--r--kicad/ext.c6
-rw-r--r--kicad/lib-parse.c2
-rw-r--r--kicad/lib-render.c12
-rw-r--r--kicad/pro.c3
-rw-r--r--kicad/sch-parse.c2
-rw-r--r--kicad/sexpr.c4
8 files changed, 21 insertions, 16 deletions
diff --git a/kicad/delta.c b/kicad/delta.c
index d07915d..9eb05bb 100644
--- a/kicad/delta.c
+++ b/kicad/delta.c
@@ -17,6 +17,7 @@
#include <string.h>
#include "misc/util.h"
+#include "misc/diag.h"
#include "gfx/text.h"
#include "kicad/lib.h"
#include "kicad/sch.h"
@@ -98,7 +99,7 @@ static bool comp_eq_obj(const struct lib_obj *a, const struct lib_obj *b)
!strcmp(a->u.pin.name, b->u.pin.name) &&
!strcmp(a->u.pin.number, b->u.pin.number);
default:
- abort();
+ BUG("invalid type %d", a->type);
}
}
@@ -320,7 +321,7 @@ static bool obj_eq(const struct sch_obj *a, const struct sch_obj *b,
return 0;
return sheet_eq(a->u.sheet.sheet, b->u.sheet.sheet);
default:
- abort();
+ BUG("invalid type %d", a->type);
}
}
diff --git a/kicad/dwg.c b/kicad/dwg.c
index 261d0c3..799c329 100644
--- a/kicad/dwg.c
+++ b/kicad/dwg.c
@@ -18,6 +18,7 @@
#include <assert.h>
#include "misc/util.h"
+#include "misc/diag.h"
#include "gfx/misc.h"
#include "gfx/style.h"
#include "gfx/text.h"
@@ -74,7 +75,7 @@ static enum box_type flip_box(enum box_type box)
case box_both:
return box_both;
default:
- abort();
+ BUG("invalid box type %d", box);
}
}
diff --git a/kicad/ext.c b/kicad/ext.c
index d4221ee..fe85c44 100644
--- a/kicad/ext.c
+++ b/kicad/ext.c
@@ -46,13 +46,15 @@ void classify_files(struct file_names *fn, char *const *args,
unsigned n_args)
{
unsigned i;
+ enum ext ext;
fn->pro = fn->sch = fn->pl = NULL;
fn->libs = NULL;
fn->n_libs = 0;
for (i = 0; i != n_args; i++) {
- switch (identify(args[i])) {
+ ext = identify(args[i]);
+ switch (ext) {
case ext_unknown:
fatal("%s: unknown file type", args[i]);
case ext_project:
@@ -80,7 +82,7 @@ void classify_files(struct file_names *fn, char *const *args,
fn->pl = args[i];
break;
default:
- abort();
+ BUG("invalid extension code %d", ext);
}
}
}
diff --git a/kicad/lib-parse.c b/kicad/lib-parse.c
index 0d5d493..47081e7 100644
--- a/kicad/lib-parse.c
+++ b/kicad/lib-parse.c
@@ -313,7 +313,7 @@ static bool lib_parse_line(const struct file *file,
}
break;
default:
- abort();
+ BUG("invalid state %d", lib->state);
}
fatal("%u: cannot parse\n\"%s\"\n", file->lineno, line);
}
diff --git a/kicad/lib-render.c b/kicad/lib-render.c
index 54361ca..f73b227 100644
--- a/kicad/lib-render.c
+++ b/kicad/lib-render.c
@@ -71,7 +71,7 @@ static void draw_poly(const struct lib_poly *poly, const int m[6])
LAYER_COMP_DWG_BG);
break;
default:
- abort();
+ BUG("invalid fill '%c'", poly->fill);
}
}
@@ -97,7 +97,7 @@ static void draw_rect(const struct lib_rect *rect, const int m[6])
LAYER_COMP_DWG_BG);
break;
default:
- abort();
+ BUG("invalid fill '%c'", rect->fill);
}
}
@@ -125,7 +125,7 @@ static void draw_circ(const struct lib_circ *circ, const int m[6])
LAYER_COMP_DWG_BG);
break;
default:
- abort();
+ BUG("invalid fill '%c'", circ->fill);
}
}
@@ -422,7 +422,7 @@ static void draw_pin(const struct comp *comp, const struct lib_pin *pin,
hor = text_max;
break;
default:
- abort();
+ BUG("invalid orientation '%c'", pin->orient);
}
draw_pin_line(pin, shape, dx, dy, m);
@@ -474,7 +474,7 @@ static void draw_text(const struct lib_text *text, const int m[6])
txt.vert = text_flip(txt.vert);
break;
default:
- abort();
+ BUG("unknown rotation %d", txt.rot);
}
text_fig(&txt, COLOR_COMP_DWG, WIDTH_COMP_DWG);
@@ -533,7 +533,7 @@ static void draw(const struct comp *comp, const struct lib_obj *obj,
draw_pin(comp, &obj->u.pin, m);
break;
default:
- abort();
+ BUG("invalid object type %d", obj->type);
}
}
diff --git a/kicad/pro.c b/kicad/pro.c
index f077fe3..a113ba1 100644
--- a/kicad/pro.c
+++ b/kicad/pro.c
@@ -16,6 +16,7 @@
#include <assert.h>
#include "misc/util.h"
+#include "misc/diag.h"
#include "file/file.h"
#include "kicad/ext.h"
#include "kicad/pro.h"
@@ -77,7 +78,7 @@ static bool pro_parse_line(const struct file *file,
}
break;
default:
- abort();
+ BUG("invalid state %d", pro->state);
}
return 1;
}
diff --git a/kicad/sch-parse.c b/kicad/sch-parse.c
index 456ad13..08d7dd8 100644
--- a/kicad/sch-parse.c
+++ b/kicad/sch-parse.c
@@ -599,7 +599,7 @@ static bool parse_line(const struct file *file, void *user, const char *line)
case sch_eof:
return 1;
default:
- abort();
+ BUG("invalid state %d", ctx->state);
}
fatal("%s:%u: cannot parse\n\"%s\"\n", file->name, file->lineno, line);
}
diff --git a/kicad/sexpr.c b/kicad/sexpr.c
index 6f0fd2f..84871b9 100644
--- a/kicad/sexpr.c
+++ b/kicad/sexpr.c
@@ -108,7 +108,7 @@ static void end_string(struct sexpr_ctx *ctx, const char *end)
*t++ = '\t';
continue;
case 0:
- abort();
+ BUG("escaped NUL");
default:
break;
}
@@ -203,7 +203,7 @@ bool sexpr_parse(struct sexpr_ctx *ctx, const char *s)
case failed:
return 0;
default:
- abort();
+ BUG("invalid state %d", ctx->state);
}
s++;
}