[augeas-devel] augeas: master - Remove assert_error_at

David Lutterkort lutter at fedoraproject.org
Tue Jan 26 02:21:47 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=db23496a48941a84b2c72ede0c36700af6da4e55
Commit:        db23496a48941a84b2c72ede0c36700af6da4e55
Parent:        f282c26827c6beb184b69ef9554eb89a54df727c
Author:        David Lutterkort <lutter at redhat.com>
AuthorDate:    Thu Jan 21 16:41:30 2010 -0800
Committer:     David Lutterkort <lutter at redhat.com>
CommitterDate: Mon Jan 25 17:22:30 2010 -0800

Remove assert_error_at

This function was dangerous, since it does not jump, and therefore users
will continue doing what they were doing, even if an assertion failed. Use
BUG_ON instead.
---
 src/get.c    |    9 ++++-----
 src/put.c    |    5 +++--
 src/syntax.c |   13 -------------
 src/syntax.h |    4 ----
 4 files changed, 7 insertions(+), 24 deletions(-)

diff --git a/src/get.c b/src/get.c
index 645cdb5..90a8550 100644
--- a/src/get.c
+++ b/src/get.c
@@ -37,9 +37,6 @@
 static const char *const short_iteration =
     "Iterated lens matched less than it should";
 
-#define assert_error(state, format, args ...) \
-    assert_error_at(__FILE__, __LINE__, state->info, format, ## args)
-
 struct seq {
     struct seq *next;
     const char *name;
@@ -1089,9 +1086,10 @@ static struct tree *get_lens(struct lens *lens, struct state *state) {
         tree = get_rec(lens, state);
         break;
     default:
-        assert_error(state, "illegal lens tag %d", lens->tag);
+        BUG_ON(true, state->info, "illegal lens tag %d", lens->tag);
         break;
     }
+ error:
     return tree;
 }
 
@@ -1223,9 +1221,10 @@ static struct skel *parse_lens(struct lens *lens, struct state *state,
         skel = parse_rec(lens, state, dict);
         break;
     default:
-        assert_error(state, "illegal lens tag %d", lens->tag);
+        BUG_ON(true, state->info, "illegal lens tag %d", lens->tag);
         break;
     }
+ error:
     return skel;
 }
 
diff --git a/src/put.c b/src/put.c
index 35bcd2e..e4024b8 100644
--- a/src/put.c
+++ b/src/put.c
@@ -26,6 +26,7 @@
 #include "regexp.h"
 #include "memory.h"
 #include "lens.h"
+#include "errcode.h"
 
 /* Data structure to keep track of where we are in the tree. The split
  * describes a sublist of the list of siblings in the current tree. The
@@ -414,10 +415,10 @@ static int skel_instance_of(struct lens *lens, struct skel *skel) {
     case L_REC:
         return skel_instance_of(lens->body, skel);
     default:
-        assert_error_at(__FILE__, __LINE__, lens->info,
-                        "illegal lens tag %d", lens->tag);
+        BUG_ON(true, lens->info, "illegal lens tag %d", lens->tag);
         break;
     }
+ error:
     return 0;
 }
 
diff --git a/src/syntax.c b/src/syntax.c
index 1abffd9..4e3dc6e 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -137,19 +137,6 @@ void fatal_error(struct info *info, const char *format, ...) {
     va_end(ap);
 }
 
-void assert_error_at(const char *srcfile, int srclineno, struct info *info,
-                     const char *format, ...) {
-    va_list ap;
-
-    fprintf(stderr, "%s:%d:(", srcfile, srclineno);
-    print_info(stderr, info);
-    fprintf(stderr,"):Internal error:");
-	va_start(ap, format);
-    vfprintf(stderr, format, ap);
-    va_end(ap);
-    fprintf(stderr, "\n");
-}
-
 static void free_param(struct param *param) {
     if (param == NULL)
         return;
diff --git a/src/syntax.h b/src/syntax.h
index f39c7ef..2e772fc 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -37,10 +37,6 @@ void syntax_error(struct info *info, const char *format, ...)
 void fatal_error(struct info *info, const char *format, ...)
     ATTRIBUTE_FORMAT(printf, 2, 3);
 
-void assert_error_at(const char *srcfile, int srclineno, struct info *info,
-                     const char *format, ...)
-    ATTRIBUTE_FORMAT(printf, 4, 5);
-
 enum term_tag {
     A_MODULE,
     A_BIND,              /* Module scope binding of a name */




More information about the augeas-devel mailing list