[lvc-project] [PATCH] ASN.1: Avoid fall-through warning

Katya Orlova e.orlova at ispras.ru
Fri Aug 11 15:10:58 MSK 2023


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")
Signed-off-by: Katya Orlova <e.orlova at ispras.ru>
---
 scripts/asn1_compiler.c | 5 +++++
 1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/scripts/asn1_compiler.c b/scripts/asn1_compiler.c
index 4c3f645065a4..73e1675a852b 100644
--- a/scripts/asn1_compiler.c
+++ b/scripts/asn1_compiler.c
@@ -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:
-- 
2.30.2




More information about the lvc-project mailing list