Ethereal-dev: [Ethereal-dev] Import of netxray-files broken

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: "Dr.-Ing. Gerrit Gehnen" <G.Gehnen@xxxxxxxx>
Date: Fri, 23 Mar 2001 12:53:58 +0100
Hello,

just a few days go we had a comment about differences in packaging of
structs in compilers. Now I found an good example:
Between 0.8.15 and 0.8.16 there was a change in wiretap\netxray.c
which replaced two guint32 vars with either an guint64, if available
or an struct of two guint32 vars. 
But the Microsoft C compiler fills structs to the next alignment border
so the resulting struct of two guint32's takes 8 Bytes, the default
value for MSC.
The result is naturally, that the import of netxray files under
Windows is broken.

Attached you find a patch for wiretap\netxray.c against the file
version 1.36 (doesn't interfere with the changes in 1.37)
which sets the alignment for the MSC-compiler.

Probably there are a lot of similar problems hidden in the code.
Maybe we should use the compiler directive /Zp for the MSC.

  Gerrit
*** netxray.c	Wed Feb 14 10:38:10 2001
--- netxray.c.new	Fri Mar 23 11:53:48 2001
***************
*** 83,88 ****
--- 83,93 ----
  	'0', '0', '2', '.', '0', '0', '2', '\0'
  };
  
+ #ifdef _MSC_VER
+ /* Visual C uses 8-byte alingment for structs included in structs as default */
+ #pragma pack (push,1)
+ #endif
+ 
  /* NetXRay 1.x data record format - followed by frame data. */
  struct netxrayrec_1_x_hdr {
  	netxray_ticks t;
***************
*** 98,103 ****
--- 103,113 ----
  	guint16	incl_len;	/* capture length */
  	guint32	xxx[7];		/* unknown */
  };
+ 
+ #ifdef _MSC_VER
+ /* Switch back to previous alignement */
+ #pragma pack (pop)
+ #endif
  
  static gboolean netxray_read(wtap *wth, int *err, int *data_offset);
  static void netxray_close(wtap *wth);