ソースを参照

liblzma: Suppress clang-analyzer warnings

Brad King 2 年 前
コミット
e24c403816

+ 3 - 0
Utilities/cmliblzma/liblzma/common/index.c

@@ -263,6 +263,9 @@ index_tree_append(index_tree *tree, index_tree_node *node)
 		up = ctz32(tree->count) + 2;
 		do {
 			node = node->parent;
+			#ifdef __clang_analyzer__
+			assert(node);
+			#endif
 		} while (--up > 0);
 
 		// Rotate left using node as the rotation root.

+ 4 - 0
Utilities/cmliblzma/liblzma/common/index_encoder.c

@@ -237,12 +237,15 @@ lzma_index_buffer_encode(const lzma_index *i,
 
 	// Do the actual encoding. This should never fail, but store
 	// the original *out_pos just in case.
+#ifndef __clang_analyzer__ // Hide unreachable code from clang-analyzer.
 	const size_t out_start = *out_pos;
+#endif
 	lzma_ret ret = index_encode(&coder, NULL, NULL, NULL, 0,
 			out, out_pos, out_size, LZMA_RUN);
 
 	if (ret == LZMA_STREAM_END) {
 		ret = LZMA_OK;
+#ifndef __clang_analyzer__ // Hide unreachable code from clang-analyzer.
 	} else {
 		// We should never get here, but just in case, restore the
 		// output position and set the error accordingly if something
@@ -250,6 +253,7 @@ lzma_index_buffer_encode(const lzma_index *i,
 		assert(0);
 		*out_pos = out_start;
 		ret = LZMA_PROG_ERROR;
+#endif
 	}
 
 	return ret;