[augeas-devel] augeas: master - * src/lens.c (str_to_fa): remove FIXME's and use proper error reporting

David Lutterkort lutter at fedoraproject.org
Thu Jan 14 18:19:54 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=cca990f19d8455645cbe4fc5fcf7281dcb76344a
Commit:        cca990f19d8455645cbe4fc5fcf7281dcb76344a
Parent:        3856b3f49d05cea313811e01ce3e11e545006f09
Author:        David Lutterkort <lutter at redhat.com>
AuthorDate:    Tue Jan 12 15:33:19 2010 -0800
Committer:     David Lutterkort <lutter at redhat.com>
CommitterDate: Wed Jan 13 10:27:34 2010 -0800

* src/lens.c (str_to_fa): remove FIXME's and use proper error reporting

---
 src/lens.c |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/lens.c b/src/lens.c
index b093a22..6d23ade 100644
--- a/src/lens.c
+++ b/src/lens.c
@@ -74,28 +74,34 @@ static struct value *str_to_fa(struct info *info, const char *pattern,
     int error;
     struct value *exn = NULL;
     size_t re_err_len;
-    char *re_str, *re_err;
+    char *re_str = NULL, *re_err = NULL;
 
+    *fa = NULL;
     error = fa_compile(pattern, strlen(pattern), fa);
     if (error == REG_NOERROR)
         return NULL;
 
     re_str = escape(pattern, -1);
-    if (re_str == NULL) {
-        FIXME("Out of memory");
-    }
+    ERR_NOMEM(re_str == NULL, info);
+
     exn = make_exn_value(info, "Invalid regular expression /%s/", re_str);
 
     re_err_len = regerror(error, NULL, NULL, 0);
-    if (ALLOC_N(re_err, re_err_len) < 0) {
-        FIXME("Out of memory");
-    }
+    error = ALLOC_N(re_err, re_err_len);
+    ERR_NOMEM(error < 0, info);
+
     regerror(error, NULL, re_err, re_err_len);
     exn_printf_line(exn, "%s", re_err);
 
+ done:
     free(re_str);
     free(re_err);
     return exn;
+ error:
+    fa_free(*fa);
+    *fa = NULL;
+    exn = exn_error();
+    goto done;
 }
 
 static struct value *regexp_to_fa(struct regexp *regexp, struct fa **fa) {




More information about the augeas-devel mailing list