summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJames Ross-Gowan <rossymiles@gmail.com>2017-01-17 20:36:57 +1100
committerRalph Giles <giles@thaumas.net>2017-11-01 10:42:08 -0700
commitea2b959407a3adf1da7b675733f4968ea69a64eb (patch)
treeed0ff0c7204ce7503eb1e31db74c784c4149986f /src
parentdd85929dbe38be4b3876c9c0d6d5dcb7a128f388 (diff)
downloadogg-git-ea2b959407a3adf1da7b675733f4968ea69a64eb.tar.gz
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 <giles@thaumas.net>
Diffstat (limited to 'src')
-rw-r--r--src/framing.c30
1 files changed, 29 insertions, 1 deletions
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);