[tcpdump-workers] [Patch] print-dhcp6.c

2013-03-26 Thread Gisle Vanem

This file doesn't compile using MSVC v16 (from VC-Express 2010)
because it has variable definitions after statements (' problem X' below). 
tcpdump should be in pure C, not C++ or gcc features. Right?


Patch:

--- Git-Latest\print-dhcp6.cThu Feb 28 16:10:44 2013
+++ print-dhcp6.c   Mon Mar 04 13:25:40 2013
@@ -335,6 +335,8 @@
   size_t optlen;
   u_int8_t auth_proto;
   u_int authinfolen, authrealmlen;
+   int remain_len;  /* Length of remaining options */
+   int label_len;   /* Label length */

   if (cp == ep)
   return;
@@ -723,10 +725,9 @@
   break;
   }
   tp = (u_char *)(dh6o + 1);
-   int remain_len = optlen;   !! problem 1
+   remain_len = optlen;
   printf( );
   /* Encoding is described in section 3.1 of RFC 1035 */
-   int label_len; /* Label length */   !! problem 2
   while (remain_len  *tp) {
   label_len =  *tp++;
   if (label_len  remain_len - 1) {

---

--gv
___
tcpdump-workers mailing list
tcpdump-workers@lists.tcpdump.org
https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers


Re: [tcpdump-workers] [Patch] print-dhcp6.c

2013-03-26 Thread Guy Harris

On Mar 26, 2013, at 6:08 AM, Gisle Vanem gva...@broadpark.no wrote:

 This file doesn't compile using MSVC v16 (from VC-Express 2010)
 because it has variable definitions after statements (' problem X' below). 
 tcpdump should be in pure C, not C++ or gcc features. Right?

Right.  (GCC features are OK if

1) they're protected with an #ifdef/#if

and

2) if the #ifdef/#if test fails, the resulting code works the same as 
if it succeeds.

See, for example, extract.h, which uses __attribute__() if the compiler 
supports it, but still works if the compiler doesn't support it.)

I've checked your fix into the trunk and the 4.4 branch.

___
tcpdump-workers mailing list
tcpdump-workers@lists.tcpdump.org
https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers