svn rev #22051: tools/gssmonger/trunk/ gssmaggot/ gssmaster/ include/

raeburn@MIT.EDU raeburn at MIT.EDU
Mon Feb 23 19:00:02 EST 2009


http://src.mit.edu/fisheye/changelog/krb5/?cs=22051
Commit By: raeburn
Log Message:
Various bits of cleanup related to message formatting, after bogus
formats caused another crash...

Tack on gcc format attributes where appropriate.  Fix up most warnings
resulting from using them and compiling with -Wformat; mostly this
means changing "%d" to "%lu" or "%ld", and "%x" to "%lx", in various
places.  As an exception, left the special cases of "%hc" and "%hs"
which have undefined behavior under ANSI/ISO C but have specific
meaning under Windows (and may or may not be needed in these cases, I
haven't investigated).  Unfortunately, gcc doesn't know what to make
of "%hs" so format checking is lost in these cases.

Define SOCKET_FORMAT in win.h and unix.h as an appropriate way to
print a socket identifier on each platform; use it.

Change WSAGetLastError definition in unix.h to produce an int, as the
Windows WSAGetLastError appears to do, intsead of DWORD.

Make some functions static.

Add some missing uses of va_end.



Changed Files:
U   tools/gssmonger/trunk/gssmaggot/extend.c
U   tools/gssmonger/trunk/gssmaggot/gssapi.c
U   tools/gssmonger/trunk/gssmaggot/handlers.c
U   tools/gssmonger/trunk/gssmaggot/logging.c
U   tools/gssmonger/trunk/gssmaggot/netrw.c
U   tools/gssmonger/trunk/gssmaggot/netutil.c
U   tools/gssmonger/trunk/gssmaggot/resource.c
U   tools/gssmonger/trunk/gssmaggot/util.c
U   tools/gssmonger/trunk/gssmaster/caseprv.c
U   tools/gssmonger/trunk/gssmaster/chgpass.c
U   tools/gssmonger/trunk/gssmaster/clientapis.c
U   tools/gssmonger/trunk/gssmaster/clientio.c
U   tools/gssmonger/trunk/gssmaster/combos.c
U   tools/gssmonger/trunk/gssmaster/context.c
U   tools/gssmonger/trunk/gssmaster/interfere.c
U   tools/gssmonger/trunk/gssmaster/main.c
U   tools/gssmonger/trunk/gssmaster/mangle.c
U   tools/gssmonger/trunk/gssmaster/misc.c
U   tools/gssmonger/trunk/include/everything.h
U   tools/gssmonger/trunk/include/ezdef.h
U   tools/gssmonger/trunk/include/ezlog.h
U   tools/gssmonger/trunk/include/server.h
U   tools/gssmonger/trunk/include/unix.h
U   tools/gssmonger/trunk/include/win.h
Modified: tools/gssmonger/trunk/gssmaggot/extend.c
===================================================================
--- tools/gssmonger/trunk/gssmaggot/extend.c	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/gssmaggot/extend.c	2009-02-24 00:00:02 UTC (rev 22051)
@@ -417,7 +417,7 @@
       } else {
 
         GsmDebug( DBG_TRACE,
-                  "\"%s\" not found among the %d extensions.\n",
+                  "\"%s\" not found among the %lu extensions.\n",
                   SearchKey.ExtensionName,
                   g_cExtensions );
 

Modified: tools/gssmonger/trunk/gssmaggot/gssapi.c
===================================================================
--- tools/gssmonger/trunk/gssmaggot/gssapi.c	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/gssmaggot/gssapi.c	2009-02-24 00:00:02 UTC (rev 22051)
@@ -521,8 +521,8 @@
           
           ServerLogMessage( pArgs,
                             FILE_AND_LINE,
-                            "gss_init_sec_context used credId %ld.\n",
-                            *phCreds );
+                            "gss_init_sec_context used credId %lu.\n",
+                            (unsigned long) *phCreds );
         
         }
 
