From 7f8f7e38ee7247bc25850224f5ea3e40b827435a Mon Sep 17 00:00:00 2001 From: Tollef Fog Heen Date: Mon, 12 Oct 2009 08:46:41 +0200 Subject: [PATCH] Better error handling in split_otp --- src/main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 2d450b7..59a498e 100644 --- a/src/main.c +++ b/src/main.c @@ -222,6 +222,7 @@ static int set_data_for_uid(char *uid, struct ykc_stats *stats) PGresult *res; const char *paramValues[3]; char ctr[10], use[10]; + int r = 0; paramValues[0] = uid; @@ -242,13 +243,14 @@ static int set_data_for_uid(char *uid, struct ykc_stats *stats) if (PQresultStatus(res) != PGRES_COMMAND_OK) { fprintf(stderr, "UPDATE failed: %s\n", PQerrorMessage(db_conn)); - PQclear(res); - return -1; - /* XXX Better error handling.*/ + r = -1; + goto free_mem; } assert(PQntuples(res) == 0); + +free_mem: PQclear(res); - return 0; + return r; } static int get_data_for_uid(char *uid, struct ykc_stats *stats) -- 2.39.5