Commit Graph

16 Commits

Author SHA1 Message Date
Nicolas Williams
6a0f45c4d7 Use __attribute__ ((__name__)) form
Protect against macros named noreturn and so on.
2017-03-13 18:39:41 -04:00
Viktor Dukhovni
3d590d651f Reapply incorectly reverted gen_template bugfix
Without this, template memory allocation is incorrect for nested
sequences, which, as luck would have it, breaks tests on NetBSD
(whose malloc seems to give tighter allocations).

This partly undoes:

    commit 060474df16
    Author: Love Hornquist Astrand <lha@h5l.org>
    Date:   Mon Jun 3 21:45:51 2013 -0700

	quel 64bit warnings, fixup implicit encoding for template,
	fix spelling

Restoring changes from:

    commit 5e081aa4a6
    Author: Viktor Dukhovni <viktor@dukhovni.org>
    Date:   Sun May 27 08:07:28 2012 +0000

	Fix ASN.1 template compiler bug and add test cases more
	likely to trip on similar (structure size/type) errors

For example, without the bugfix, the sizeof(...) argument in multiple
generated nested structure templates is wrong, as seen in the bad vs.
good diff:

    --- test_template_asn1-template.c	2016-11-09 08:23:21.000000000 +0000
    +++ test_template_asn1-template.c	2016-11-09 08:23:40.000000000 +0000
    @@ -593,3 +593,3 @@
     const struct asn1_template asn1_TESTImplicit_tag_ti2_26[] = {
    -/* 0 */ { 0, sizeof(struct TESTImplicit), ((void *)1) },
    +/* 0 */ { 0, sizeof(struct TESTImplicit_ti2), ((void *)1) },
     /* 1 */ { A1_TAG_T(ASN1_C_CONTEXT,CONS,127), offsetof(struct TESTImplicit_ti2, foo), asn1_TESTLargeTag_tag_foo_4 }
    @@ -1618,3 +1618,3 @@
     const struct asn1_template asn1_TESTSeqOf2_tag_strings_68[] = {
    -/* 0 */ { 0, sizeof(struct TESTSeqOf2), ((void *)1) },
    +/* 0 */ { 0, sizeof(struct TESTSeqOf2_strings), ((void *)1) },
     /* 1 */ { A1_OP_SEQOF, 0, asn1_TESTSeqOfSeq2_val_tag_string_60 }
    @@ -1679,3 +1679,3 @@
     const struct asn1_template asn1_TESTSeqOf3_tag_strings_71[] = {
    -/* 0 */ { 0, sizeof(struct TESTSeqOf3), ((void *)1) },
    +/* 0 */ { 0, sizeof(struct TESTSeqOf3_strings), ((void *)1) },
     /* 1 */ { A1_OP_SEQOF, 0, asn1_TESTSeqOfSeq2_val_tag_string_60 }
    @@ -1760,3 +1760,3 @@
     const struct asn1_template asn1_TESTSeqOf4_tag_b1_75[] = {
    -/* 0 */ { 0, sizeof(struct TESTSeqOf4), ((void *)1) },
    +/* 0 */ { 0, sizeof(struct TESTSeqOf4_b1), ((void *)1) },
     /* 1 */ { A1_OP_SEQOF, 0, asn1_TESTSeqOf4_seofTstruct_10 }
    @@ -1765,3 +1765,3 @@
     const struct asn1_template asn1_TESTSeqOf4_tag_b1_74[] = {
    -/* 0 */ { 0, sizeof(struct TESTSeqOf4), ((void *)1) },
    +/* 0 */ { 0, sizeof(struct TESTSeqOf4_b1), ((void *)1) },
     /* 1 */ { A1_TAG_T(ASN1_C_UNIV,CONS,UT_Sequence), 0, asn1_TESTSeqOf4_tag_b1_75 }
    @@ -1801,3 +1801,3 @@
     const struct asn1_template asn1_TESTSeqOf4_tag_b2_79[] = {
    -/* 0 */ { 0, sizeof(struct TESTSeqOf4), ((void *)1) },
    +/* 0 */ { 0, sizeof(struct TESTSeqOf4_b2), ((void *)1) },
     /* 1 */ { A1_OP_SEQOF, 0, asn1_TESTSeqOf4_seofTstruct_11 }
    @@ -1842,3 +1842,3 @@
     const struct asn1_template asn1_TESTSeqOf4_tag_b3_84[] = {
    -/* 0 */ { 0, sizeof(struct TESTSeqOf4), ((void *)1) },
    +/* 0 */ { 0, sizeof(struct TESTSeqOf4_b3), ((void *)1) },
     /* 1 */ { A1_OP_SEQOF, 0, asn1_TESTSeqOf4_seofTstruct_12 }
2016-11-09 03:33:34 -05:00
Love Hornquist Astrand
060474df16 quel 64bit warnings, fixup implicit encoding for template, fix spelling 2013-06-03 21:46:20 -07:00
Stefan Metzmacher
d28613ce11 heimdal:lib/asn1: try to fix the build on IRIX
cc-1028 cc: ERROR File = ../source4/heimdal/lib/asn1/gen_template.c, Line = 548
  The expression used must have a constant value.

  struct templatehead template = { 0L, &(template). tqh_first };
                                         ^
If this really fixes the IRIX build, we'll propose this for heimdal upstream.

metze

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2012-06-11 11:05:37 +02:00
Roland C. Dowdeswell
abdde6a608 Additional changes to make -Wshadow build on Ubuntu 10.04.
Looks like they defined basename() in string.h and ntohs/htonl are
implemented in terms of __bswap16() which is a macro with tmp
variables and so one cannot embed one call to ntohs/htons in another.
Not good but we workaround this limitation in glibc.
2012-06-07 16:59:01 +01:00
Viktor Dukhovni
5e081aa4a6 Fix ASN.1 template compiler bug and add test cases more likely to trip on similar (structure size/type) errors
Signed-off-by: Roland C. Dowdeswell <elric@imrryr.org>
2012-06-05 22:05:35 +01:00
Roland C. Dowdeswell
e8779d5d4a Add -Wshadow and deal with the warnings. 2012-02-21 11:17:55 +00:00
Nicolas Williams
a222521e68 64-bit build fixes for ASN.1 compiler 64-bit integer support 2011-12-13 13:03:57 -06:00
Nicolas Williams
19d378f44d Add 64-bit integer support to ASN.1 compiler
ASN.1 INTEGERs will now compile to C int64_t or uint64_t, depending
    on whether the constraint ranges include numbers that cannot be
    represented in 32-bit ints and whether they include negative
    numbers.

    Template backend support included.  check-template is now built with
    --template, so we know we're testing it.

    Tests included.
2011-12-12 20:01:20 -06:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Jeffrey Altman
6850d6a65f avoid uninit variable and unreachable code warnings
most of these warnings are not problems because of ample
use of abort() calls.  However, the large number of warnings
makes it difficult to identify real problems.  Initialize
the variables to shut up the compilers.

Change-Id: I8477c11b17c7b6a7d9074c721fdd2d7303b186a8
2011-05-17 12:02:16 -04:00
Jeffrey Altman
36dcd37cc7 use %p printf format spec for pointers
do not cast to unsigned long since a 64-bit pointer
and 32-bit long will truncate the value.

Change-Id: Ibeda98171ccbab4b55950bb02c858773e1028cbf
2011-05-17 12:02:15 -04:00
Asanka C. Herath
59542f4298 Unreachable code to silence older compilers 2010-11-24 15:33:07 -05:00
Love Hornquist Astrand
33b8ccccd6 catch error from as.*printf 2010-05-30 15:13:44 -07:00
Love Hornquist Astrand
e65154c6db catch error from as.*printf 2010-05-30 14:48:48 -07:00
Love Hornquist Astrand
b939943b07 first stange of asn1 table driven compiler 2009-11-21 10:24:56 -08:00