Skip to content

Commit

Permalink
Merge pull request #2073 from dtcenter/feature_1996_sonarqube_findings2
Browse files Browse the repository at this point in the history
Feature 1996 sonarqube findings
  • Loading branch information
hsoh-u authored Mar 1, 2022
2 parents 30ad6b6 + b55b5c9 commit 7d63e0f
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion met/src/basic/vx_config/threshold.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ if ( tf_left ) return ( true );

const bool tf_right = right_child->check(x, cmn, csd);

return ( tf_left || tf_right );
return ( tf_right );

}

Expand Down
9 changes: 5 additions & 4 deletions met/src/basic/vx_util/ascii_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1002,9 +1002,10 @@ if ( DoCommaString ) {

p = strchr(junk, '.');

if ( p ) *p = (char) 0;

++p;
if ( p ) {
*p = (char) 0;
++p;
}

X = atol(junk);

Expand All @@ -1014,7 +1015,7 @@ if ( DoCommaString ) {

s << j2;

if ( Precision > 0 ) s << '.' << p;
if ( Precision > 0 && p ) s << '.' << p;

set_entry(r, c, s.string());

Expand Down
1 change: 1 addition & 0 deletions met/src/libcode/vx_nc_obs/met_point_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ void MetPointHeader::reset_counters() {
strl_len = 0;
strll_len = 0;
hdr_count = 0;
hdr_type_count = 0;

min_vld_time = -1;
max_vld_time = -1;
Expand Down
2 changes: 2 additions & 0 deletions met/src/libcode/vx_nc_obs/nc_obs_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ void NcDataBuffer::reset_counters() {
hdr_data_offset = 0;
pb_hdr_count = 0;
pb_hdr_data_offset = 0;
prev_hdr_vld = 0;
}

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -988,6 +989,7 @@ void NetcdfObsVars::reset(bool _use_var_id) {
deflate_level = 0;
hdr_cnt = 0; // header array length (fixed dimension if hdr_cnt > 0)
obs_cnt = 0; // obs. array length (fixed dimension if obs_cnt > 0)
raw_hdr_cnt = 0;
//hdr_str_len = 0; // string length for header (message) type header
}

Expand Down
33 changes: 17 additions & 16 deletions met/src/libcode/vx_shapedata/interest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -601,23 +601,33 @@ void get_percentiles(DistributionPercentiles &ptile,
const int perc, const bool precip_flag)

{
int i, x, y, count, n_values;
int i, x, y, n_values;
int nx, ny;
double *v = (double *) 0;
double *v_tmp = (double *) 0;
const char *method_name = "get_percentiles() -> ";

nx = raw.data.nx();
ny = raw.data.ny();

v_tmp = new double[nx*ny];
if(!v_tmp) {
mlog << Error << "\n" << method_name << "memory allocation error, v_tmp\n\n";
exit(1);
}

//
// Count values.
// Only check precipitation for values greater than zero.
// Only collect precipitation values greater than zero.
//
n_values = 0;
for(x=0; x<nx; ++x) {
for(y=0; y<ny; ++y) {
if((mask.s_is_on(x, y)) &&
(raw.is_valid_xy(x, y)) &&
(!precip_flag || (precip_flag && raw.data(x, y) > 0))) ++n_values;
(!precip_flag || (precip_flag && raw.data(x, y) > 0))) {
v_tmp[n_values++] = (double)(raw.data(x, y));
}
}
}

Expand All @@ -627,25 +637,15 @@ void get_percentiles(DistributionPercentiles &ptile,
v = new double [n_values];

if(!v) {
mlog << Error << "\nget_percentiles() -> "
<< "memory allocation error\n\n";
mlog << Error << "\n" << method_name << "memory allocation error\n\n";
exit(1);
}

//
// Fill values
//
count = 0;
for(x=0; x<nx; ++x) {
for(y=0; y<ny; ++y) {
if((mask.s_is_on(x, y)) &&
(raw.is_valid_xy(x, y)) &&
(!precip_flag || (precip_flag && raw.data(x, y) > 0))) {

v[count++] = (double) (raw.data(x, y));
}
}
}
for(x=0; x<n_values; ++x)
v[x] = v_tmp[x];

//
// Sort
Expand Down Expand Up @@ -685,6 +685,7 @@ void get_percentiles(DistributionPercentiles &ptile,
//
// Free memory
//
if(v_tmp) { delete [] v_tmp; v_tmp = (double *) 0; }
if(v) { delete [] v; v = (double *) 0; }

//
Expand Down
2 changes: 0 additions & 2 deletions met/src/libcode/vx_tc_util/genesis_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ class GenesisInfo : public TrackInfo {

void assign(const GenesisInfo &);

bool IsSet;

// Genesis Information
int GenesisIndex;
unixtime GenesisTime;
Expand Down
1 change: 1 addition & 0 deletions met/src/tools/other/gen_ens_prod/gen_ens_prod.cc
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ void get_ens_mean_stdev(GenEnsProdVarInfo *ens_info,
<< "Computing the ensemble mean and standard deviation for "
<< ens_info->raw_magic_str << ".\n";

nxy = 0;
// Loop over the ensemble inputs
for(i_ens=0; i_ens < ens_info->inputs_n(); i_ens++) {

Expand Down

0 comments on commit 7d63e0f

Please sign in to comment.