]> wimlib.net Git - wimlib/blobdiff - src/decompress_common.c
Silence compiler warning in make_huffman_decode_table()
[wimlib] / src / decompress_common.c
index 8ea02196610d01c8670fd9cf842d5d6b0cdcd30f..66440efe203acaed25f56d6a45ddf07d12c25ab7 100644 (file)
@@ -2,25 +2,12 @@
  * decompress_common.c
  *
  * Code for decompression shared among multiple compression formats.
- */
-
-/*
- * Copyright (C) 2012, 2013, 2014 Eric Biggers
  *
- * This file is part of wimlib, a library for working with WIM files.
+ * Author:  Eric Biggers
+ * Year:    2012 - 2014
  *
- * wimlib is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with wimlib; if not, see http://www.gnu.org/licenses/.
+ * The author dedicates this file to the public domain.
+ * You can do whatever you want with this file.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -28,7 +15,7 @@
 #endif
 
 #include "wimlib/decompress_common.h"
-#include "wimlib/error.h"
+#include "wimlib/util.h" /* for BUILD_BUG_ON()  */
 
 #include <string.h>
 
@@ -191,7 +178,6 @@ make_huffman_decode_table(u16 decode_table[const restrict],
                if (unlikely(left < 0)) {
                        /* The lengths overflow the codespace; that is, the code
                         * is over-subscribed.  */
-                       DEBUG("Invalid prefix code (over-subscribed)");
                        return -1;
                }
        }
@@ -213,7 +199,6 @@ make_huffman_decode_table(u16 decode_table[const restrict],
                               table_num_entries * sizeof(decode_table[0]));
                        return 0;
                }
-               DEBUG("Invalid prefix code (incomplete set)");
                return -1;
        }
 
@@ -307,13 +292,7 @@ make_huffman_decode_table(u16 decode_table[const restrict],
 
                        v = MAKE_DIRECT_ENTRY(sorted_syms[sym_idx], codeword_len);
                        v |= v << 16;
-                       if (sizeof(unsigned long) == 8) {
-                               /* This may produce a compiler warning if an
-                                * 'unsigned long' is 32 bits, but this won't be
-                                * executed unless an 'unsigned long' is at
-                                * least 64 bits anyway.  */
-                               v |= v << 32;
-                       }
+                       v |= v << (sizeof(unsigned long) == 8 ? 32 : 0);
 
                        p = (aliased_long_t *)decode_table_ptr;
                        n = stores_per_loop;
@@ -349,7 +328,7 @@ make_huffman_decode_table(u16 decode_table[const restrict],
        }
 
        /* If we've filled in the entire table, we are done.  Otherwise,
-        * there are codes longer than table_bits for which we must
+        * there are codewords longer than table_bits for which we must
         * generate binary trees.  */
 
        decode_table_pos = (u16*)decode_table_ptr - decode_table;
@@ -358,11 +337,11 @@ make_huffman_decode_table(u16 decode_table[const restrict],
                unsigned next_free_tree_slot;
                unsigned cur_codeword;
 
-               /* First, zero out the rest of the entries.  This is
-                * necessary so that the entries appear as "unallocated"
-                * in the next part.  Each of these entries will
-                * eventually be filled the representation of the root
-                * node of a binary tree.  */
+               /* First, zero out the remaining entries.  This is
+                * necessary so that these entries appear as
+                * "unallocated" in the next part.  Each of these entries
+                * will eventually be filled with the representation of
+                * the root node of a binary tree.  */
                j = decode_table_pos;
                do {
                        decode_table[j] = 0;
@@ -370,7 +349,8 @@ make_huffman_decode_table(u16 decode_table[const restrict],
 
                /* We allocate child nodes starting at the end of the
                 * direct lookup table.  Note that there should be
-                * 2*num_syms extra entries for this purpose.  */
+                * 2*num_syms extra entries for this purpose, although
+                * fewer than this may actually be needed.  */
                next_free_tree_slot = table_num_entries;
 
                /* Iterate through each codeword with length greater than