[PATCH 7/7] CLI: add simple error handling for talloc logging

david at tethera.net david at tethera.net
Sat Jan 19 10:25:58 PST 2013


From: David Bremner <bremner at debian.org>

This really should have been there before. I think it's better to do
the actual operation and then possibly fail writing the memory log,
but it would not be too hard to change it to abort earlier.
---
 notmuch.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/notmuch.c b/notmuch.c
index f8d4b35..c3336e8 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -301,7 +301,12 @@ main (int argc, char *argv[])
 
 	    if (leak_report && (strcmp (leak_report, "") != 0)) {
 		FILE *report = fopen (leak_report, "w");
-		talloc_report_full (NULL, report);
+		if (report) {
+		    talloc_report_full (NULL, report);
+		} else {
+		    ret = 1;
+		    perror (leak_report);
+		}
 	    }
 
 	    return ret;
-- 
1.7.10.4



More information about the notmuch mailing list