Elia Pinto <gitter.spiros@xxxxxxxxx> writes: > Fix the LGTM warning fired by the rule that finds code that could convert the result of an integer > multiplication to a larger type. Since the conversion applies after the multiplication, > arithmetic overflow may still occur. Overly long? > chunk_offsets[0] = 8 + (num_chunks + 1) * GRAPH_CHUNKLOOKUP_WIDTH; > chunk_offsets[1] = chunk_offsets[0] + GRAPH_FANOUT_SIZE; > - chunk_offsets[2] = chunk_offsets[1] + hashsz * ctx->commits.nr; > - chunk_offsets[3] = chunk_offsets[2] + (hashsz + 16) * ctx->commits.nr; > + chunk_offsets[2] = chunk_offsets[1] + (uint64_t)hashsz * ctx->commits.nr; > + chunk_offsets[3] = chunk_offsets[2] + ((uint64_t)hashsz + 16) * ctx->commits.nr; chunk_offsets[] is u64[], while hashsz and is uint and ctx->commits.nr is int. OK. > @@ -1426,7 +1426,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx) > } > if (ctx->num_commit_graphs_after > 1) { > chunk_offsets[num_chunks + 1] = chunk_offsets[num_chunks] + > - hashsz * (ctx->num_commit_graphs_after - 1); > + (uint64_t)hashsz * (ctx->num_commit_graphs_after - 1); Likewise. > @@ -1454,7 +1454,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx) > num_chunks); > ctx->progress = start_delayed_progress( > progress_title.buf, > - num_chunks * ctx->commits.nr); > + (uint64_t)num_chunks * ctx->commits.nr); Hmph, do we need this? I understand that the second parameter to the callee is u64, so the caller needs to come up with u64 without overflow, but doesn't that automatically get promoted? > } > write_graph_chunk_fanout(f, ctx); > write_graph_chunk_oids(f, hashsz, ctx);