aboutsummaryrefslogtreecommitdiffstats
path: root/libasn1parser
diff options
context:
space:
mode:
authorLev Walkin <vlm@lionet.info>2016-01-10 20:03:04 -0800
committerLev Walkin <vlm@lionet.info>2016-01-10 20:03:04 -0800
commit04abdb24636ed70603c090ae6e00bba4af9c0a8b (patch)
tree546ed491a005d0e7015f318e889a379c2e043e2f /libasn1parser
parent0f2624523b06040c4bd61581b573b9b09b791a97 (diff)
get rid of compiler warning of too smart compiler
Diffstat (limited to 'libasn1parser')
-rw-r--r--libasn1parser/asn1p_expr_str.h19
-rwxr-xr-xlibasn1parser/expr-h.pl19
2 files changed, 22 insertions, 16 deletions
diff --git a/libasn1parser/asn1p_expr_str.h b/libasn1parser/asn1p_expr_str.h
index 8e9545df..ea77c6c2 100644
--- a/libasn1parser/asn1p_expr_str.h
+++ b/libasn1parser/asn1p_expr_str.h
@@ -5,6 +5,8 @@
#ifndef ASN1_PARSER_EXPR_STR_H
#define ASN1_PARSER_EXPR_STR_H
+#include <assert.h>
+
#ifndef __GNUC__
#define __attribute__(x) /* unused */
#endif
@@ -49,13 +51,14 @@ static char *asn1p_expr_type2str[] __attribute__ ((unused)) = {
/*
* Convert the ASN.1 expression type back into the string representation.
*/
-#define ASN_EXPR_TYPE2STR(type) \
- ( \
- (((ssize_t)(type)) < 0 \
- || ((size_t)(type)) >= sizeof(asn1p_expr_type2str) \
- / sizeof(asn1p_expr_type2str[0])) \
- ? (char *)0 \
- : asn1p_expr_type2str[(int)(type)] \
- )
+#define ASN_EXPR_TYPE2STR(type) _asn_expr_type2str(type)
+
+static char * __attribute__((unused))
+_asn_expr_type2str(size_t type) {
+ assert((ssize_t)type >= 0);
+ if(type < sizeof(asn1p_expr_type2str)/sizeof(asn1p_expr_type2str[0]))
+ return asn1p_expr_type2str[type];
+ return NULL;
+}
#endif /* ASN1_PARSER_EXPR_STR_H */
diff --git a/libasn1parser/expr-h.pl b/libasn1parser/expr-h.pl
index 8b1e0805..27f4b9c4 100755
--- a/libasn1parser/expr-h.pl
+++ b/libasn1parser/expr-h.pl
@@ -9,6 +9,8 @@ print<<EOM;
#ifndef ASN1_PARSER_EXPR_STR_H
#define ASN1_PARSER_EXPR_STR_H
+#include <assert.h>
+
#ifndef __GNUC__
#define __attribute__(x) /* unused */
#endif
@@ -40,14 +42,15 @@ print<<EOM;
/*
* Convert the ASN.1 expression type back into the string representation.
*/
-#define ASN_EXPR_TYPE2STR(type) \\
- ( \\
- (((ssize_t)(type)) < 0 \\
- || ((size_t)(type)) >= sizeof(asn1p_expr_type2str) \\
- / sizeof(asn1p_expr_type2str[0])) \\
- ? (char *)0 \\
- : asn1p_expr_type2str[(int)(type)] \\
- )
+#define ASN_EXPR_TYPE2STR(type) _asn_expr_type2str(type)
+
+static char * __attribute__((unused))
+_asn_expr_type2str(size_t type) {
+ assert((ssize_t)type >= 0);
+ if(type < sizeof(asn1p_expr_type2str)/sizeof(asn1p_expr_type2str[0]))
+ return asn1p_expr_type2str[type];
+ return NULL;
+}
#endif /* ASN1_PARSER_EXPR_STR_H */
EOM