summaryrefslogtreecommitdiff
path: root/lib/base64.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2023-10-11 00:15:32 +0300
committerIgor Ryzhov <iryzhov@nfware.com>2023-10-12 21:23:18 +0300
commit7d67b9ff28d09de58c632f80ef7d330e45e698f6 (patch)
tree16c8afc9dc80d70951f83d2f1182ace0edc7ee49 /lib/base64.c
parent9bc4d9eaec92589deda092bd867054e25e64be3f (diff)
build: add -Wimplicit-fallthrough
Also: - replace all /* fallthrough */ comments with portable fallthrough; pseudo keyword to accomodate both gcc and clang - add missing break; statements as required by older versions of gcc - cleanup some code to remove unnecessary fallthrough Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'lib/base64.c')
-rw-r--r--lib/base64.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/base64.c b/lib/base64.c
index 1507b0252b..ee2e838c01 100644
--- a/lib/base64.c
+++ b/lib/base64.c
@@ -9,6 +9,7 @@
#endif
#include "base64.h"
+#include "compiler.h"
static const int CHARS_PER_LINE = 72;
static const char *ENCODING =
@@ -41,6 +42,7 @@ int base64_encode_block(const char *plaintext_in, int length_in, char *code_out,
switch (state_in->step) {
while (1) {
+ fallthrough;
case step_A:
if (plainchar == plaintextend) {
state_in->result = result;
@@ -51,7 +53,7 @@ int base64_encode_block(const char *plaintext_in, int length_in, char *code_out,
result = (fragment & 0x0fc) >> 2;
*codechar++ = base64_encode_value(result);
result = (fragment & 0x003) << 4;
- /* fall through */
+ fallthrough;
case step_B:
if (plainchar == plaintextend) {
state_in->result = result;
@@ -62,7 +64,7 @@ int base64_encode_block(const char *plaintext_in, int length_in, char *code_out,
result |= (fragment & 0x0f0) >> 4;
*codechar++ = base64_encode_value(result);
result = (fragment & 0x00f) << 2;
- /* fall through */
+ fallthrough;
case step_C:
if (plainchar == plaintextend) {
state_in->result = result;
@@ -146,6 +148,7 @@ int base64_decode_block(const char *code_in, int length_in, char *plaintext_out,
switch (state_in->step) {
while (1) {
+ fallthrough;
case step_a:
do {
if (codec == code_in+length_in) {
@@ -156,7 +159,7 @@ int base64_decode_block(const char *code_in, int length_in, char *plaintext_out,
fragmt = base64_decode_value(*codec++);
} while (fragmt < 0);
*plainc = (fragmt & 0x03f) << 2;
- /* fall through */
+ fallthrough;
case step_b:
do {
if (codec == code_in+length_in) {
@@ -168,7 +171,7 @@ int base64_decode_block(const char *code_in, int length_in, char *plaintext_out,
} while (fragmt < 0);
*plainc++ |= (fragmt & 0x030) >> 4;
*plainc = (fragmt & 0x00f) << 4;
- /* fall through */
+ fallthrough;
case step_c:
do {
if (codec == code_in+length_in) {
@@ -180,7 +183,7 @@ int base64_decode_block(const char *code_in, int length_in, char *plaintext_out,
} while (fragmt < 0);
*plainc++ |= (fragmt & 0x03c) >> 2;
*plainc = (fragmt & 0x003) << 6;
- /* fall through */
+ fallthrough;
case step_d:
do {
if (codec == code_in+length_in) {