From dc2b43b3e7bebe5c1fb9dedcb8630c4d45a99266 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Mon, 19 Apr 2010 10:17:31 -0400 Subject: [PATCH 1/4] Fix logic error for missing options in reader --- gvdb-reader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gvdb-reader.c b/gvdb-reader.c index 65bef5e9b..2bec7dccf 100644 --- a/gvdb-reader.c +++ b/gvdb-reader.c @@ -417,7 +417,7 @@ gvdb_table_get_value (GvdbTable *file, { data = gvdb_table_dereference (file, &item->options, 8, &size); - if (data != NULL || size > 0) + if (data != NULL && size > 0) { *options = g_variant_new_from_data (G_VARIANT_TYPE ("a{sv}"), data, size, file->trusted, From 6713b3dbaaabf9bbf196e6bc45d200b092239b59 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Mon, 19 Apr 2010 10:18:44 -0400 Subject: [PATCH 2/4] Whitespace fixups --- gvdb-builder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gvdb-builder.c b/gvdb-builder.c index e13924349..de9fff2a4 100644 --- a/gvdb-builder.c +++ b/gvdb-builder.c @@ -254,7 +254,7 @@ file_builder_allocate (FileBuilder *fb, static void file_builder_add_value (FileBuilder *fb, GVariant *value, - struct gvdb_pointer *pointer) + struct gvdb_pointer *pointer) { GVariant *variant, *normal; gpointer data; From 2d9811ebdaee294ac9a1826db5be891b2b90d67f Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Mon, 19 Apr 2010 10:28:44 -0400 Subject: [PATCH 3/4] Don't write out zero-byte sections in builder This and the previous issue caught by Christian Persch in bug #616156 --- gvdb-builder.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gvdb-builder.c b/gvdb-builder.c index de9fff2a4..7cca13f9d 100644 --- a/gvdb-builder.c +++ b/gvdb-builder.c @@ -236,6 +236,9 @@ file_builder_allocate (FileBuilder *fb, { FileChunk *chunk; + if (size == 0) + return NULL; + fb->offset += (-fb->offset) & (alignment - 1); chunk = g_slice_new (FileChunk); chunk->offset = fb->offset; From 291a5c9ed98cf5456c8d6af0c3113610646de7b3 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Tue, 20 Apr 2010 20:12:41 -0400 Subject: [PATCH 4/4] __value -> value to avoid stomping the C compiler --- gvdb-format.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gvdb-format.h b/gvdb-format.h index 41c825455..f11a033b6 100644 --- a/gvdb-format.h +++ b/gvdb-format.h @@ -24,8 +24,8 @@ #include -typedef struct { guint16 __value; } guint16_le; -typedef struct { guint32 __value; } guint32_le; +typedef struct { guint16 value; } guint16_le; +typedef struct { guint32 value; } guint32_le; struct gvdb_pointer { guint32_le start; @@ -69,7 +69,7 @@ static inline guint32_le guint32_to_le (guint32 value) { } static inline guint32 guint32_from_le (guint32_le value) { - return GUINT32_FROM_LE (value.__value); + return GUINT32_FROM_LE (value.value); } static inline guint16_le guint16_to_le (guint16 value) { @@ -78,7 +78,7 @@ static inline guint16_le guint16_to_le (guint16 value) { } static inline guint16 guint16_from_le (guint16_le value) { - return GUINT16_FROM_LE (value.__value); + return GUINT16_FROM_LE (value.value); } #define GVDB_SIGNATURE0 1918981703