Skip to content

Commit

Permalink
Fix "may be used uninitialized" warnings at low optimisation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
daviesrob authored and pd3 committed Oct 31, 2024
1 parent fcdae25 commit 8310af3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions plugins/split-vep.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <getopt.h>
#include <unistd.h> // for isatty
#include <inttypes.h>
#include <assert.h>
#include <htslib/hts.h>
#include <htslib/vcf.h>
#include <htslib/bgzf.h>
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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; }
Expand Down
4 changes: 2 additions & 2 deletions read_consensus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 8310af3

Please sign in to comment.