Skip to content

Commit 44e88aa

Browse files
committed
Handle several coverity issues
1 parent 694a005 commit 44e88aa

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

Diff for: examples/example012_rsa_crypto.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ namespace local_rsa
8181
return b;
8282
}
8383

84-
local_integer_type tmp_x;
85-
local_integer_type tmp_y;
84+
local_integer_type tmp_x { };
85+
local_integer_type tmp_y { };
8686

8787
local_integer_type gcd_ext = extended_euclidean(b % a, a, &tmp_x, &tmp_y);
8888

89-
*x = tmp_y - ((b / a) * tmp_x);
90-
*y = tmp_x;
89+
*x = std::move(tmp_y - ((b / a) * tmp_x));
90+
*y = std::move(tmp_x);
9191

9292
return gcd_ext;
9393
}
@@ -258,7 +258,10 @@ namespace local_rsa
258258

259259
euclidean::extended_euclidean(a, b, &x, &s);
260260

261-
s = is_neg(s) ? make_positive(s, phi_of_m) : s;
261+
if(is_neg(s))
262+
{
263+
s = std::move(make_positive(s, phi_of_m));
264+
}
262265

263266
private_key = private_key_type { s, my_p, my_q };
264267
}

Diff for: examples/example014_pi_spigot_wide.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,12 @@ namespace example014_pi_spigot
137137
- i
138138
);
139139

140-
const auto di =
141-
((j == static_cast<std::uint32_t>(UINT8_C(0)))
142-
? static_cast<unsigned_large_type>(d_init())
143-
: static_cast<unsigned_large_type>(my_pi_in[my_index]));
140+
unsigned_large_type di { my_pi_in[my_index] };
141+
142+
if(j == static_cast<std::uint32_t>(UINT8_C(0)))
143+
{
144+
di = std::move(static_cast<unsigned_large_type>(d_init()));
145+
}
144146

145147
val_d += (di * local_pow10);
146148

0 commit comments

Comments
 (0)