removed gcc-7 warnings

This commit is contained in:
Lev Walkin 2017-10-19 03:06:35 -07:00
parent b2d896e4d9
commit 48e82d1f1f
16 changed files with 80 additions and 57 deletions

View File

@ -328,10 +328,13 @@ main(int ac, char **av) {
ret = asn1f_process(asn, asn1_fixer_flags,
NULL /* default fprintf(stderr) */);
switch(ret) {
case 1:
if(!warnings_as_errors) /* Fall through */
case 0:
case 0:
break; /* All clear */
case 1:
if(!warnings_as_errors) {
break;
}
/* Fall through */
case -1:
exit_code = EX_DATAERR; /* Fatal failure */
goto cleanup;
@ -467,7 +470,7 @@ importStandardModules(asn1p_t *asn, const char *skeletons_dir) {
/*
* Print the usage screen and exit(EX_USAGE).
*/
static void
static void __attribute__((noreturn))
usage(const char *av0) {
/* clang-format off */
fprintf(stderr,

View File

@ -173,7 +173,6 @@ process_line(const char *fname, char *line, int lineno) {
ber_tlv_len_t tlv_len;
ber_tlv_len_t opt_tl_len; /* optional TL length */
ssize_t ret;
(void)fname;
/* Skip the whitespace */
for(; *line == ' ' || *line == '\t'; line++)
@ -184,11 +183,15 @@ process_line(const char *fname, char *line, int lineno) {
switch(*op) {
case '<': /* That's what we want! A tag opening */
break;
case '-': /* This is a comment (dash-dash) */
if(op[1] == *op) case '\r':
case '\r':
case '\n':
case '#': /* This is a comment */
return 0;
case '-': /* This is a comment (dash-dash) */
if(op[1] == '-') {
return 0;
}
/* Fall through */
default:
fprintf(stderr, "%s: Missing '<' after whitespace at line %d\n", fname,
lineno);

View File

@ -2333,6 +2333,7 @@ try_inline_default(arg_t *arg, asn1p_expr_t *expr, int out) {
switch(etype) {
case ASN_BASIC_BOOLEAN:
fits_long = 1;
/* Fall through */
case ASN_BASIC_INTEGER:
case ASN_BASIC_ENUMERATED:
if(expr->marker.default_value == NULL
@ -3439,13 +3440,15 @@ static int compar_cameo(const void *ap, const void *bp) {
&atag, AFT_IMAGINARY_ANY | AFT_CANON_CHOICE)))
return 1;
if(WITH_MODULE_NAMESPACE(b->expr->module, expr_ns,
asn1f_fetch_outmost_tag(
arg->asn, expr_ns, b->expr->module, b->expr,
&btag, AFT_IMAGINARY_ANY | AFT_CANON_CHOICE)))
if(WITH_MODULE_NAMESPACE(
b->expr->module, expr_ns,
asn1f_fetch_outmost_tag(arg->asn, expr_ns, b->expr->module, b->expr,
&btag,
AFT_IMAGINARY_ANY | AFT_CANON_CHOICE))) {
return -1;
}
if(atag.tag_class < btag.tag_class)
if(atag.tag_class < btag.tag_class)
return -1;
if(atag.tag_class > btag.tag_class)
return 1;

View File

@ -463,9 +463,11 @@ asn1c_type_fits_long(arg_t *arg, asn1p_expr_t *expr) {
/* Special case for unsigned */
if(!(arg->flags & A1C_USE_WIDE_TYPES) && left.type == ARE_VALUE
&& left.value >= 0 && left.value <= 2147483647 && right.type == ARE_MAX)
&& left.value >= 0 && left.value <= 2147483647
&& right.type == ARE_MAX) {
return FL_FITS_UNSIGN;
if(left.type == ARE_VALUE
}
if(left.type == ARE_VALUE
&& left.value >= 0
&& right.type == ARE_VALUE
&& right.value > 2147483647

View File

@ -711,8 +711,9 @@ include_type_to_pdu_collection(arg_t *arg) {
return 0;
/* Parameterized types can't serve as PDU's without instantiation. */
if(arg->expr->lhs_params)
if(arg->expr->lhs_params) {
return 0;
}
if((arg->flags & A1C_PDU_ALL)
|| ((arg->flags & A1C_PDU_AUTO) && !arg->expr->_type_referenced)

View File

@ -112,6 +112,7 @@ asn1f_fix_bit_string_value(arg_t *arg, asn1p_expr_t *ttype) {
break;
}
/* Fall through: remove trailing zero bits */
/* Fall through */
case ATV_BITVECTOR:
asn1f_BS_remove_trailing_zero_bits(expr->value);
break;

View File

@ -135,6 +135,7 @@ asn1f_fix_constr_ext(arg_t *arg) {
case 3:
FATAL("Third extension marker "
"is not allowed at line %d", v->_lineno);
/* Fall through */
default:
r_value = -1;
}

View File

@ -1040,8 +1040,9 @@ asn1constraint_compute_constraint_range(
range->not_OER_visible = 1;
if(!ct
|| (range->not_OER_visible && (cpr_flags & CPR_strict_OER_visibility)))
|| (range->not_OER_visible && (cpr_flags & CPR_strict_OER_visibility))) {
return range;
}
switch(ct->type) {
case ACT_EL_VALUE:

View File

@ -125,10 +125,9 @@ _asn1f_parse_object_cb(const uint8_t *buf, size_t size, void *keyp) {
ret = _asn1f_parse_class_object_data(arg, eclass, row, eclass->with_syntax,
buf, buf + size, 0, 0, key->sequence);
if(ret) {
LOG((int)(ret < 0),
"Cannot parse %s of CLASS %s found at line %d",
expr->Identifier, eclass->Identifier, expr->_lineno);
asn1p_ioc_row_delete(row);
LOG(ret, "Cannot parse %s of CLASS %s found at line %d",
expr->Identifier, eclass->Identifier, expr->_lineno);
asn1p_ioc_row_delete(row);
return ret;
}

View File

@ -83,17 +83,23 @@ typedef struct arg_s {
* Merge the return value of the called function with the already
* partially computed return value of the current function.
*/
#define RET2RVAL(ret,rv) do { \
int __ret = ret; \
switch(__ret) { \
case 0: break; \
case 1: if(rv) break; \
case -1: rv = __ret; break; \
default: \
assert(__ret >= -1 && __ret <= 1); \
rv = -1; \
} \
} while(0)
#define RET2RVAL(ret, rv) \
do { \
int __ret = ret; \
switch(__ret) { \
case 0: \
break; \
case 1: \
if(rv) break; \
/* Fall through */ \
case -1: \
rv = __ret; \
break; \
default: \
assert(__ret >= -1 && __ret <= 1); \
rv = -1; \
} \
} while(0)
/*
* Temporary substitute module for the purposes of evaluating expression.

View File

@ -66,6 +66,7 @@ asn1p_value_compare(const asn1p_value_t *a, const asn1p_value_t *b) {
!= 0) {
return -1;
}
return 0;
case ATV_VALUESET:
return asn1p_constraint_compare(a->value.constraint,
b->value.constraint);

View File

@ -417,11 +417,11 @@ asn1print_constraint(const asn1p_constraint_t *ct, enum asn1print_flags flags) {
safe_printf("PATTERN ");
asn1print_value(ct->value, flags);
break;
case ACT_CA_SET: symno++;
case ACT_CA_CRC: symno++;
case ACT_CA_CSV: symno++;
case ACT_CA_UNI: symno++;
case ACT_CA_INT: symno++;
case ACT_CA_SET: symno++; /* Fall through */
case ACT_CA_CRC: symno++; /* Fall through */
case ACT_CA_CSV: symno++; /* Fall through */
case ACT_CA_UNI: symno++; /* Fall through */
case ACT_CA_INT: symno++; /* Fall through */
case ACT_CA_EXC:
{
char *symtable[] = { " EXCEPT ", " ^ ", " | ", ",",

View File

@ -497,21 +497,21 @@ INTEGER__xer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
/* FALL THROUGH */
case ST_DIGITS_TRAILSPACE:
/* The last symbol encountered was a digit. */
switch(asn_strtoimax_lim(dec_value_start, &dec_value_end, &dec_value)) {
case ASN_STRTOX_OK:
if(dec_value >= LONG_MIN && dec_value <= LONG_MAX) {
break;
} else {
/*
* We model INTEGER on long for XER,
* to avoid rewriting all the tests at once.
*/
ASN_DEBUG("INTEGER exceeds long range");
/* Fall through */
}
case ASN_STRTOX_ERROR_RANGE:
ASN_DEBUG("INTEGER decode %s hit range limit", td->name);
return XPBD_DECODER_LIMIT;
switch(asn_strtoimax_lim(dec_value_start, &dec_value_end, &dec_value)) {
case ASN_STRTOX_OK:
if(dec_value >= LONG_MIN && dec_value <= LONG_MAX) {
break;
} else {
/*
* We model INTEGER on long for XER,
* to avoid rewriting all the tests at once.
*/
ASN_DEBUG("INTEGER exceeds long range");
}
/* Fall through */
case ASN_STRTOX_ERROR_RANGE:
ASN_DEBUG("INTEGER decode %s hit range limit", td->name);
return XPBD_DECODER_LIMIT;
case ASN_STRTOX_ERROR_INVAL:
case ASN_STRTOX_EXPECT_MORE:
case ASN_STRTOX_EXTRA_DATA:

View File

@ -443,6 +443,7 @@ SEQUENCE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
phase3:
ctx->phase = 3;
/* Fall through */
case 3: /* 00 and other tags expected */
case 4: /* only 00's expected */

View File

@ -310,7 +310,7 @@ SET_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
ADVANCE(rval.consumed);
RETURN(RC_WMORE);
}
/* Fail through */
/* Fall through */
case RC_FAIL: /* Fatal error */
RETURN(RC_FAIL);
} /* switch(rval) */
@ -381,6 +381,7 @@ SET_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
}
ctx->phase = 5;
/* Fall through */
case 5:
/* Check that all mandatory elements are present. */
if(!_SET_is_populated(td, st))

View File

@ -320,13 +320,13 @@ check_ber_857_encoding(int base, int sign, int scaling_factor, int exponent, int
*b |= ((explen - 1) & 0x03); /* 8.5.7.4 */
b++;
switch(explen) {
case 2: *b++ = (int8_t)(exponent >> 8);
case 1: *b++ = (int8_t)exponent;
case 2: *b++ = (int8_t)(exponent >> 8); /* Fall through */
case 1: *b++ = (int8_t)exponent; /* Fall through */
}
switch(mantlen) {
case 3: *b++ = (mantissa >> 16) & 0xff;
case 2: *b++ = (mantissa >> 8) & 0xff;
case 1: *b++ = (mantissa & 0xff);
case 3: *b++ = (mantissa >> 16) & 0xff; /* Fall through */
case 2: *b++ = (mantissa >> 8) & 0xff; /* Fall through */
case 1: *b++ = (mantissa & 0xff); /* Fall through */
}
verify = (sign ? -1.0 : 1.0) * ldexp(mantissa, exponent * baseF + scaling_factor);