Skip to content

Commit 930521d

Browse files
committed
resolved warnings for control reaching end of function
1 parent 699090a commit 930521d

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

hashing/ripemd_160.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828
#include <iomanip> /// For functions like std::setw, std::setfill
2929
#include <iostream> /// For managing io
3030
#include <sstream> /// For bytes to hex string
31-
#include <string> /// For string data
32-
#include <thread> /// To parallelize for efficiency
33-
#include <vector> /// For dynamic arrays
31+
#include <stdexcept> /// For standard exceptions like std::runtime_error
32+
#include <string> /// For string data
33+
#include <thread> /// To parallelize for efficiency
34+
#include <vector> /// For dynamic arrays
3435

3536
/**
3637
* @namespace hashing
@@ -49,6 +50,7 @@ class RIPEMD160 {
4950
* @param j Round number j / 16
5051
* @param B,C,D The state values
5152
* @return Returns the function value
53+
* @note 0 <= j <= 4
5254
*/
5355
uint32_t f(int j, uint32_t B, uint32_t C, uint32_t D) {
5456
switch (j) {
@@ -63,12 +65,15 @@ class RIPEMD160 {
6365
case 4:
6466
return B ^ (C | ~D);
6567
}
68+
69+
throw std::runtime_error("j value out of bound");
6670
}
6771

6872
/**
6973
* @brief Implements K value for a given j
7074
* @param j Round number j / 16
7175
* @return Appropriate K value
76+
* @note 0 <= j <= 4
7277
*/
7378
uint32_t K(int j) {
7479
switch (j) {
@@ -83,12 +88,15 @@ class RIPEMD160 {
8388
case 4:
8489
return static_cast<uint32_t>(0xA953FD4E);
8590
}
91+
92+
throw std::runtime_error("j value out of bound");
8693
}
8794

8895
/**
8996
* @brief Implements K' value for a given j
9097
* @param j Round number j / 16
9198
* @return Appropriate K' value
99+
* @note 0 <= j <= 4
92100
*/
93101
uint32_t K_dash(int j) {
94102
switch (j) {
@@ -103,6 +111,8 @@ class RIPEMD160 {
103111
case 4:
104112
return 0x00000000;
105113
}
114+
115+
throw std::runtime_error("j value out of bound");
106116
}
107117

108118
/**

0 commit comments

Comments
 (0)