@@ -534,7 +534,7 @@
 
         ServerLogMessage( pArgs,
                           FILE_AND_LINE,
-                          "gss_init_sec_context using flags 0x%x"
+                          "gss_init_sec_context using flags 0x%lx"
                           " and targetname %s at %s",
                           ApiFlags,
                           TargetName,
@@ -555,7 +555,7 @@
 
       ServerLogMessage( pArgs,
                         FILE_AND_LINE,
-                        "%s returning GSM 0x%x.  Dumping tickets:",
+                        "%s returning GSM 0x%lx.  Dumping tickets:",
                         ApiName,
                         ReturnVal );
 
@@ -685,7 +685,7 @@
 
           ServerLogMessage( pArgs,
                             FILE_AND_LINE,
-                            "Couldn't duplicate credHandle: 0x%x.",
+                            "Couldn't duplicate credHandle: 0x%lx.",
                             ReturnVal );
 
           DeleteCredentialResource( &hDelegCred );

Modified: tools/gssmonger/trunk/gssmaggot/handlers.c
===================================================================
--- tools/gssmonger/trunk/gssmaggot/handlers.c	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/gssmaggot/handlers.c	2009-02-24 00:00:02 UTC (rev 22051)
@@ -302,7 +302,7 @@
     if ( ret ) {
 
       GsmDebug( DBG_TRACE,
-                "Toasting resource %ld (0x%x)...\n",
+                "Toasting resource %ld (0x%lx)...\n",
                 ResourceId,
                 ResourceId );
 
@@ -365,9 +365,14 @@
 
       } else {
 
+#if 0 /* XXX Looks to me like *phContext will be a structure on
+	 Windows?  With GSSAPI, it'll be gss_ctx_id_t, which will be
+	 some pointer or arithmetic type.  No good consistent way we
+	 should print it.  */
         GsmDebug( DBG_TRACE,
                   "Not deleting noncontext contextid 0x%x.\n",
                   *phContext );
+#endif
 
       }
 
@@ -629,7 +634,7 @@
     ServerLogMessage( pArgs,
                       file,
                       line,
-                      "%s returned 0x%x (0x%x)"
+                      "%s returned 0x%lx (0x%lx)"
 #if USE_GSSAPI
                       ": %s [minor:%s]"
 #endif
@@ -654,7 +659,7 @@
 #endif
 
     GsmDebug( DBG_TRACE,
-              "mapped to GSM return code %ld (0x%x).\n",
+              "mapped to GSM return code %ld (0x%lx).\n",
               ret,
               ret );
 
@@ -711,7 +716,7 @@
 
         ServerLogMessage( pArgs,
                           FILE_AND_LINE,
-                          "Can't decypher Credential Resource %ld (0x%x).",
+                          "Can't decypher Credential Resource %ld (0x%lx).",
                           CredId,
                           CredId );
 

Modified: tools/gssmonger/trunk/gssmaggot/logging.c
===================================================================
--- tools/gssmonger/trunk/gssmaggot/logging.c	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/gssmaggot/logging.c	2009-02-24 00:00:02 UTC (rev 22051)
@@ -94,8 +94,17 @@
   
  **************************************************************--*/
 
+static BOOL
+ExpandArgsToBuffer( IN  long    BufferSizeHint,
+                    IN  LPSTR   fmt,
+                    IN  va_list InVa,
+                    OUT LPSTR  *ppBuffer )
+#if defined __GNUC__ && __GNUC__ >= 3
+    __attribute__((format(printf,2,0)))
+#endif
+    ;
 
-BOOL
+static BOOL
 ExpandArgsToBuffer( IN  long    BufferSizeHint,
                     IN  LPSTR   fmt,
                     IN  va_list InVa,
@@ -140,7 +149,7 @@
 
     GssMongerError( FILE_AND_LINE,
                     "** Can't expand message \"%s\"."
-                    "  Stopping at size=%d",
+                    "  Stopping at size=%lu",
                     fmt,
                     SizeAttempt );
 
@@ -177,8 +186,19 @@
   
  **************************************************************--*/
 
+static BOOL
+ServerSendLogEntry( IN PPROTOCOL_CALLBACK_ARGS pArgs,
+                    IN ULONG                   LogLevel,
+                    IN LPSTR                   file,
+                    IN ULONG                   line,
+                    IN LPSTR                   fmt,
+                    IN va_list                 va )
+#if defined __GNUC__ && __GNUC__ >= 3
+    __attribute__((format(printf,5,0)))
+#endif
+    ;
 
-BOOL
+static BOOL
 ServerSendLogEntry( IN PPROTOCOL_CALLBACK_ARGS pArgs,
                     IN ULONG                   LogLevel,
                     IN LPSTR                   file,
@@ -336,14 +356,17 @@
                   ... ) {
 
     va_list va;
+    BOOL result;
     
     va_start( va, fmt );
 
-    return ServerSendLogEntry( pArgs,
-                               eLogInfo,
-                               file, line,
-                               fmt,
-                               va );
+    result = ServerSendLogEntry( pArgs,
+				 eLogInfo,
+				 file, line,
+				 fmt,
+				 va );
+    va_end( va );
+    return result;
 }
 /*++**************************************************************
   NAME:      ServerLogFailure
@@ -400,13 +423,16 @@
                   ... ) {
 
     va_list va;
+    BOOL result;
     
     va_start( va, fmt );
 
-    return ServerSendLogEntry( pArgs,
-                               eLogFailure,
-                               file, line,
-                               fmt,
-                               va );
+    result = ServerSendLogEntry( pArgs,
+				 eLogFailure,
+				 file, line,
+				 fmt,
+				 va );
+    va_end( va );
+    return result;
 }
  

Modified: tools/gssmonger/trunk/gssmaggot/netrw.c
===================================================================
--- tools/gssmonger/trunk/gssmaggot/netrw.c	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/gssmaggot/netrw.c	2009-02-24 00:00:02 UTC (rev 22051)
@@ -429,11 +429,11 @@
       NetioErrorMessage( NETIO_FILE_AND_LINE,
                          GETLASTERROR,
                          "send",
-                         "returned 0x%x on socket 0x%p: 0x%x",
+                         "returned 0x%x on socket " SOCKET_FORMAT ": 0x%x",
                          ret,
                          Sock,
                          GETLASTERROR );
-        
+
       return FALSE;
     }
 
@@ -442,8 +442,8 @@
       NetioErrorMessage( NETIO_FILE_AND_LINE,
                          GETLASTERROR,
                          "send",
-                         "wrote %ld bytes, != "
-                         "the byte count provided (%d)",
+                         "wrote %d bytes, != "
+                         "the byte count provided (%lu)",
                          ret,
                          szData );
 
@@ -566,7 +566,7 @@
         NetioErrorMessage( NETIO_FILE_AND_LINE,
                            GETLASTERROR,
                            "recv",
-                           "returned weird error on socket 0x%p",
+                           "returned weird error on socket " SOCKET_FORMAT,
                            Sock );
 
       }

Modified: tools/gssmonger/trunk/gssmaggot/netutil.c
===================================================================
--- tools/gssmonger/trunk/gssmaggot/netutil.c	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/gssmaggot/netutil.c	2009-02-24 00:00:02 UTC (rev 22051)
@@ -79,12 +79,22 @@
 
 #define NETIO_FILE_AND_LINE FILE_AND_LINE
 
-VOID
+static VOID
 NetioErrorMessage( IN PCHAR File,
                    IN INT   Line,
                    IN DWORD dwErr,
                    IN PCHAR Source,
                    IN PCHAR Fmt,
+                   ... )
+    PRINTFLIKE(5,6)
+    ;
+
+static VOID
+NetioErrorMessage( IN PCHAR File,
+                   IN INT   Line,
+                   IN DWORD dwErr,
+                   IN PCHAR Source,
+                   IN PCHAR Fmt,
                    ... ) {
     CHAR Buffer[ 100 ] = { 0 }; /* arbitrary */
     va_list va;
@@ -194,7 +204,7 @@
 
     ULONG i;
 
-    printf( "NetReadInteger: (size: %d)\n", pEntry->ulSize );
+    printf( "NetReadInteger: (size: %lu)\n", pEntry->ulSize );
 
     if ( !NetReadExactly( sock,
                           pEntry->pvData,
@@ -266,7 +276,7 @@
           ret && ( i < cEntries );
           i ++ ) {
 
-      printf ( "NetReadArgArray: waiting for entry %ld of %ld (%hs) on %ld...\n", i, cEntries, pEntries[i].Name, sock );
+      printf ( "NetReadArgArray: waiting for entry %ld of %ld (%hs) on %ld...\n", i, cEntries, pEntries[i].Name, (long) sock );
       GsmDebug( DBG_NETIO,
                 "NetReadArgArray: waiting for entry %ld (%hs)...\n",
                 i,
@@ -417,7 +427,7 @@
 #endif
 
            GssMongerError( FILE_AND_LINE,
-                           "Entry %ld (%hs) has unknown type flags 0x%x",
+                           "Entry %ld (%hs) has unknown type flags 0x%lx",
                            i,
                            pEntries[ i ].Name,
                            pEntries[ i ].flags );
@@ -605,7 +615,7 @@
 #endif
 
          GssMongerError( FILE_AND_LINE,
-                         "Entry %ld (%hs) has unknown type flags 0x%x",
+                         "Entry %ld (%hs) has unknown type flags 0x%lx",
                          i,
                          pEntries[ i ].Name,
                          pEntries[ i ].flags );
@@ -781,7 +791,7 @@
               strcpy(addrname, "<unknown>");
           }
           GssMongerError( FILE_AND_LINE,
-                          "Cannot connect to %s on port %ld: 0x%x\n",
+                          "Cannot connect to %s on port %d: 0x%x\n",
                           addrname,
                           HostPort,
                           GETLASTERROR );

Modified: tools/gssmonger/trunk/gssmaggot/resource.c
===================================================================
--- tools/gssmonger/trunk/gssmaggot/resource.c	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/gssmaggot/resource.c	2009-02-24 00:00:02 UTC (rev 22051)
@@ -118,7 +118,7 @@
 
     GsmDebug( DBG_RESOURCES,
               "** Current resource dump:\n"
-              "   MaxResourceId: %ld (0x%x)\n"
+              "   MaxResourceId: %ld (0x%lx)\n"
               "   Dead Resource Count: %ld\n"
               "   Live Resource Count: %ld\n"
               "   Resource Vector Size: %ld\n",
@@ -141,7 +141,7 @@
       if ( pResourceTable->pResources[ i ].bLive ) {
 
         GsmDebug( DBG_RESOURCES,
-                  "LIVE id %ld 0x%p allocated by %hs:%ld\n",
+                  "LIVE id %ld 0x%p allocated by %hs:%d\n",
                   pResourceTable->pResources[ i ].Id,
                   pResourceTable->pResources[ i ].pvData,
                   pResourceTable->pResources[ i ].file,
@@ -237,7 +237,7 @@
     Key.Id = ResourceId;
 
     GsmDebug( DBG_RESOURCES,  
-              "Looking for resource id %ld (0x%x)...\n",
+              "Looking for resource id %ld (0x%lx)...\n",
               ResourceId,
               ResourceId );
 
@@ -272,7 +272,7 @@
       pRes = NULL;
 
       GssMongerError( FILE_AND_LINE,
-                      "No resource with ID %ld (0x%x).",
+                      "No resource with ID %ld (0x%lx).",
                       ResourceId,
                       ResourceId );
     }
@@ -389,7 +389,7 @@
       *pulResourceId = pResource->Id;
 
       GsmDebug( DBG_RESOURCES,  
-                "** Mapped resId %ld (0x%x) to resource at 0x%p.\n",
+                "** Mapped resId %ld (0x%lx) to resource at 0x%p.\n",
                 *pulResourceId,
                 *pulResourceId,
                 pResource->pvData );
@@ -441,7 +441,7 @@
       *ppvData = p->pvData;
 
       GsmDebug( DBG_RESOURCES,  
-                "** Found resId %ld (0x%x) with data at 0x%p.\n",
+                "** Found resId %ld (0x%lx) with data at 0x%p.\n",
                 id,
                 id,
                 p->pvData );

Modified: tools/gssmonger/trunk/gssmaggot/util.c
===================================================================
--- tools/gssmonger/trunk/gssmaggot/util.c	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/gssmaggot/util.c	2009-02-24 00:00:02 UTC (rev 22051)
@@ -275,9 +275,8 @@
         vfprintf( stdout,
                   fmt,
                   v );
-
       }
-
+      va_end(fmt);
     }
 }
 
@@ -348,6 +347,8 @@
     fprintf( fError,
              "\n" );
 
+    va_end (va);
+
 #endif
 
 }
@@ -437,9 +438,9 @@
 
       GssMongerError( file,
                       line,
-                      "Unable to realloc 0x%p to %d bytes.",
+                      "Unable to realloc 0x%p to %lu bytes.",
                       *ppvData,
-                      HowMuch );
+                      (unsigned long) HowMuch );
       return FALSE;
     }
 

Modified: tools/gssmonger/trunk/gssmaster/caseprv.c
===================================================================
--- tools/gssmonger/trunk/gssmaster/caseprv.c	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/gssmaster/caseprv.c	2009-02-24 00:00:02 UTC (rev 22051)
@@ -802,7 +802,7 @@
     srand( Seed );
     ezLogMsgA( EZLOG_INFO,
                EZ_DEFAULT,
-               "Using seed: %d.",
+               "Using seed: %lu.",
                Seed );
 
     ezStartBlockA( NULL,
@@ -845,7 +845,7 @@
         // iterate over cases
 
 
-        printf("iServer %i\n", iServer);
+        printf("iServer %lu\n", iServer);
 
         IterateOverCases( pArgs,
                           iClient,

Modified: tools/gssmonger/trunk/gssmaster/chgpass.c
===================================================================
--- tools/gssmonger/trunk/gssmaster/chgpass.c	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/gssmaster/chgpass.c	2009-02-24 00:00:02 UTC (rev 22051)
@@ -188,7 +188,7 @@
 
         ezLogMsgA( EZLOG_SEV2,
                    EZ_DEFAULT,
-                   "Unable to change password from \"%hs\" to \"%hs\": 0x%x",
+                   "Unable to change password from \"%hs\" to \"%hs\": 0x%lx",
                    pPrinc->Password,
                    NewPassword,
                    gsmErr );
@@ -211,7 +211,7 @@
           ezLogMsgA( EZLOG_SEV2,
                      EZ_DEFAULT,
                      "Can't change password from \"%hs\" back to \"%hs\":"
-                     " 0x%x.  Password is now \"%hs\".",
+                     " 0x%lx.  Password is now \"%hs\".",
 
                      NewPassword,
                      pPrinc->Password,

Modified: tools/gssmonger/trunk/gssmaster/clientapis.c
===================================================================
--- tools/gssmonger/trunk/gssmaster/clientapis.c	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/gssmaster/clientapis.c	2009-02-24 00:00:02 UTC (rev 22051)
@@ -166,7 +166,7 @@
     }
 
     GsmDebug( DBG_TRACE,
-              "Destroying resource ID %ld (0x%x)...\n",
+              "Destroying resource ID %ld (0x%lx)...\n",
               ulResId,
               ulResId );
 
@@ -1367,9 +1367,9 @@
 
       ezLogMsgA( EZLOG_WARN,
                  EZ_DEFAULT,
-                 "Failed to listen on socket %x: 0x%x",
+                 "Failed to listen on socket " SOCKET_FORMAT ": 0x%x",
                  hThread->ListeningSocket,
-                 WSAGetLastError() );
+                 (unsigned int) WSAGetLastError() );
 
       dwErr = WSAGetLastError();
 
@@ -1458,7 +1458,7 @@
 
         ezLogMsgA( EZLOG_WARN,
                    EZ_DEFAULT,
-                   "select() returned 0x%x while checking sockets.",
+                   "select() returned 0x%lx while checking sockets.",
                    dwErr = WSAGetLastError() );
 
         break;
@@ -1604,7 +1604,7 @@
 
            ezLogMsgA( EZLOG_BLOCK,
                       EZ_DEFAULT,
-                      "Unknown loglevel 0x%x received.  Logging as WARN.",
+                      "Unknown loglevel 0x%lx received.  Logging as WARN.",
                       LogLevel );
 
            HandleIncomingMessage( hThread, i, &AckId,
@@ -1659,7 +1659,7 @@
     } while ( dwErr == ERROR_SUCCESS );
 
     GsmDebug( DBG_TRACE,
-              "Server logthread going down: 0x%x\n",
+              "Server logthread going down: 0x%lx\n",
               dwErr );
 
     closesocket( hThread->ListeningSocket );
@@ -1706,7 +1706,7 @@
         ezLogMsgA( EZLOG_WARN,
                    EZ_DEFAULT,
                    "Failed to get address info: %#x",
-                   WSAGetLastError() );
+                   (unsigned int) WSAGetLastError() );
       }
       else {
         for (AI = AddrInfo; AI; AI = AI->ai_next) {
@@ -1723,7 +1723,7 @@
                          EZ_DEFAULT,
                          "Failed to bind socket to port %d: 0x%x",
                          ntohs (SS_PORT(AI)),
-                         WSAGetLastError() );
+                         (unsigned int) WSAGetLastError() );
 
             } else if ( SOCKET_ERROR == 
                         getsockname( hThread->ListeningSocket,
@@ -2033,7 +2033,7 @@
         
           ezLogMsgA( EZLOG_WARN,
                      EZ_DEFAULT,
-                     "%hs:%d returned error 0x%x"
+                     "%hs:%d returned error 0x%lx"
                      " from our attempt to connect to its logging service.",
                      hServer->HostName,
                      hServer->HostPort,
@@ -2047,7 +2047,7 @@
 
           ezLogMsgA( EZLOG_BLOCK,
                      EZ_DEFAULT,
-                     "%hs:%d is using logging protocol 0x%x"
+                     "%hs:%d is using logging protocol 0x%lx"
                      " and will not sync down to our protocol (0x%x)."
                      "  The protocols are probably incompatible."
                      "  Please upgrade me and try again.",

Modified: tools/gssmonger/trunk/gssmaster/clientio.c
===================================================================
--- tools/gssmonger/trunk/gssmaster/clientio.c	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/gssmaster/clientio.c	2009-02-24 00:00:02 UTC (rev 22051)
@@ -321,20 +321,20 @@
 
     ulMsgId = htonl( MessageId );
 
-    printf( "ClientSendReceiveData: (%s) %d %d [%d]\n", MessageName, cInputParams, cOutputParams, sizeof( ulMsgId ) );
+    printf( "ClientSendReceiveData: (%s) %lu %lu [%lu]\n", MessageName, cInputParams, cOutputParams, (unsigned long) sizeof( ulMsgId ) );
 
 
     GsmDebug( DBG_NETIO,
-              "Sending htonl(%ld) of size %ld...\n",
+              "Sending htonl(%d) of size %lu...\n",
               MessageId,
-              sizeof( ulMsgId ) );
+              (unsigned long) sizeof( ulMsgId ) );
 
     if ( !NetWrite( pConn->sock,
                     &ulMsgId,
                     sizeof( ulMsgId ) ) ) {
 
       GssMongerError( FILE_AND_LINE,
-                      "Can't send MessageId for %ld (%hs): 0x%x",
+                      "Can't send MessageId for %u (%hs): 0x%x",
                       MessageId,
                       MessageName,
                       GETLASTERROR );

Modified: tools/gssmonger/trunk/gssmaster/combos.c
===================================================================
--- tools/gssmonger/trunk/gssmaster/combos.c	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/gssmaster/combos.c	2009-02-24 00:00:02 UTC (rev 22051)
@@ -178,9 +178,19 @@
   
 };
 
-VOID
+static VOID
 AppendAndUpdateStatusLine( IN PTESTARGS pArgs,
                            IN LPSTR     fmt,
+                           IN ... )
+#if defined __GNUC__ && __GNUC__ >= 3
+    __attribute__((format(printf,2,3)))
+#endif
+    ;
+
+
+static VOID
+AppendAndUpdateStatusLine( IN PTESTARGS pArgs,
+                           IN LPSTR     fmt,
                            IN ... ) {
 
     LPSTR Cursor = StatusLinePrefix;

Modified: tools/gssmonger/trunk/gssmaster/context.c
===================================================================
--- tools/gssmonger/trunk/gssmaster/context.c	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/gssmaster/context.c	2009-02-24 00:00:02 UTC (rev 22051)
@@ -222,7 +222,7 @@
 
         ezLogMsgA( EZLOG_WARN,
                    EZ_DEFAULT,
-                   "Init failed (GSM 0x%x).",
+                   "Init failed (GSM 0x%lx).",
                    GsmErr );
 
       }
@@ -264,7 +264,7 @@
 
           ezLogMsgA( EZLOG_WARN,
                      EZ_DEFAULT,
-                     "Accept failed (GSM=0x%x).",
+                     "Accept failed (GSM=0x%lx).",
                      GsmErr );
 
         }

Modified: tools/gssmonger/trunk/gssmaster/interfere.c
===================================================================
--- tools/gssmonger/trunk/gssmaster/interfere.c	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/gssmaster/interfere.c	2009-02-24 00:00:02 UTC (rev 22051)
@@ -469,8 +469,8 @@
 
           ezLogMsgA( EZLOG_SEV2,
                      EZ_DEFAULT,
-                     "Message decoded different size (%d)"
-                     " than original (%d)",
+                     "Message decoded different size (%ld)"
+                     " than original (%ld)",
                      pData[ iDecode ].cbPlain,
                      pData[ iDecode ].OriginalMessage->cbMessage );
 
@@ -601,7 +601,7 @@
 
         if ( ret ) { 
           GsmDebug( DBG_TRACE,
-                    "%hs inhaled: %d bytes.\n",
+                    "%hs inhaled: %lu bytes.\n",
                     FileName,
                     g_pTestMessages[ g_cTestMessages ].cbMessage );
           g_cTestMessages++;

Modified: tools/gssmonger/trunk/gssmaster/main.c
===================================================================
--- tools/gssmonger/trunk/gssmaster/main.c	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/gssmaster/main.c	2009-02-24 00:00:02 UTC (rev 22051)
@@ -260,7 +260,7 @@
     if ( dwConsoleEvent ) {
       ezLogMsgA( EZLOG_INFO,
                  EZ_DEFAULT,
-                 "Received console event 0x%x.  Terminating.",
+                 "Received console event 0x%lx.  Terminating.",
                  dwConsoleEvent );
 
     }

Modified: tools/gssmonger/trunk/gssmaster/mangle.c
===================================================================
--- tools/gssmonger/trunk/gssmaster/mangle.c	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/gssmaster/mangle.c	2009-02-24 00:00:02 UTC (rev 22051)
@@ -215,7 +215,7 @@
         if ( !GSM_SUCCESS( ret ) ) break;
 
         fprintf( fp,
-                 "; +%04d: ",
+                 "; +%04ld: ",
                  iRowStart );
 
         ret = WriteTokenDataLine( fp, 
@@ -447,7 +447,7 @@
 
             ezLogMsgA( EZLOG_BLOCK,
                        EZ_DEFAULT,
-                       "Error reading char %d (after '%hc') from %hs:"
+                       "Error reading char %ld (after '%hc') from %hs:"
                        " '%hc' (0x%02x) is not a hex digit.",
                        iFile,
                        FileName,
@@ -467,13 +467,13 @@
 
           ezLogMsgA( EZLOG_BLOCK,
                      EZ_DEFAULT,
-                     "Error reading char %d from %hs:"
+                     "Error reading char %lu from %hs:"
                      " '%hc' (0x%02x) needs to be a hex digit,"
                      " whitespace or a comment.",
                      iFile,
                      FileName,
                      ch[0],
-                     ch[0] );
+                     (unsigned int) ch[0] );
 
           ret = GSMERR_TEST_ISSUE;
           break;

Modified: tools/gssmonger/trunk/gssmaster/misc.c
===================================================================
--- tools/gssmonger/trunk/gssmaster/misc.c	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/gssmaster/misc.c	2009-02-24 00:00:02 UTC (rev 22051)
@@ -135,7 +135,7 @@
 
       ezLogMsgA( EZLOG_BLOCK,
                  EZ_DEFAULT,
-                 "Can't allocate %d chars for moniker",
+                 "Can't allocate %lu chars for moniker",
                  cchString );
     }
 
@@ -248,7 +248,7 @@
 
           ezLogMsgA( EZLOG_INFO,
                      EZ_DEFAULT,
-                     "%hs:%d is v%ld, caps 0x%x: %hs\n",
+                     "%hs:%d is v%ld, caps 0x%lx: %hs\n",
                      SlaveName,
                      Port,
                      pSlaves[ cSlaves ].VersionInfo,
@@ -285,7 +285,7 @@
 
             ezLogMsgA( EZLOG_WARN,
                        EZ_DEFAULT,
-                       "%hs:%d is using protocol %d"
+                       "%hs:%d is using protocol %lu"
                        " (our version is %d)."
                        "  This may cause problems.",
                        SlaveName,
@@ -822,7 +822,7 @@
 
       ezLogMsgA( LogLevel,
                  EZ_DEFAULT,
-                 "%hs did not produce a token (%d-length).",
+                 "%hs did not produce a token (%lu-length).",
                  ApiName,
                  cbToken );
 

Modified: tools/gssmonger/trunk/include/everything.h
===================================================================
--- tools/gssmonger/trunk/include/everything.h	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/include/everything.h	2009-02-24 00:00:02 UTC (rev 22051)
@@ -78,6 +78,12 @@
 
 #define FILE_AND_LINE __FILE__, __LINE__
 
+#if defined __GNUC__ && !defined __cplusplus && __GNUC__ >= 3
+#define PRINTFLIKE(FMT,ARG) __attribute__((format(printf,FMT,ARG)))
+#else
+#define PRINTFLIKE(FMT,ARG)
+#endif
+
 typedef SOCKET *PSOCKET;
 
 extern ULONG DefaultTimeOut; /* in netutil.c */
@@ -89,7 +95,9 @@
 GssMongerError( IN LPSTR file,
                 IN int   line,
                 IN LPSTR fmt,
-                ... );
+                ... )
+    PRINTFLIKE(3,4)
+    ;
 
 BOOL
 MakeSocket( OUT PSOCKET        pSocket,
@@ -147,7 +155,9 @@
 VOID /* in util.c */
 GsmDebug( IN ULONG DebugFlagType,
           IN LPSTR Fmt,
-          ... );
+          ... )
+    PRINTFLIKE(2,3)
+    ;
 
 
 BOOL /* util.c */

Modified: tools/gssmonger/trunk/include/ezdef.h
===================================================================
--- tools/gssmonger/trunk/include/ezdef.h	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/include/ezdef.h	2009-02-24 00:00:02 UTC (rev 22051)
@@ -365,7 +365,11 @@
 				       IN          LPEZSTR, // __FILE__
 				       IN          ULONG,   // __LINE__
 				       IN          LPEZSTR, // fmt
-				       ... );
+				       ... )
+#if defined __GNUC__ && __GNUC__ >= 3 && !defined(__cplusplus) && defined(EZ_ASCII)
+    __attribute__((format(printf,5,6)))
+#endif
+    ;
 
 typedef EZU(EZLOGMSG_FN) *EZU(PEZLOGMSG_FN);
 

Modified: tools/gssmonger/trunk/include/ezlog.h
===================================================================
--- tools/gssmonger/trunk/include/ezlog.h	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/include/ezlog.h	2009-02-24 00:00:02 UTC (rev 22051)
@@ -640,6 +640,7 @@
 
    This keeps me from having to doubly-define the whole mess. */
 
+#define EZ_ASCII
 #define LPEZSTR LPSTR
 #define EZU( x ) x ## A
 
@@ -647,6 +648,7 @@
 
 #undef LPEZSTR
 #undef EZU
+#undef EZ_ASCII
 
 #define LPEZSTR  LPWSTR
 #define EZU( x ) x ## W

Modified: tools/gssmonger/trunk/include/server.h
===================================================================
--- tools/gssmonger/trunk/include/server.h	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/include/server.h	2009-02-24 00:00:02 UTC (rev 22051)
@@ -81,14 +81,22 @@
                   IN LPSTR file,
                   IN int   line,
                   IN LPSTR fmt,
-                  ... );
+                  ... )
+#if defined __GNUC__ && __GNUC__ >= 3
+    __attribute__((format(printf,4,5)))
+#endif
+    ;
 
 BOOL /* server.c */
 ServerLogFailure( IN PPROTOCOL_CALLBACK_ARGS pArgs,
                   IN LPSTR file,
                   IN int   line,
                   IN LPSTR fmt,
-                  ... );
+                  ... )
+#if defined __GNUC__ && __GNUC__ >= 3
+    __attribute__((format(printf,4,5)))
+#endif
+    ;
 
 #endif
 

