Skip to content
Snippets Groups Projects
Commit d9bd775a authored by Lev Walkin's avatar Lev Walkin
Browse files

enforsed compilation with -W -Werror

parent 70e70287
No related branches found
No related tags found
No related merge requests found
Showing
with 77 additions and 29 deletions
......@@ -32,6 +32,9 @@ int buf2_pos;
static int
buf2_fill(const void *buffer, size_t size, void *app_key) {
(void)app_key;
if(buf2_pos + size > sizeof(buf2))
return -1;
......@@ -42,7 +45,7 @@ buf2_fill(const void *buffer, size_t size, void *app_key) {
}
static void
check(int is_ok, uint8_t *buf, int size, int consumed) {
check(int is_ok, uint8_t *buf, int size, size_t consumed) {
T1_t t, *tp;
ber_dec_rval_t rval;
der_enc_rval_t erval;
......@@ -57,7 +60,7 @@ check(int is_ok, uint8_t *buf, int size, int consumed) {
if(is_ok) {
assert(rval.code == RC_OK);
assert(rval.consumed == consumed);
assert(rval.consumed == (size_t)consumed);
assert(t.a.size == 2);
assert(t.b.present == b_PR_n);
assert(t.b.choice.n.size == 1);
......@@ -73,7 +76,7 @@ check(int is_ok, uint8_t *buf, int size, int consumed) {
|| t.c.size != 1
);
}
assert(rval.consumed <= consumed);
assert(rval.consumed <= (size_t)consumed);
return;
}
......@@ -89,7 +92,7 @@ check(int is_ok, uint8_t *buf, int size, int consumed) {
printf("%d != %d\n", (int)erval.encoded, (int)sizeof(buf1));
}
assert(erval.encoded == sizeof(buf1));
for(i = 0; i < sizeof(buf1); i++) {
for(i = 0; i < (ssize_t)sizeof(buf1); i++) {
if(buf1[i] != buf2[i]) {
fprintf(stderr, "Recreated buffer content mismatch:\n");
fprintf(stderr, "Byte %d, %x != %x (%d != %d)\n",
......@@ -133,6 +136,9 @@ try_corrupt(uint8_t *buf, int size) {
int
main(int ac, char **av) {
(void)ac; /* Unused argument */
(void)av; /* Unused argument */
check(1, buf1, sizeof(buf1), sizeof(buf1));
try_corrupt(buf1, sizeof(buf1));
check(1, buf1, sizeof(buf1) + 10, sizeof(buf1));
......
......@@ -34,7 +34,7 @@ uint8_t buf1[] = {
};
static void
check(int is_ok, uint8_t *buf, int size, int consumed) {
check(int is_ok, uint8_t *buf, int size, size_t consumed) {
T_t t, *tp;
ber_dec_rval_t rval;
......@@ -87,6 +87,9 @@ try_corrupt(uint8_t *buf, int size) {
int
main(int ac, char **av) {
(void)ac; /* Unused argument */
(void)av; /* Unused argument */
check(1, buf1, sizeof(buf1), sizeof(buf1));
try_corrupt(buf1, sizeof(buf1));
......
......@@ -82,7 +82,7 @@ uint8_t buf1[] = {
};
static void
check(int is_ok, uint8_t *buf, int size, int consumed) {
check(int is_ok, uint8_t *buf, int size, size_t consumed) {
T_t t, *tp;
ber_dec_rval_t rval;
......@@ -164,10 +164,10 @@ try_corrupt(uint8_t *buf, int size, int allow_consume) {
}
static void
partial_read(uint8_t *buf, int size) {
partial_read(uint8_t *buf, size_t size) {
T_t t, *tp;
ber_dec_rval_t rval;
int i1, i2;
size_t i1, i2;
uint8_t *buf1 = alloca(size);
uint8_t *buf2 = alloca(size);
uint8_t *buf3 = alloca(size);
......@@ -183,11 +183,11 @@ partial_read(uint8_t *buf, int size) {
for(i1 = 0; i1 < size; i1++) {
for(i2 = i1; i2 < size; i2++) {
uint8_t *chunk1 = buf;
int size1 = i1;
size_t size1 = i1;
uint8_t *chunk2 = buf + size1;
int size2 = i2 - i1;
size_t size2 = i2 - i1;
uint8_t *chunk3 = buf + size1 + size2;
int size3 = size - size1 - size2;
size_t size3 = size - size1 - size2;
fprintf(stderr, "\n%d:{%d, %d, %d}...\n",
size, size1, size2, size3);
......@@ -239,6 +239,9 @@ partial_read(uint8_t *buf, int size) {
int
main(int ac, char **av) {
(void)ac; /* Unused argument */
(void)av; /* Unused argument */
/* Check that the full buffer may be decoded normally */
check(1, buf1, sizeof(buf1), sizeof(buf1) - 3);
......
......@@ -43,7 +43,7 @@ uint8_t buf2[] = {
};
static void
check(int is_ok, uint8_t *buf, int size, int consumed) {
check(int is_ok, uint8_t *buf, int size, size_t consumed) {
T_t t, *tp;
ber_dec_rval_t rval;
......@@ -103,6 +103,9 @@ try_corrupt(uint8_t *buf, int size) {
int
main(int ac, char **av) {
(void)ac; /* Unused argument */
(void)av; /* Unused argument */
fprintf(stderr, "Must succeed:\n");
check(1, buf1, sizeof(buf1) + 20, sizeof(buf1));
......
......@@ -92,7 +92,7 @@ int bytes_compare(const void *bufferp, size_t size, void *key) {
}
static void
check(int is_ok, uint8_t *buf, int size, int consumed) {
check(int is_ok, uint8_t *buf, int size, size_t consumed) {
Forest_t t, *tp;
ber_dec_rval_t rval;
......@@ -167,6 +167,9 @@ try_corrupt(uint8_t *buf, int size) {
int
main(int ac, char **av) {
(void)ac; /* Unused argument */
(void)av; /* Unused argument */
check(1, buf1, sizeof(buf1), sizeof(buf1));
try_corrupt(buf1, sizeof(buf1));
check(1, buf1, sizeof(buf1) + 20, sizeof(buf1));
......
......@@ -11,6 +11,9 @@ int
main(int ac, char **av) {
Programming_t p;
(void)ac; /* Unused argument */
(void)av; /* Unused argument */
memset(&p, 0, sizeof(p));
/*
......
......@@ -11,6 +11,9 @@ int
main(int ac, char **av) {
T_t t;
(void)ac; /* Unused argument */
(void)av; /* Unused argument */
memset(&t, 0, sizeof(t));
/*
......
......@@ -115,7 +115,7 @@ uint8_t buf2_reconstr[] = {
};
static void
check(T_t *tp, uint8_t *buf, int size, int consumed) {
check(T_t *tp, uint8_t *buf, int size, size_t consumed) {
ber_dec_rval_t rval;
tp = memset(tp, 0, sizeof(*tp));
......@@ -260,6 +260,9 @@ int
main(int ac, char **av) {
T_t t;
(void)ac; /* Unused argument */
(void)av; /* Unused argument */
check(&t, buf1, sizeof(buf1) + 10, sizeof(buf1));
compare(&t, buf1_reconstr, sizeof(buf1_reconstr));
asn_fprint(stderr, &asn1_DEF_T, &t);
......
......@@ -130,7 +130,7 @@ uint8_t buf2_reconstr[] = {
static void
check(T_t *tp, uint8_t *buf, int size, int consumed) {
check(T_t *tp, uint8_t *buf, int size, size_t consumed) {
ber_dec_rval_t rval;
tp = memset(tp, 0, sizeof(*tp));
......@@ -278,6 +278,9 @@ int
main(int ac, char **av) {
T_t t;
(void)ac; /* Unused argument */
(void)av; /* Unused argument */
/* Check exact buf0 */
check(&t, buf0, sizeof(buf0), sizeof(buf0));
compare(&t, buf0_reconstr, sizeof(buf0_reconstr));
......
......@@ -13,6 +13,9 @@ main(int ac, char **av) {
Test_structure_1_t ts1;
Sets_t s1;
(void)ac; /* Unused argument */
(void)av; /* Unused argument */
memset(&ts1, 0, sizeof(ts1));
memset(&s1, 0, sizeof(s1));
......
......@@ -94,6 +94,8 @@ asn1c_open_file(arg_t *arg, const char *name, const char *ext) {
FILE *fp;
int fd;
(void)arg; /* Unused argument */
/*
* Compute filenames.
*/
......
......@@ -208,6 +208,8 @@ static int
asn1c_copy_over(arg_t *arg, char *path) {
char *fname = basename(path);
(void)arg; /* Unused argument */
if(symlink(path, fname)) {
if(errno == EEXIST) {
struct stat sb1, sb2;
......
......@@ -65,9 +65,9 @@ asn1c_compile_expr(arg_t *arg) {
int (*type_cb)(arg_t *);
int ret;
assert(expr->meta_type >= AMT_INVALID);
assert((int)expr->meta_type >= AMT_INVALID);
assert(expr->meta_type < AMT_EXPR_META_MAX);
assert(expr->expr_type >= A1TC_INVALID);
assert((int)expr->expr_type >= A1TC_INVALID);
assert(expr->expr_type < ASN_EXPR_TYPE_MAX);
type_cb = asn1_lang_map[expr->meta_type][expr->expr_type].type_cb;
......
......@@ -30,6 +30,8 @@ asn1f_class_access(arg_t *arg, asn1p_ref_t *ref, asn1p_module_t **mod_r) {
asn1p_expr_t *result;
asn1p_ref_t tmpref;
(void)mod_r; /* Unused argument */
assert(ref->comp_count > 1);
DEBUG("%s(%s) for line %d", __func__,
......
......@@ -114,7 +114,7 @@ static int
_asn1f_make_sure_type_is(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_type_e type) {
asn1p_module_t *mod = NULL;
asn1p_expr_t *next_expr;
int expr_type;
asn1p_expr_type_e expr_type;
int ret;
expr_type = expr->expr_type;
......
......@@ -75,13 +75,13 @@ asn1f_printable_value(asn1p_value_t *v) {
}
case ATV_REAL:
ret = snprintf(buf, sizeof(buf), "%f", v->value.v_double);
if(ret >= sizeof(buf))
if(ret >= (ssize_t)sizeof(buf))
memcpy(buf + sizeof(buf) - 4, "...", 4);
return buf;
case ATV_INTEGER:
ret = snprintf(buf, sizeof(buf), "%lld",
(long long)v->value.v_integer);
if(ret >= sizeof(buf))
if(ret >= (ssize_t)sizeof(buf))
memcpy(buf + sizeof(buf) - 4, "...", 4);
return buf;
case ATV_MIN: return "MIN";
......@@ -126,7 +126,7 @@ asn1f_printable_value(asn1p_value_t *v) {
*ptr++ = ((uc >> (7-(i%8)))&1)?'1':'0';
}
} else {
char hextable[16] = "0123456789ABCDEF";
static const char *hextable="0123456789ABCDEF";
/*
* Dump byte by byte.
*/
......
......@@ -45,13 +45,13 @@ static char *asn1p_expr_type2str[] __attribute__ ((unused)) = {
/*
* Convert the ASN.1 expression type back into the string representation.
*/
#define ASN_EXPR_TYPE2STR(type) \
( \
((type) < 0 \
|| (type) >= sizeof(asn1p_expr_type2str) \
/ sizeof(asn1p_expr_type2str[0])) \
? (char *)0 \
: asn1p_expr_type2str[(type)] \
#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[(type)] \
)
#endif /* ASN1_PARSER_EXPR_STR_H */
......@@ -80,7 +80,8 @@ asn1p_ref_name2lextype(char *name) {
int
asn1p_ref_add_component(asn1p_ref_t *ref, char *name, enum asn1p_ref_lex_type_e lex_type) {
if(!ref || !name || lex_type < RLT_UNKNOWN || lex_type >= RLT_MAX) {
if(!ref || !name
|| (int)lex_type < RLT_UNKNOWN || lex_type >= RLT_MAX) {
errno = EINVAL;
return -1;
}
......
......@@ -84,6 +84,8 @@ asn1print_oid(asn1p_oid_t *oid, enum asn1print_flags_e flags) {
int ac;
int accum = 0;
(void)flags; /* Unused argument */
printf("{");
for(ac = 0; ac < oid->arcs_count; ac++) {
if(accum + strlen(oid->arcs[ac].name?:"") > 50) {
......@@ -111,6 +113,8 @@ static int
asn1print_ref(asn1p_ref_t *ref, enum asn1print_flags_e flags) {
int cc;
(void)flags; /* Unused argument */
for(cc = 0; cc < ref->comp_count; cc++) {
if(cc) printf(".");
printf("%s", ref->components[cc].name);
......@@ -123,6 +127,8 @@ static int
asn1print_tag(asn1p_expr_t *tc, enum asn1print_flags_e flags) {
struct asn1p_type_tag_s *tag = &tc->tag;
(void)flags; /* Unused argument */
if(tag->tag_class == TC_NOCLASS)
return 0;
......
......@@ -66,6 +66,8 @@ BIT_STRING_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
uint8_t *end;
char *p = scratch;
(void)td; /* Unused argument */
if(!st || !st->buf) return cb("<absent>", 8, app_key);
ilevel += 4;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment