Warning fixes from Christos Zoulas
- shadowed variables - signed/unsigned confusion - const lossage - incomplete structure initializations - unused code
This commit is contained in:
@@ -209,7 +209,8 @@ range_check(const char *name,
|
||||
|
||||
static int
|
||||
decode_type (const char *name, const Type *t, int optional,
|
||||
const char *forwstr, const char *tmpstr, const char *dertype)
|
||||
const char *forwstr, const char *tmpstr, const char *dertype,
|
||||
size_t depth)
|
||||
{
|
||||
switch (t->type) {
|
||||
case TType: {
|
||||
@@ -328,7 +329,8 @@ decode_type (const char *name, const Type *t, int optional,
|
||||
if (asprintf (&s, "%s(%s)->%s", m->optional ? "" : "&",
|
||||
name, m->gen_name) < 0 || s == NULL)
|
||||
errx(1, "malloc");
|
||||
decode_type (s, m->type, m->optional, forwstr, m->gen_name, NULL);
|
||||
decode_type (s, m->type, m->optional, forwstr, m->gen_name, NULL,
|
||||
depth + 1);
|
||||
free (s);
|
||||
}
|
||||
|
||||
@@ -369,7 +371,7 @@ decode_type (const char *name, const Type *t, int optional,
|
||||
"%s = calloc(1, sizeof(*%s));\n"
|
||||
"if (%s == NULL) { e = ENOMEM; %s; }\n",
|
||||
s, s, s, forwstr);
|
||||
decode_type (s, m->type, 0, forwstr, m->gen_name, NULL);
|
||||
decode_type (s, m->type, 0, forwstr, m->gen_name, NULL, depth + 1);
|
||||
free (s);
|
||||
|
||||
fprintf(codefile, "members |= (1 << %d);\n", memno);
|
||||
@@ -442,7 +444,7 @@ decode_type (const char *name, const Type *t, int optional,
|
||||
errx(1, "malloc");
|
||||
if (asprintf (&sname, "%s_s_of", tmpstr) < 0 || sname == NULL)
|
||||
errx(1, "malloc");
|
||||
decode_type (n, t->subtype, 0, forwstr, sname, NULL);
|
||||
decode_type (n, t->subtype, 0, forwstr, sname, NULL, depth + 1);
|
||||
fprintf (codefile,
|
||||
"(%s)->len++;\n"
|
||||
"len = %s_origlen - ret;\n"
|
||||
@@ -480,7 +482,7 @@ decode_type (const char *name, const Type *t, int optional,
|
||||
tmpstr, tmpstr, typestring);
|
||||
if(support_ber)
|
||||
fprintf(codefile,
|
||||
"int is_indefinite;\n");
|
||||
"int is_indefinite%zu;\n", depth);
|
||||
|
||||
fprintf(codefile, "e = der_match_tag_and_length(p, len, %s, &%s, %s, "
|
||||
"&%s_datalen, &l);\n",
|
||||
@@ -516,20 +518,20 @@ decode_type (const char *name, const Type *t, int optional,
|
||||
tmpstr);
|
||||
if(support_ber)
|
||||
fprintf (codefile,
|
||||
"if((is_indefinite = _heim_fix_dce(%s_datalen, &len)) < 0)\n"
|
||||
"if((is_indefinite%zu = _heim_fix_dce(%s_datalen, &len)) < 0)\n"
|
||||
"{ e = ASN1_BAD_FORMAT; %s; }\n"
|
||||
"if (is_indefinite) { if (len < 2) { e = ASN1_OVERRUN; %s; } len -= 2; }",
|
||||
tmpstr, forwstr, forwstr);
|
||||
"if (is_indefinite%zu) { if (len < 2) { e = ASN1_OVERRUN; %s; } len -= 2; }",
|
||||
depth, tmpstr, forwstr, depth, forwstr);
|
||||
else
|
||||
fprintf(codefile,
|
||||
"if (%s_datalen > len) { e = ASN1_OVERRUN; %s; }\n"
|
||||
"len = %s_datalen;\n", tmpstr, forwstr, tmpstr);
|
||||
if (asprintf (&tname, "%s_Tag", tmpstr) < 0 || tname == NULL)
|
||||
errx(1, "malloc");
|
||||
decode_type (name, t->subtype, 0, forwstr, tname, ide);
|
||||
decode_type (name, t->subtype, 0, forwstr, tname, ide, depth + 1);
|
||||
if(support_ber)
|
||||
fprintf(codefile,
|
||||
"if(is_indefinite){\n"
|
||||
"if(is_indefinite%zu){\n"
|
||||
"len += 2;\n"
|
||||
"e = der_match_tag_and_length(p, len, "
|
||||
"(Der_class)0, &%s, UT_EndOfContent, "
|
||||
@@ -538,6 +540,7 @@ decode_type (const char *name, const Type *t, int optional,
|
||||
"p += l; len -= l; ret += l;\n"
|
||||
"if (%s != (Der_type)0) { e = ASN1_BAD_ID; %s; }\n"
|
||||
"} else \n",
|
||||
depth,
|
||||
typestring,
|
||||
tmpstr,
|
||||
forwstr,
|
||||
@@ -584,7 +587,8 @@ decode_type (const char *name, const Type *t, int optional,
|
||||
if (asprintf (&s, "%s(%s)->u.%s", m->optional ? "" : "&",
|
||||
name, m->gen_name) < 0 || s == NULL)
|
||||
errx(1, "malloc");
|
||||
decode_type (s, m->type, m->optional, forwstr, m->gen_name, NULL);
|
||||
decode_type (s, m->type, m->optional, forwstr, m->gen_name, NULL,
|
||||
depth + 1);
|
||||
fprintf(codefile,
|
||||
"(%s)->element = %s;\n",
|
||||
name, m->label);
|
||||
@@ -702,7 +706,7 @@ generate_type_decode (const Symbol *s)
|
||||
fprintf (codefile, "\n");
|
||||
fprintf (codefile, "memset(data, 0, sizeof(*data));\n"); /* hack to avoid `unused variable' */
|
||||
|
||||
decode_type ("data", s->type, 0, "goto fail", "Top", NULL);
|
||||
decode_type ("data", s->type, 0, "goto fail", "Top", NULL, 1);
|
||||
if (preserve)
|
||||
fprintf (codefile,
|
||||
"data->_save.data = calloc(1, ret);\n"
|
||||
|
Reference in New Issue
Block a user