From 8310af38c8124c56b3971c6c2c1cf650012876cf Mon Sep 17 00:00:00 2001 From: Rob Davies Date: Tue, 22 Oct 2024 17:26:58 +0100 Subject: [PATCH] Fix "may be used uninitialized" warnings at low optimisation These are probably false positives, but with low optimisation the compiler isn't able to work out that the variables are always set before use. Fix by always assigning them. --- plugins/split-vep.c | 6 ++++-- read_consensus.c | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/split-vep.c b/plugins/split-vep.c index a59f6bb1..f459b418 100644 --- a/plugins/split-vep.c +++ b/plugins/split-vep.c @@ -30,6 +30,7 @@ #include #include // for isatty #include +#include #include #include #include @@ -606,7 +607,7 @@ static void parse_column_str(args_t *args) char keep = *ep; *ep = 0; int type = -1; - int idx_beg, idx_end; + int idx_beg = 0, idx_end = -1; if ( !strcmp("-",bp) ) { kstring_t str = {0,0,0}; @@ -973,11 +974,12 @@ static void init_data(args_t *args) else { int len = strlen(sel_csq); - int severity, modifier = '='; + int severity = -1, modifier = '='; if ( sel_csq[len-1]=='+' ) { modifier = '+'; sel_csq[len-1] = 0; } else if ( sel_csq[len-1]=='-' ) { modifier = '-'; sel_csq[len-1] = 0; } if ( khash_str2int_get(args->csq2severity, sel_csq, &severity)!=0 ) error("Error: the consequence \"%s\" is not recognised. Run \"bcftools +split-vep -S ?\" to see the default list.\n", sel_csq); + assert(severity >= 0); if ( modifier=='=' ) { args->min_severity = severity; args->max_severity = severity; } else if ( modifier=='+' ) { args->min_severity = severity; args->max_severity = INT_MAX; } else if ( modifier=='-' ) { args->min_severity = 0; args->max_severity = severity; } diff --git a/read_consensus.c b/read_consensus.c index 593b19b5..f66cc7dc 100644 --- a/read_consensus.c +++ b/read_consensus.c @@ -521,7 +521,7 @@ static int create_haplotype_frequency_spectrum(read_cns_t *rcns) } else if ( cvar->vtype==ins ) { - int len; + int len = 0; ins_freq_t *ifrq = &rcns->ins_freq[cvar->pos - rcns->beg]; int iseq = cstate_seek_op_fwd(&cigar, cvar->pos+1, BAM_CINS, &len); if ( iseq==-2 ) break; @@ -533,7 +533,7 @@ static int create_haplotype_frequency_spectrum(read_cns_t *rcns) } else if ( cvar->vtype==del ) { - int len; + int len = 0; del_freq_t *dfrq = &rcns->del_freq[cvar->pos - rcns->beg]; int ret = cstate_seek_op_fwd(&cigar, cvar->pos+1, BAM_CDEL, &len); if ( ret==-2 ) break;