Clear static analysis warnings
Fixing static analysis warnings: adding assert for nonnull pointer;
checking for >=0 before shift; initializing local variable
BUG=aomedia:2312
Change-Id: Iae4dea95151dbe8b4d76c297064bac9f3a93394e
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 54531e5..a8063c0 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -1566,6 +1566,8 @@
unsigned char *cx_data = ctx->cx_data;
size_t cx_data_sz = ctx->cx_data_sz;
+ assert(!(cx_data == NULL && cx_data_sz != 0));
+
/* Any pending invisible frames? */
if (ctx->pending_cx_data) {
memmove(cx_data, ctx->pending_cx_data, ctx->pending_cx_data_sz);
diff --git a/av1/encoder/hash_motion.c b/av1/encoder/hash_motion.c
index 4c872f1..00915e5 100644
--- a/av1/encoder/hash_motion.c
+++ b/av1/encoder/hash_motion.c
@@ -393,8 +393,9 @@
uint32_t *hash_value1, uint32_t *hash_value2,
int use_highbitdepth, MACROBLOCK *x) {
uint32_t to_hash[4];
- const int add_value = hash_block_size_to_index(block_size) << crc_bits;
+ int add_value = hash_block_size_to_index(block_size);
assert(add_value >= 0);
+ add_value <<= crc_bits;
const int crc_mask = (1 << crc_bits) - 1;
// 2x2 subblock hash values in current CU
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index cc7ad97..16bce20 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -9437,7 +9437,7 @@
}
if (!do_tx_search) {
- int64_t curr_sse;
+ int64_t curr_sse = -1;
int est_residue_cost = 0;
int64_t est_dist = 0;
int64_t est_rd = 0;
@@ -9464,10 +9464,12 @@
*best_est_rd = AOMMIN(*best_est_rd, rd_stats->rdcost);
if (cm->current_frame.reference_mode == SINGLE_REFERENCE) {
if (!is_comp_pred) {
+ assert(curr_sse >= 0);
inter_modes_info_push(inter_modes_info, mode_rate, curr_sse,
rd_stats->rdcost, mbmi);
}
} else {
+ assert(curr_sse >= 0);
inter_modes_info_push(inter_modes_info, mode_rate, curr_sse,
rd_stats->rdcost, mbmi);
}