Re: [PATCH 4/4] perf annotate: Introduce source_code to collect actual code

From: Ravi Bangoria
Date: Fri Feb 24 2017 - 00:58:21 EST


Hi Taeung,

On Wednesday 22 February 2017 03:38 PM, Taeung Song wrote:
> + INIT_LIST_HEAD(&notes->src->code);
> +
> + while (!feof(file)) {
> + int nr;
> + char *c, *parsed_line;
> + struct source_code *code;
> +
> + if (getline(&line, &len, file) < 0) {
> + symbol__free_source_code(sym);
> + break;
> + }
> +
> + if (++nr < first_linenr)

Please initialize variable nr. I got a compilation error:

util/annotate.c: In function ‘symbol__tty_annotate’:
util/annotate.c:1674:6: error: ‘nr’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
if (++nr < first_linenr)
^
util/annotate.c:1665:7: note: ‘nr’ was declared here
int nr;
^

Ravi