[tracker/binary-log-2: 24/56] libtracker-db: Improve db journal reader GErrors
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker/binary-log-2: 24/56] libtracker-db: Improve db journal reader GErrors
- Date: Fri, 8 Jan 2010 10:34:35 +0000 (UTC)
commit fc4f9e394c177b03df8b6c831588ecec568b7dae
Author: Martyn Russell <martyn lanedo com>
Date: Tue Jan 5 09:42:38 2010 +0000
libtracker-db: Improve db journal reader GErrors
src/libtracker-db/tracker-db-journal.c | 54 +++++++++++++++++++++++---------
1 files changed, 39 insertions(+), 15 deletions(-)
---
diff --git a/src/libtracker-db/tracker-db-journal.c b/src/libtracker-db/tracker-db-journal.c
index 46ffd10..e5428d4 100644
--- a/src/libtracker-db/tracker-db-journal.c
+++ b/src/libtracker-db/tracker-db-journal.c
@@ -534,12 +534,14 @@ tracker_db_journal_entry_next (TrackerDBJournalEntry *entry,
guint32 read_size;
if (entry->current >= entry->end) {
- g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0, "End of journal reached");
+ g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0,
+ "End of journal reached");
return FALSE;
}
if (entry->end - entry->current < sizeof (guint32)) {
- g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0, "Damaged journal entry, < sizeof(guint32) at start/end of journal");
+ g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0,
+ "Damaged journal entry, < sizeof(guint32) at start/end of journal");
return FALSE;
}
@@ -548,7 +550,8 @@ tracker_db_journal_entry_next (TrackerDBJournalEntry *entry,
entry->entry_end = entry->entry_begin + entry_size;
if (entry->end < entry->entry_end) {
- g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0, "Damaged journal entry, end < entry end");
+ g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0,
+ "Damaged journal entry, end < entry end");
return FALSE;
}
@@ -559,7 +562,10 @@ tracker_db_journal_entry_next (TrackerDBJournalEntry *entry,
if (entry_size != read_size) {
/* damaged journal entry */
- g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0, "Damaged journal entry, %d != %d (size != size read)", entry_size, read_size);
+ g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0,
+ "Damaged journal entry, %d != %d (size != size read)",
+ entry_size,
+ read_size);
return FALSE;
}
@@ -572,7 +578,8 @@ tracker_db_journal_entry_next (TrackerDBJournalEntry *entry,
/* verify checksum */
if (crc32 != tracker_crc32 (entry->entry_begin, entry_size)) {
/* damaged journal entry */
- g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0, "Damaged journal entry, crc32 failed");
+ g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0,
+ "Damaged journal entry, crc32 failed");
return FALSE;
}
@@ -583,7 +590,10 @@ tracker_db_journal_entry_next (TrackerDBJournalEntry *entry,
if (entry->current + 4 != entry->entry_end) {
/* damaged journal entry */
- g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0, "Damaged journal entry, current + 4 != entry end");
+ g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0,
+ "Damaged journal entry, %p != %p (end of transaction with 0 triples)",
+ entry->current + 4,
+ entry->entry_end);
return FALSE;
}
@@ -595,7 +605,9 @@ tracker_db_journal_entry_next (TrackerDBJournalEntry *entry,
if (entry->end - entry->current < sizeof (guint32)) {
/* damaged journal entry */
- g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0, "Damaged journal entry, < sizeof(guint32)");
+ g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0,
+ "Damaged journal entry, %d < sizeof(guint32)",
+ (gint) (entry->end - entry->current));
return FALSE;
}
@@ -607,7 +619,9 @@ tracker_db_journal_entry_next (TrackerDBJournalEntry *entry,
if (entry->end - entry->current < sizeof (guint32) + 1) {
/* damaged journal entry */
- g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0, "Damaged journal entry, < sizeof(guint32) for RESOURCE");
+ g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0,
+ "Damaged journal entry, %d < sizeof(guint32) + 1 for resource",
+ (gint) (entry->end - entry->current));
return FALSE;
}
@@ -617,14 +631,16 @@ tracker_db_journal_entry_next (TrackerDBJournalEntry *entry,
str_length = strnlen (entry->current, entry->end - entry->current);
if (str_length == entry->end - entry->current) {
/* damaged journal entry (no terminating '\0' character) */
- g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0, "Damaged journal entry, no terminating zero found for RESOURCE");
+ g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0,
+ "Damaged journal entry, no terminating zero found for resource");
return FALSE;
}
if (!g_utf8_validate (entry->current, -1, NULL)) {
/* damaged journal entry (invalid UTF-8) */
- g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0, "Damaged journal entry, invalid UTF-8 for RESOURCE");
+ g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0,
+ "Damaged journal entry, invalid UTF-8 for resource");
return FALSE;
}
@@ -647,7 +663,9 @@ tracker_db_journal_entry_next (TrackerDBJournalEntry *entry,
if (entry->end - entry->current < 2 * sizeof (guint32)) {
/* damaged journal entry */
- g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0, "Damaged journal entry, < 2 * sizeof(guint32)");
+ g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0,
+ "Damaged journal entry, %d < 2 * sizeof(guint32)",
+ (gint) (entry->end - entry->current));
return FALSE;
}
@@ -660,7 +678,9 @@ tracker_db_journal_entry_next (TrackerDBJournalEntry *entry,
if (data_format & 2) {
if (entry->end - entry->current < sizeof (guint32)) {
/* damaged journal entry */
- g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0, "Damaged journal entry, < sizeof(guint32) for data format 2");
+ g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0,
+ "Damaged journal entry, %d < sizeof(guint32) for data format 2",
+ (gint) (entry->end - entry->current));
return FALSE;
}
@@ -669,20 +689,24 @@ tracker_db_journal_entry_next (TrackerDBJournalEntry *entry,
} else {
if (entry->end - entry->current < 1) {
/* damaged journal entry */
- g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0, "Damaged journal entry, < 1");
+ g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0,
+ "Damaged journal entry, %d < 1",
+ (gint) (entry->end - entry->current));
return FALSE;
}
str_length = strnlen (entry->current, entry->end - entry->current);
if (str_length == entry->end - entry->current) {
/* damaged journal entry (no terminating '\0' character) */
- g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0, "Damaged journal entry, no terminating zero found");
+ g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0,
+ "Damaged journal entry, no terminating zero found");
return FALSE;
}
if (!g_utf8_validate (entry->current, -1, NULL)) {
/* damaged journal entry (invalid UTF-8) */
- g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0, "Damaged journal entry, invalid UTF-8");
+ g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0,
+ "Damaged journal entry, invalid UTF-8");
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]