[libbluray-devel] initialize UO mask padding bits to 0

hpi1 git at videolan.org
Sun Apr 19 15:02:31 CEST 2015


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Fri Apr 17 21:24:57 2015 +0300| [87cb0495b6db5bd264a2fb02849df68442ba9fec] | committer: hpi1

initialize UO mask padding bits to 0

Allows comparing UO masks with memcmp

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=87cb0495b6db5bd264a2fb02849df68442ba9fec
---

 src/libbluray/bdnav/mpls_parse.c    |    2 ++
 src/libbluray/bdnav/uo_mask_table.h |   13 ++++++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/libbluray/bdnav/mpls_parse.c b/src/libbluray/bdnav/mpls_parse.c
index 69b0034..d26b1f0 100644
--- a/src/libbluray/bdnav/mpls_parse.c
+++ b/src/libbluray/bdnav/mpls_parse.c
@@ -56,6 +56,8 @@ mpls_parse_uo(uint8_t *buf, BD_UO_MASK *uo)
     BITBUFFER bb;
     bb_init(&bb, buf, 8);
 
+    memset(uo, 0, sizeof(BD_UO_MASK));
+
     uo->menu_call                       = bb_read(&bb, 1);
     uo->title_search                    = bb_read(&bb, 1);
     uo->chapter_search                  = bb_read(&bb, 1);
diff --git a/src/libbluray/bdnav/uo_mask_table.h b/src/libbluray/bdnav/uo_mask_table.h
index 3eb24d9..af0eca6 100644
--- a/src/libbluray/bdnav/uo_mask_table.h
+++ b/src/libbluray/bdnav/uo_mask_table.h
@@ -63,9 +63,9 @@ typedef struct bd_uo_mask_table_s
 static inline BD_UO_MASK bd_uo_mask_combine(BD_UO_MASK a, BD_UO_MASK b)
 {
     union {
-        BD_UO_MASK mask;
         uint64_t   u64;
-    } mask_a, mask_b, result;
+        BD_UO_MASK mask;
+    } mask_a = {0}, mask_b = {0}, result;
 
     mask_a.mask = a;
     mask_b.mask = b;
@@ -78,9 +78,12 @@ static inline BD_UO_MASK bd_uo_mask_combine(BD_UO_MASK a, BD_UO_MASK b)
 
 static inline BD_UO_MASK bd_empty_uo_mask(void)
 {
-    const BD_UO_MASK empty = EMPTY_UO_MASK;
-    return empty;
-}
+    static const union {
+        const uint64_t   u64;
+        const BD_UO_MASK mask;
+    } empty = {0};
 
+    return empty.mask;
+}
 
 #endif // _BD_UO_MASK_TABLE_H_



More information about the libbluray-devel mailing list