From ea2b959407a3adf1da7b675733f4968ea69a64eb Mon Sep 17 00:00:00 2001 From: James Ross-Gowan Date: Tue, 17 Jan 2017 20:36:57 +1100 Subject: Fix struct comparison in tests for Win64 On 64-bit Windows, sizeof(unsigned char *) is 8, sizeof(long) is 4 and alignof(ogg_int64_t) is 8. This results in a 4-byte hole in ogg_packet after "long e_o_s", which means ogg_packet structs cannot be reliably compared by memcmp. Compare ogg_packet structs member-by-member instead. This fixes `make check` for me on mingw-w64/GCC. Signed-off-by: Ralph Giles --- src/framing.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/framing.c b/src/framing.c index 6f63ab2..79fc715 100644 --- a/src/framing.c +++ b/src/framing.c @@ -1493,6 +1493,34 @@ const int head3_7[] = {0x4f,0x67,0x67,0x53,0,0x05, 1, 0}; +int compare_packet(const ogg_packet *op1, const ogg_packet *op2){ + if(op1->packet!=op2->packet){ + fprintf(stderr,"op1->packet != op2->packet\n"); + return(1); + } + if(op1->bytes!=op2->bytes){ + fprintf(stderr,"op1->bytes != op2->bytes\n"); + return(1); + } + if(op1->b_o_s!=op2->b_o_s){ + fprintf(stderr,"op1->b_o_s != op2->b_o_s\n"); + return(1); + } + if(op1->e_o_s!=op2->e_o_s){ + fprintf(stderr,"op1->e_o_s != op2->e_o_s\n"); + return(1); + } + if(op1->granulepos!=op2->granulepos){ + fprintf(stderr,"op1->granulepos != op2->granulepos\n"); + return(1); + } + if(op1->packetno!=op2->packetno){ + fprintf(stderr,"op1->packetno != op2->packetno\n"); + return(1); + } + return(0); +} + void test_pack(const int *pl, const int **headers, int byteskip, int pageskip, int packetskip){ unsigned char *data=_ogg_malloc(1024*1024); /* for scripted test cases only */ @@ -1601,7 +1629,7 @@ void test_pack(const int *pl, const int **headers, int byteskip, ogg_stream_packetout(&os_de,&op_de); /* just catching them all */ /* verify peek and out match */ - if(memcmp(&op_de,&op_de2,sizeof(op_de))){ + if(compare_packet(&op_de,&op_de2)){ fprintf(stderr,"packetout != packetpeek! pos=%ld\n", depacket); exit(1); -- cgit v1.2.1