Modified: tools/gssmonger/trunk/include/unix.h
===================================================================
--- tools/gssmonger/trunk/include/unix.h	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/include/unix.h	2009-02-24 00:00:02 UTC (rev 22051)
@@ -212,7 +212,8 @@
 
 #define ZeroMemory(X, Y) memset((X), '\0', (Y))
 #define GetLastError() -1
-#define WSAGetLastError() (DWORD)-1
+#define WSAGetLastError() ((int)-1)
+#define SOCKET_FORMAT "%d"
 
 #include <signal.h> // signal() is used for gssmaster's custom ctrl-C handler
 

Modified: tools/gssmonger/trunk/include/win.h
===================================================================
--- tools/gssmonger/trunk/include/win.h	2009-02-23 21:26:29 UTC (rev 22050)
+++ tools/gssmonger/trunk/include/win.h	2009-02-24 00:00:02 UTC (rev 22051)
@@ -157,4 +157,9 @@
 
 #define UNUSED_PARAMETER( x ) x /* reference unreferenced parameter */
 
-#endif // __WIN_H
\ No newline at end of file
+/* The type SOCKET is technically a pointer-sized unsigned integer
+   type, but this looks close enough, and was what the original code
+   was using.  */
+#define SOCKET_FORMAT "0x%p"
+
+#endif // __WIN_H




More information about the cvs-krb5 mailing list