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

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