Subject: Re: Bad config-win32.h in 1.7.0 and snapshots

Re: Bad config-win32.h in 1.7.0 and snapshots

From: László Tamás Szabó <laszlo.tamas.szabo_at_gmail.com>
Date: Tue, 22 Dec 2009 17:54:46 +0100

Thanks!

One more question though, did anyone test it under Win64?
When I tried to build for Win64 the compiler showed 7 warnings; all of
these seemed to be insignificant. The examples from the package work
fine, but I’m curious; is it safe to use under Win64?

I made a few tiny changes to the sources to get rid of the warning
messages and modified Makefile.msvc so in VC++ 2005 and later it doesn’t
warn for deprecated compiler options.

The patch file diff'ed against c-ares-1.7.1-20091222.tar.gz is attached
(I hope the mailing list won't remove it :)

Regards,
Laszlo Tamas Szabo

*** ares_expand_name.c Mon Jan 19 23:26:36 1970
--- ares_expand_name.c Mon Jan 19 23:26:36 1970
***************
*** 96,102 ****
          {
            if (!indir)
              {
! *enclen = p + 2 - encoded;
                indir = 1;
              }
            p = abuf + ((*p & ~INDIR_MASK) << 8 | *(p + 1));
--- 96,102 ----
          {
            if (!indir)
              {
! *enclen = (long)(p + 2 - encoded);
                indir = 1;
              }
            p = abuf + ((*p & ~INDIR_MASK) << 8 | *(p + 1));
***************
*** 116,122 ****
          }
      }
    if (!indir)
! *enclen = p + 1 - encoded;
  
    /* Nuke the trailing period if we wrote one. */
    if (q > *s)
--- 116,122 ----
          }
      }
    if (!indir)
! *enclen = (long)(p + 1 - encoded);
  
    /* Nuke the trailing period if we wrote one. */
    if (q > *s)
*** ares_init.c Mon Jan 19 23:26:36 1970
--- ares_init.c Mon Jan 19 23:26:36 1970
***************
*** 1027,1033 ****
--- 1027,1038 ----
      }
  
      do {
+ #ifndef _WIN64
        res = gethostname(hostname, len);
+ #else
+ /* hostname longer than 2^31 chars isn't possible */
+ res = gethostname(hostname, (int)len);
+ #endif
  
        if(toolong(res)) {
          char *p;
*** ares_process.c Mon Jan 19 23:26:36 1970
--- ares_process.c Mon Jan 19 23:26:36 1970
***************
*** 92,98 ****
                          int whichserver);
  static void next_server(ares_channel channel, struct query *query,
                          struct timeval *now);
! static int configure_socket(int s, ares_channel channel);
  static int open_tcp_socket(ares_channel channel, struct server_state *server);
  static int open_udp_socket(ares_channel channel, struct server_state *server);
  static int same_questions(const unsigned char *qbuf, int qlen,
--- 92,98 ----
                          int whichserver);
  static void next_server(ares_channel channel, struct query *query,
                          struct timeval *now);
! static int configure_socket(ares_socket_t s, ares_channel channel);
  static int open_tcp_socket(ares_channel channel, struct server_state *server);
  static int open_udp_socket(ares_channel channel, struct server_state *server);
  static int same_questions(const unsigned char *qbuf, int qlen,
***************
*** 856,862 ****
  #endif
  }
  
! static int configure_socket(int s, ares_channel channel)
  {
    setsocknonblock(s, TRUE);
  
--- 856,862 ----
  #endif
  }
  
! static int configure_socket(ares_socket_t s, ares_channel channel)
  {
    setsocknonblock(s, TRUE);
  
*** inet_net_pton.c Mon Jan 19 23:26:36 1970
--- inet_net_pton.c Mon Jan 19 23:26:36 1970
***************
*** 212,218 ****
        if (n++ != 0 && val == 0) /* no leading zeros */
          return (0);
        val *= 10;
! val += (pch - digits);
        if (val > 128) /* range */
          return (0);
        continue;
--- 212,218 ----
        if (n++ != 0 && val == 0) /* no leading zeros */
          return (0);
        val *= 10;
! val += (int)(pch - digits);
        if (val > 128) /* range */
          return (0);
        continue;
***************
*** 244,250 ****
        if (n++ != 0 && val == 0) /* no leading zeros */
          return (0);
        val *= 10;
! val += (pch - digits);
        if (val > 255) /* range */
          return (0);
        continue;
--- 244,250 ----
        if (n++ != 0 && val == 0) /* no leading zeros */
          return (0);
        val *= 10;
! val += (int)(pch - digits);
        if (val > 255) /* range */
          return (0);
        continue;
*** Makefile.msvc Mon Jan 19 23:26:36 1970
--- Makefile.msvc Mon Jan 19 23:26:36 1970
***************
*** 222,234 ****
  !UNDEF PDBTYPE_CONSOLIDATE
  !ENDIF
  
  # ----------------------------
  # Assorted commands and flags
  # ----------------------------
  
! CC_CMD_REL = cl.exe /nologo $(RTLIB) /DNDEBUG /O2
! CC_CMD_DBG = cl.exe /nologo $(RTLIBD) /D_DEBUG /Od /Zi /GZ
! CC_CFLAGS = $(CFLAGS) /I. /W3 /GX /FD
  
  RC_CMD_REL = rc.exe /l 0x409 /d "NDEBUG"
  RC_CMD_DBG = rc.exe /l 0x409 /d "_DEBUG"
--- 222,246 ----
  !UNDEF PDBTYPE_CONSOLIDATE
  !ENDIF
  
+ # -------------------------------------------------------
+ # Fix for deprecated compiler options in VC2005 and later
+ # -------------------------------------------------------
+
+ !IF $(CC_VERS_NUM) >= 80
+ CFLAGS_REL = /EHsc
+ CFLAGS_DBG = /EHsc /RTC1
+ !ELSE
+ CFLAGS_REL = /GX
+ CFLAGS_DBG = /GX /GZ
+ !ENDIF
+
  # ----------------------------
  # Assorted commands and flags
  # ----------------------------
  
! CC_CMD_REL = cl.exe /nologo $(RTLIB) /DNDEBUG /O2 $(CFLAGS_REL)
! CC_CMD_DBG = cl.exe /nologo $(RTLIBD) /D_DEBUG /Od /Zi $(CFLAGS_DBG)
! CC_CFLAGS = $(CFLAGS) /I. /W3 /FD
  
  RC_CMD_REL = rc.exe /l 0x409 /d "NDEBUG"
  RC_CMD_DBG = rc.exe /l 0x409 /d "_DEBUG"
Received on 2009-12-22