Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Ethereal-dev: [Ethereal-dev] Patch for getopt.c

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

From: Peter Johansson <Peter.Johansson@xxxxxxxxxxxx>
Date: Mon, 25 Jul 2005 23:07:54 +0200
The supplied patch takes care of the following compilation warnings:

getopt.c(409) : warning C4013: 'strcmp' undefined; assuming extern returning int getopt.c(478) : warning C4013: 'strncmp' undefined; assuming extern returning int getopt.c(480) : warning C4013: 'strlen' undefined; assuming extern returning int

/ Peter
Index: I:/ethereal-win32-libs/getopt.c
===================================================================
--- I:/ethereal-win32-libs/getopt.c	(revision 15066)
+++ I:/ethereal-win32-libs/getopt.c	(working copy)
@@ -28,6 +28,8 @@
 #include "config.h"
 #endif
 
+#include <string.h>
+
 #ifndef __STDC__
 /* This is a separate conditional since some stdc systems
    reject `defined (const)'.  */
@@ -477,7 +479,7 @@
 	   p++, option_index++)
 	if (!strncmp (p->name, nextchar, s - nextchar))
 	  {
-	    if (s - nextchar == strlen (p->name))
+	    if ((size_t)(s - nextchar) == strlen (p->name))
 	      {
 		/* Exact match found.  */
 		pfound = p;