Blame SOURCES/0005-ras-record-Make-the-code-easier-to-add-support-for-o.patch

97e186
From 93217061a4b1dc7f287f2715aadc621d2c00425d Mon Sep 17 00:00:00 2001
97e186
From: Mauro Carvalho Chehab <mchehab@redhat.com>
97e186
Date: Fri, 31 May 2013 13:53:18 -0300
97e186
Subject: [PATCH 05/32] ras-record: Make the code easier to add support for other tables
97e186
97e186
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
97e186
---
97e186
 ras-record.c |   25 ++++++++-----------------
97e186
 1 files changed, 8 insertions(+), 17 deletions(-)
97e186
97e186
diff --git a/ras-record.c b/ras-record.c
97e186
index 298977e..36b3373 100644
97e186
--- a/ras-record.c
97e186
+++ b/ras-record.c
97e186
@@ -143,10 +143,14 @@ static int ras_mc_prepare_stmt(struct sqlite3_priv *priv,
97e186
 #endif
97e186
 
97e186
 	rc = sqlite3_prepare_v2(priv->db, sql, -1, stmt, NULL);
97e186
-	if (rc != SQLITE_OK)
97e186
+	if (rc != SQLITE_OK) {
97e186
 		log(TERM, LOG_ERR,
97e186
 		    "Failed to prepare insert db at table %s (db %s): error = %s\n",
97e186
 		    db_tab->name, SQLITE_RAS_DB, sqlite3_errmsg(priv->db));
97e186
+		stmt = NULL;
97e186
+	} else {
97e186
+		log(TERM, LOG_INFO, "Recording %s events\n", db_tab->name);
97e186
+	}
97e186
 
97e186
 	return rc;
97e186
 }
97e186
@@ -225,23 +229,10 @@ int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras)
97e186
 	priv->db = db;
97e186
 
97e186
 	rc = ras_mc_create_table(priv, &mc_event_tab);
97e186
-	if (rc != SQLITE_OK) {
97e186
-		sqlite3_close(db);
97e186
-		free(priv);
97e186
-		return -1;
97e186
-	}
97e186
+	if (rc == SQLITE_OK)
97e186
+		rc = ras_mc_prepare_stmt(priv, &priv->stmt_mc_event, &mc_event_tab);
97e186
 
97e186
-	rc = ras_mc_prepare_stmt(priv, &priv->stmt_mc_event, &mc_event_tab);
97e186
-	if (rc == SQLITE_OK) {
97e186
-		log(TERM, LOG_INFO,
97e186
-		    "cpu %u: Recording events at %s\n",
97e186
-		    cpu, SQLITE_RAS_DB);
97e186
-		ras->db_priv = priv;
97e186
-	} else {
97e186
-		sqlite3_close(db);
97e186
-		free(priv);
97e186
-		return -1;
97e186
-	}
97e186
 
97e186
+	ras->db_priv = priv;
97e186
 	return 0;
97e186
 }
97e186
-- 
97e186
1.7.1
97e186