Blame SOURCES/0004-ras-record-reorder-functions.patch

97e186
From 4474f696c9207ceb21d55a0047ab6871879afe5a Mon Sep 17 00:00:00 2001
97e186
From: Mauro Carvalho Chehab <mchehab@redhat.com>
97e186
Date: Fri, 31 May 2013 13:51:55 -0300
97e186
Subject: [PATCH 04/32] ras-record: reorder functions
97e186
97e186
No functional changes
97e186
97e186
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
97e186
---
97e186
 ras-record.c |   77 +++++++++++++++++++++++++++++----------------------------
97e186
 1 files changed, 39 insertions(+), 38 deletions(-)
97e186
97e186
diff --git a/ras-record.c b/ras-record.c
97e186
index efcd78f..298977e 100644
97e186
--- a/ras-record.c
97e186
+++ b/ras-record.c
97e186
@@ -46,6 +46,10 @@ struct db_table_descriptor {
97e186
 	size_t			num_fields;
97e186
 };
97e186
 
97e186
+/*
97e186
+ * Table and functions to handle ras:mc_event
97e186
+ */
97e186
+
97e186
 static const struct db_fields mc_event_fields[] = {
97e186
 		{ .name="id",			.type="INTEGER PRIMARY KEY" },
97e186
 		{ .name="timestamp",		.type="TEXT" },
97e186
@@ -69,8 +73,41 @@ static const struct db_table_descriptor mc_event_tab = {
97e186
 	.num_fields = ARRAY_SIZE(mc_event_fields),
97e186
 };
97e186
 
97e186
-const char *insertdb = "INSERT INTO";
97e186
-const char *valuesdb = " VALUES ";
97e186
+int ras_store_mc_event(struct ras_events *ras, struct ras_mc_event *ev)
97e186
+{
97e186
+	int rc;
97e186
+	struct sqlite3_priv *priv = ras->db_priv;
97e186
+
97e186
+	if (!priv || !priv->stmt_mc_event)
97e186
+		return 0;
97e186
+	log(TERM, LOG_INFO, "mc_event store: %p\n", priv->stmt_mc_event);
97e186
+
97e186
+	sqlite3_bind_text(priv->stmt_mc_event,  1, ev->timestamp, -1, NULL);
97e186
+	sqlite3_bind_int (priv->stmt_mc_event,  2, ev->error_count);
97e186
+	sqlite3_bind_text(priv->stmt_mc_event,  3, ev->error_type, -1, NULL);
97e186
+	sqlite3_bind_text(priv->stmt_mc_event,  4, ev->msg, -1, NULL);
97e186
+	sqlite3_bind_text(priv->stmt_mc_event,  5, ev->label, -1, NULL);
97e186
+	sqlite3_bind_int (priv->stmt_mc_event,  6, ev->mc_index);
97e186
+	sqlite3_bind_int (priv->stmt_mc_event,  7, ev->top_layer);
97e186
+	sqlite3_bind_int (priv->stmt_mc_event,  8, ev->middle_layer);
97e186
+	sqlite3_bind_int (priv->stmt_mc_event,  9, ev->lower_layer);
97e186
+	sqlite3_bind_int (priv->stmt_mc_event, 10, ev->address);
97e186
+	sqlite3_bind_int (priv->stmt_mc_event, 11, ev->grain);
97e186
+	sqlite3_bind_int (priv->stmt_mc_event, 12, ev->syndrome);
97e186
+	sqlite3_bind_text(priv->stmt_mc_event, 13, ev->driver_detail, -1, NULL);
97e186
+	rc = sqlite3_step(priv->stmt_mc_event);
97e186
+	if (rc != SQLITE_OK && rc != SQLITE_DONE)
97e186
+		log(TERM, LOG_ERR,
97e186
+		    "Failed to do mc_event step on sqlite: error = %d\n", rc);
97e186
+	rc = sqlite3_reset(priv->stmt_mc_event);
97e186
+	if (rc != SQLITE_OK && rc != SQLITE_DONE)
97e186
+		log(TERM, LOG_ERR,
97e186
+		    "Failed reset mc_event on sqlite: error = %d\n",
97e186
+		    rc);
97e186
+	log(TERM, LOG_INFO, "register inserted at db\n");
97e186
+
97e186
+	return rc;
97e186
+}
97e186
 
97e186
 static int ras_mc_prepare_stmt(struct sqlite3_priv *priv,
97e186
 			       sqlite3_stmt **stmt,
97e186
@@ -208,39 +245,3 @@ int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras)
97e186
 
97e186
 	return 0;
97e186
 }
97e186
-
97e186
-int ras_store_mc_event(struct ras_events *ras, struct ras_mc_event *ev)
97e186
-{
97e186
-	int rc;
97e186
-	struct sqlite3_priv *priv = ras->db_priv;
97e186
-
97e186
-	if (!priv || !priv->stmt_mc_event)
97e186
-		return 0;
97e186
-	log(TERM, LOG_INFO, "mc_event store: %p\n", priv->stmt_mc_event);
97e186
-
97e186
-	sqlite3_bind_text(priv->stmt_mc_event,  1, ev->timestamp, -1, NULL);
97e186
-	sqlite3_bind_int (priv->stmt_mc_event,  2, ev->error_count);
97e186
-	sqlite3_bind_text(priv->stmt_mc_event,  3, ev->error_type, -1, NULL);
97e186
-	sqlite3_bind_text(priv->stmt_mc_event,  4, ev->msg, -1, NULL);
97e186
-	sqlite3_bind_text(priv->stmt_mc_event,  5, ev->label, -1, NULL);
97e186
-	sqlite3_bind_int (priv->stmt_mc_event,  6, ev->mc_index);
97e186
-	sqlite3_bind_int (priv->stmt_mc_event,  7, ev->top_layer);
97e186
-	sqlite3_bind_int (priv->stmt_mc_event,  8, ev->middle_layer);
97e186
-	sqlite3_bind_int (priv->stmt_mc_event,  9, ev->lower_layer);
97e186
-	sqlite3_bind_int (priv->stmt_mc_event, 10, ev->address);
97e186
-	sqlite3_bind_int (priv->stmt_mc_event, 11, ev->grain);
97e186
-	sqlite3_bind_int (priv->stmt_mc_event, 12, ev->syndrome);
97e186
-	sqlite3_bind_text(priv->stmt_mc_event, 13, ev->driver_detail, -1, NULL);
97e186
-	rc = sqlite3_step(priv->stmt_mc_event);
97e186
-	if (rc != SQLITE_OK && rc != SQLITE_DONE)
97e186
-		log(TERM, LOG_ERR,
97e186
-		    "Failed to do mc_event step on sqlite: error = %d\n", rc);
97e186
-	rc = sqlite3_reset(priv->stmt_mc_event);
97e186
-	if (rc != SQLITE_OK && rc != SQLITE_DONE)
97e186
-		log(TERM, LOG_ERR,
97e186
-		    "Failed reset mc_event on sqlite: error = %d\n",
97e186
-		    rc);
97e186
-	log(TERM, LOG_INFO, "register inserted at db\n");
97e186
-
97e186
-	return rc;
97e186
-}
97e186
-- 
97e186
1.7.1
97e186