]> wimlib.net Git - wimlib/commitdiff
Add and use SHA1_HASH_STRING_LEN constant
authorEric Biggers <ebiggers3@gmail.com>
Sat, 18 Mar 2023 07:17:54 +0000 (00:17 -0700)
committerEric Biggers <ebiggers3@gmail.com>
Sat, 18 Mar 2023 07:17:54 +0000 (00:17 -0700)
include/wimlib/sha1.h
src/blob_table.c
src/inode.c
src/resource.c
src/sha1.c

index e8167faf02eb654b674dccb62611556e2f1e998b..e1def3d9f2cb274c9bd282fe47bba9fdfc55447e 100644 (file)
@@ -37,8 +37,9 @@
 
 extern const u8 zero_hash[SHA1_HASH_SIZE];
 
+#define SHA1_HASH_STRING_LEN   (2 * SHA1_HASH_SIZE + 1)
 extern void
-sprint_hash(const u8 hash[SHA1_HASH_SIZE], tchar strbuf[SHA1_HASH_SIZE * 2 + 1]);
+sprint_hash(const u8 hash[SHA1_HASH_SIZE], tchar strbuf[SHA1_HASH_STRING_LEN]);
 
 static inline void
 copy_hash(u8 dest[SHA1_HASH_SIZE], const u8 src[SHA1_HASH_SIZE])
index 5c26e894aa9219d53c3da7957f50906b4672955c..cec5b4986337f3cc878963957cc687d2f616870b 100644 (file)
@@ -1275,7 +1275,7 @@ after_blob_hashed(struct blob_descriptor *blob,
                 * blob (from a stream) to point to the duplicate.  The caller
                 * is responsible for freeing @blob if needed.  */
                if (duplicate_blob->size != blob->size) {
-                       tchar hash_str[SHA1_HASH_SIZE * 2 + 1];
+                       tchar hash_str[SHA1_HASH_STRING_LEN];
 
                        sprint_hash(blob->hash, hash_str);
                        WARNING("SHA-1 collision at \"%"TS"\"\n"
index 68e88c05fd6a21444c0ce716d68883d2c6cab001..7699e9bf9d56dc94a82c4de6265b0a036101f2d4 100644 (file)
@@ -485,7 +485,7 @@ int
 blob_not_found_error(const struct wim_inode *inode, const u8 *hash)
 {
        if (wimlib_print_errors) {
-               tchar hashstr[SHA1_HASH_SIZE * 2 + 1];
+               tchar hashstr[SHA1_HASH_STRING_LEN];
 
                sprint_hash(hash, hashstr);
 
index dd0d2edd09cd2a7f83b1fa11c4149fc234d64b5f..afba87747f906895c1f5b690dceff7a04aacc0b0 100644 (file)
@@ -1015,8 +1015,8 @@ static int
 report_sha1_mismatch(struct blob_descriptor *blob,
                     const u8 actual_hash[SHA1_HASH_SIZE], bool recover_data)
 {
-       tchar expected_hashstr[SHA1_HASH_SIZE * 2 + 1];
-       tchar actual_hashstr[SHA1_HASH_SIZE * 2 + 1];
+       tchar expected_hashstr[SHA1_HASH_STRING_LEN];
+       tchar actual_hashstr[SHA1_HASH_STRING_LEN];
 
        wimlib_assert(blob->blob_location != BLOB_NONEXISTENT);
        wimlib_assert(blob->blob_location != BLOB_IN_ATTACHED_BUFFER);
index 58f60dd7c829b2f24b3e976a252026cc7d118e12..b3062389bee56259764c9ef3f5c3302d7d18f0c4 100644 (file)
@@ -43,7 +43,7 @@ const u8 zero_hash[20];
  * The output buffer must be at least 41 characters.
  */
 void
-sprint_hash(const u8 hash[SHA1_HASH_SIZE], tchar strbuf[SHA1_HASH_SIZE * 2 + 1])
+sprint_hash(const u8 hash[SHA1_HASH_SIZE], tchar strbuf[SHA1_HASH_STRING_LEN])
 {
        int i;
        u8 high, low;