Skip to contentSkip to conversation

ASN.1: Avoid fall-through warning

PATCH New Katya Orlova 1 participant 1 message Aug 11, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASN.1: Avoid fall-through warning

There are two FALL_THROUGH warnings in asn1_compiler.c.

The patch fixes one of them with adding 'fallthough' annotation copied from include/linux/compiler_attributes.h.

The second one is in function render_element() in line 1487:

    case TYPE_REF:
        if (e-class == ASN1_UNIV && e->method == ASN1_prim && e->tag == 0)
            goto dont_render_tag;
    default:

Is this break omission in the else branch made on purpose or is it a mistake?

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 4520c6a49af8 ("X.509: Add simple ASN.1 grammar compiler")
---
 scripts/asn1_compiler.c | 5 +++++
 1 file changed, 5 insertions(+), 0 deletions(-)
scripts/asn1_compiler.c +5 -0
index 4c3f645065a4..73e1675a852b 100644
@@ -17,6 +17,12 @@
 #include <sys/stat.h>
 #include <linux/asn1_ber_bytecode.h>
 
+#if __has_attribute(__fallthrough__)
+# define fallthrough                __attribute__((__fallthrough__))
+#else
+# define fallthrough                do {} while (0) /* fallthrough */
+#endif
 
 enum token_type {
 	DIRECTIVE_ABSENT,

DIRECTIVE_ALL,
@@ -965,6 +971,7 @@ static struct element *parse_type(struct token **_cursor, struct token *end,

case DIRECTIVE_EXTERNAL:
element->method = ASN1_CONS;
+ fallthrough;

case DIRECTIVE_BMPString:
case DIRECTIVE_GeneralString:

Signature · 1 line
2.30.2