changeset 765:d553d14a2565

2006-7-13 Brian Masney <masneyb@gftp.org> * lib/cache.c lib/config_file.c lib/fsp.c lib/ftps.c lib/gftp.h lib/local.c lib/misc.c lib/options.h lib/protocols.c lib/rfc2068.c lib/rfc959.c lib/sshv2.c - started to add some annotations for splint. Fixed a few minor warnings from splint.
author masneyb
date Fri, 14 Jul 2006 00:34:11 +0000
parents 4ed80df6729d
children 1ad4eb5c29de
files ChangeLog lib/cache.c lib/config_file.c lib/fsp.c lib/ftps.c lib/gftp.h lib/local.c lib/misc.c lib/options.h lib/protocols.c lib/rfc2068.c lib/rfc959.c lib/sshv2.c
diffstat 13 files changed, 155 insertions(+), 126 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Jul 07 20:04:42 2006 +0000
+++ b/ChangeLog	Fri Jul 14 00:34:11 2006 +0000
@@ -1,3 +1,9 @@
+2006-7-13 Brian Masney <masneyb@gftp.org>
+	* lib/cache.c lib/config_file.c lib/fsp.c lib/ftps.c lib/gftp.h
+	lib/local.c lib/misc.c lib/options.h lib/protocols.c lib/rfc2068.c
+	lib/rfc959.c lib/sshv2.c - started to add some annotations for splint.
+	Fixed a few minor warnings from splint.
+
 2006-7-7 Brian Masney <masneyb@gftp.org>
 	* lib/protocols.c (gftp_get_transfer_status) - split this function into
 	several smaller functions. Fixed bug where the number of retries wasn't
@@ -3400,7 +3406,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.437 2006/07/07 20:04:42 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.438 2006/07/14 00:34:10 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/cache.c	Fri Jul 07 20:04:42 2006 +0000
+++ b/lib/cache.c	Fri Jul 14 00:34:11 2006 +0000
@@ -36,7 +36,7 @@
 
 
 static int
-gftp_parse_cache_line (gftp_request * request, gftp_cache_entry * centry, 
+gftp_parse_cache_line (gftp_request * request, /*@out@*/ gftp_cache_entry * centry, 
                        char *line)
 {
   char *pos;
@@ -88,7 +88,7 @@
 
 
 static void
-gftp_restore_cache_line (gftp_cache_entry * centry, char *line)
+gftp_restore_cache_line (gftp_cache_entry * centry)
 {
   if (centry->pos1 != NULL)
     *centry->pos1 = '\t';
@@ -102,7 +102,8 @@
 
 
 void
-gftp_generate_cache_description (gftp_request * request, char *description,
+gftp_generate_cache_description (gftp_request * request,
+                                 char *description,
                                  size_t len, int ignore_directory)
 {
   g_snprintf (description, len, "%s://%s@%s:%d%s",
@@ -137,6 +138,7 @@
                                  _("Error: Could not make directory %s: %s\n"),
                                  cachedir, g_strerror (errno));
 
+          g_free (cachedir);
           return (-1);
         }
     }
@@ -156,6 +158,7 @@
   if ((cache_fd = mkstemp (tempstr)) < 0)
     {
       g_free (tempstr);
+      g_free (cachedir);
       if (request != NULL)
         request->logging_function (gftp_logging_error, request,
                                  _("Error: Cannot create temporary file: %s\n"),
@@ -202,6 +205,7 @@
 
   time (&now);
 
+  *description = '\0';
   gftp_generate_cache_description (request, description, sizeof (description),
                                    0);
 
@@ -276,6 +280,7 @@
       return;
     }
 
+  *buf = '\0';
   rbuf = NULL;
   while (gftp_get_line (NULL, &rbuf, buf, sizeof (buf), indexfd) > 0)
     {
@@ -307,6 +312,7 @@
   time (&now);
   if (request != NULL)
     {
+      *description = '\0';
       gftp_generate_cache_description (request, description, sizeof (description),
                                        ignore_directory);
     }
@@ -334,6 +340,7 @@
       return;
     }
 
+  *buf = '\0';
   rbuf = NULL;
   while (gftp_get_line (NULL, &rbuf, buf, sizeof (buf) - 1, indexfd) > 0)
     {
@@ -362,7 +369,7 @@
           /* Make sure we put the tabs back in the line. I do it this way 
              so that I don't have to allocate memory again for each line 
              as we read it */
-          gftp_restore_cache_line (&centry, buf);
+          gftp_restore_cache_line (&centry);
 
           /* Make sure when we call gftp_get_line() that we pass the read size
              as sizeof(buf) - 1 so that we'll have room to put the newline */
--- a/lib/config_file.c	Fri Jul 07 20:04:42 2006 +0000
+++ b/lib/config_file.c	Fri Jul 14 00:34:11 2006 +0000
@@ -125,7 +125,7 @@
     {
       printf (_("Error: Cannot open local file %s: %s\n"),
               source, g_strerror (errno));
-      exit (1);
+      exit (EXIT_FAILURE);
     }
 
   if ((destfd = gftp_fd_open (NULL, dest, O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR)) == -1)
@@ -133,7 +133,7 @@
       printf (_("Error: Cannot open local file %s: %s\n"),
               dest, g_strerror (errno));
       close (srcfd);
-      exit (1);
+      exit (EXIT_FAILURE);
     }
 
   while ((n = read (srcfd, buf, sizeof (buf))) > 0)
@@ -142,26 +142,26 @@
         {
           printf (_("Error: Could not write to socket: %s\n"), 
                   g_strerror (errno));
-          exit (1);
+          exit (EXIT_FAILURE);
         }
     }
 
   if (n == -1)
     {
       printf (_("Error: Could not read from socket: %s\n"), g_strerror (errno));
-      exit (1);
+      exit (EXIT_FAILURE);
     }
 
   if (close (srcfd) == -1)
     {
       printf (_("Error closing file descriptor: %s\n"), g_strerror (errno));
-      exit (1);
+      exit (EXIT_FAILURE);
     }
 
   if (close (destfd) == -1)
     {
       printf (_("Error closing file descriptor: %s\n"), g_strerror (errno));
-      exit (1);
+      exit (EXIT_FAILURE);
     }
 
   return (1);
@@ -181,7 +181,7 @@
   if ((tempstr = gftp_expand_path (NULL, BOOKMARKS_FILE)) == NULL)
     {
       printf (_("gFTP Error: Bad bookmarks file name %s\n"), BOOKMARKS_FILE);
-      exit (1);
+      exit (EXIT_FAILURE);
     }
 
   if (access (tempstr, F_OK) == -1)
@@ -202,7 +202,7 @@
     {
       printf (_("gFTP Error: Cannot open bookmarks file %s: %s\n"), tempstr,
 	      g_strerror (errno));
-      exit (1);
+      exit (EXIT_FAILURE);
     }
   g_free (tempstr);
 
@@ -303,7 +303,7 @@
 
           newentry->num_local_options_vars++;
           newentry->local_options_vars = g_realloc (newentry->local_options_vars,
-                                                    sizeof (gftp_config_vars) * newentry->num_local_options_vars);
+                                                    (gulong) sizeof (gftp_config_vars) * newentry->num_local_options_vars);
 
           memcpy (&newentry->local_options_vars[newentry->num_local_options_vars - 1], global_entry, 
                   sizeof (newentry->local_options_vars[newentry->num_local_options_vars - 1]));
@@ -363,7 +363,7 @@
       else
 	endpos = curpos + strlen (curpos);
 
-      *dest = g_malloc (endpos - curpos + 1);
+      *dest = g_malloc ((gulong) (endpos - curpos + 1));
       tempchar = *endpos;
       *endpos = '\0';
       strcpy (*dest, curpos);
@@ -556,7 +556,8 @@
     {
       if (gftp_protocols[i].shown)
         {
-          protocol_list = g_realloc (protocol_list, sizeof (char *) * (j + 2));
+          protocol_list = g_realloc (protocol_list,
+                                     (gulong) sizeof (char *) * (j + 2));
           protocol_list[j] = gftp_protocols[i].name;
           protocol_list[j + 1] = NULL;
           j++;
@@ -585,7 +586,7 @@
   if ((tempstr = gftp_expand_path (NULL, CONFIG_FILE)) == NULL)
     {
       printf (_("gFTP Error: Bad config file name %s\n"), CONFIG_FILE);
-      exit (1);
+      exit (EXIT_FAILURE);
     }
 
   if (access (tempstr, F_OK) == -1)
@@ -597,7 +598,7 @@
 	    {
 	      printf (_("gFTP Error: Could not make directory %s: %s\n"),
 		      temp1str, g_strerror (errno));
-	      exit (1);
+	      exit (EXIT_FAILURE);
 	    }
 	}
       g_free (temp1str);
@@ -608,7 +609,7 @@
 	  printf (_("gFTP Error: Cannot find master config file %s\n"),
 		  temp1str);
 	  printf (_("Did you do a make install?\n"));
-	  exit (1);
+	  exit (EXIT_FAILURE);
 	}
       copyfile (temp1str, tempstr);
       g_free (temp1str);
@@ -618,7 +619,7 @@
     {
       printf (_("gFTP Error: Cannot open config file %s: %s\n"), CONFIG_FILE,
 	      g_strerror (errno));
-      exit (1);
+      exit (EXIT_FAILURE);
     }
   g_free (tempstr);
  
@@ -656,7 +657,7 @@
                                 tmpconfigvar, line) != 0)
             {
               printf (_("Terminating due to parse errors at line %d in the config file\n"), line);
-              exit (1);
+              exit (EXIT_FAILURE);
             }
         }
       else
@@ -669,7 +670,7 @@
   if ((tempstr = gftp_expand_path (NULL, LOG_FILE)) == NULL)
     {
       printf (_("gFTP Error: Bad log file name %s\n"), LOG_FILE);
-      exit (1);
+      exit (EXIT_FAILURE);
     }
 
   if ((gftp_logfd = fopen (tempstr, "w")) == NULL)
@@ -735,14 +736,14 @@
   if ((tempstr = gftp_expand_path (NULL, BOOKMARKS_FILE)) == NULL)
     {
       printf (_("gFTP Error: Bad bookmarks file name %s\n"), CONFIG_FILE);
-      exit (1);
+      exit (EXIT_FAILURE);
     }
 
   if ((bmfile = fopen (tempstr, "w+")) == NULL)
     {
       printf (_("gFTP Error: Cannot open bookmarks file %s: %s\n"),
 	      CONFIG_FILE, g_strerror (errno));
-      exit (1);
+      exit (EXIT_FAILURE);
     }
 
   g_free (tempstr);
@@ -776,7 +777,7 @@
             password = NULL;
 
           fprintf (bmfile,
-    	       "[%s]\nhostname=%s\nport=%d\nprotocol=%s\nremote directory=%s\nlocal directory=%s\nusername=%s\npassword=%s\naccount=%s\n",
+    	       "[%s]\nhostname=%s\nport=%u\nprotocol=%s\nremote directory=%s\nlocal directory=%s\nusername=%s\npassword=%s\naccount=%s\n",
     	       tempstr, tempentry->hostname == NULL ? "" : tempentry->hostname,
     	       tempentry->port, tempentry->protocol == NULL
     	       || *tempentry->protocol ==
@@ -830,14 +831,14 @@
   if ((tempstr = gftp_expand_path (NULL, CONFIG_FILE)) == NULL)
     {
       printf (_("gFTP Error: Bad config file name %s\n"), CONFIG_FILE);
-      exit (1);
+      exit (EXIT_FAILURE);
     }
 
   if ((conffile = fopen (tempstr, "w+")) == NULL)
     {
       printf (_("gFTP Error: Cannot open config file %s: %s\n"), CONFIG_FILE,
 	      g_strerror (errno));
-      exit (1);
+      exit (EXIT_FAILURE);
     }
 
   g_free (tempstr);
@@ -1287,7 +1288,7 @@
   else
     {
       fprintf (stderr, _("FATAL gFTP Error: Config option '%s' not found in global hash table\n"), key);
-      exit (1);
+      exit (EXIT_FAILURE);
     }
 }
 
@@ -1350,7 +1351,7 @@
   else
     {
       fprintf (stderr, _("FATAL gFTP Error: Config option '%s' not found in global hash table\n"), key);
-      exit (1);
+      exit (EXIT_FAILURE);
     }
 }
 
@@ -1392,12 +1393,12 @@
                                                key)) == NULL)
         {
           fprintf (stderr, _("FATAL gFTP Error: Config option '%s' not found in global hash table\n"), key);
-          exit (1);
+          exit (EXIT_FAILURE);
         }
       
       request->num_local_options_vars++;
       request->local_options_vars = g_realloc (request->local_options_vars, 
-                                               sizeof (gftp_config_vars) * request->num_local_options_vars);
+                                               (gulong) sizeof (gftp_config_vars) * request->num_local_options_vars);
 
       memcpy (&request->local_options_vars[request->num_local_options_vars - 1], tmpconfigvar, sizeof (*tmpconfigvar));
       _gftp_set_option_value (&request->local_options_vars[request->num_local_options_vars - 1], value);
@@ -1425,7 +1426,7 @@
                                                key)) == NULL)
         {
           fprintf (stderr, _("FATAL gFTP Error: Config option '%s' not found in global hash table\n"), key);
-          exit (1);
+          exit (EXIT_FAILURE);
         }
 
       /* Check to see if this is set to the same value as the global option. 
@@ -1444,7 +1445,7 @@
 
       bm->num_local_options_vars++;
       bm->local_options_vars = g_realloc (bm->local_options_vars, 
-                                          sizeof (gftp_config_vars) * bm->num_local_options_vars);
+                                          (gulong) sizeof (gftp_config_vars) * bm->num_local_options_vars);
 
       memcpy (&bm->local_options_vars[bm->num_local_options_vars - 1], tmpconfigvar, sizeof (*tmpconfigvar));
       _gftp_set_option_value (&bm->local_options_vars[bm->num_local_options_vars - 1], value);
@@ -1482,7 +1483,7 @@
   *new_options_hash = g_hash_table_new (string_hash_function,
                                         string_hash_compare);
 
-  *new_options_vars = g_malloc (sizeof (gftp_config_vars) * num_local_options_vars);
+  *new_options_vars = g_malloc ((gulong) sizeof (gftp_config_vars) * num_local_options_vars);
   memcpy (*new_options_vars, orig_options,
           sizeof (gftp_config_vars) * num_local_options_vars);
 
--- a/lib/fsp.c	Fri Jul 07 20:04:42 2006 +0000
+++ b/lib/fsp.c	Fri Jul 14 00:34:11 2006 +0000
@@ -19,13 +19,12 @@
 /*****************************************************************************/
 
 #include "gftp.h"
+static const char cvsid[] = "$Id$";
 
 #define FSP_USE_SHAREMEM_AND_SEMOP 1
 #include "fsplib/fsplib.h"
 #include "fsplib/lock.h"
 
-static const char cvsid[] = "$Id$";
-
 typedef struct fsp_protocol_data_tag
 {
   FSP_SESSION *fsp;
--- a/lib/ftps.c	Fri Jul 07 20:04:42 2006 +0000
+++ b/lib/ftps.c	Fri Jul 14 00:34:11 2006 +0000
@@ -114,7 +114,7 @@
 }
 
 
-static int
+/*@unused@*/ static int
 ftps_connect (gftp_request * request)
 {
   if (request->datafd > 0)
--- a/lib/gftp.h	Fri Jul 07 20:04:42 2006 +0000
+++ b/lib/gftp.h	Fri Jul 14 00:34:11 2006 +0000
@@ -231,13 +231,13 @@
 
 struct gftp_file_tag 
 {
-  char *file,			/* Our filename */
-       *utf8_file,		/* UTF-8 encoded filename for display purposes
+  /*@null@*/ char *file,	/* Our filename */
+                  *utf8_file,	/* UTF-8 encoded filename for display purposes
 				   only. This is only set if file is not in 
 				   UTF-8 */
-       *user,			/* User that owns it */
-       *group,			/* Group that owns it */
-       *destfile;		/* Full pathname to the destination for the 
+                  *user,	/* User that owns it */
+                  *group,	/* Group that owns it */
+                  *destfile;	/* Full pathname to the destination for the 
                                    file transfer */
 
   int fd;			/* Already open fd for this file */
@@ -256,7 +256,7 @@
                transfer_done : 1, /* Is current file transfer done? */
                is_fd : 1;	/* Is this a file descriptor? */
   char transfer_action;		/* See the GFTP_TRANS_ACTION_* vars above */
-  void *user_data;
+  /*@null@*/ void *user_data;
 };
 
 
@@ -309,26 +309,26 @@
 
 typedef struct gftp_config_vars_tag
 {
-  char *key,			/* variable name */
-       *description;		/* How this field will show up in the dialog */
+  /*@null@*/ char *key,		/* variable name */
+                  *description;	/* How this field will show up in the dialog */
   int otype;			/* Type of option this is */
-  void *value;
-  void *listdata;		/* For options that have several different 
+  /*@null@*/ void *value;
+  /*@null@*/ void *listdata;	/* For options that have several different 
 				   options, this is a list of all the options.
 				   Each option_type that uses this will use this
 				   field differently */
   int flags;			/* See GFTP_CVARS_FLAGS_* above */
-  char *comment;                /* Comment to write out to the config file */
+  /*@null@*/ char *comment;     /* Comment to write out to the config file */
   int ports_shown;		/* What ports of gFTP is this option shown in */
-  void *user_data;		/* Data that the GUI can store here (Widget in gtk+) */
+  /*@null@*/ void *user_data;	/* Data that the GUI can store here (Widget in gtk+) */
 } gftp_config_vars;
 
 
 typedef struct gftp_option_type_tag
 {
   int (*read_function) (char *str, gftp_config_vars * cv, int line);
-  int (*write_function) (gftp_config_vars * cv, char *buf, size_t buflen,
-                         int to_config_file);
+  int (*write_function) (gftp_config_vars * cv, /*@out@*/ char *buf,
+                         size_t buflen, int to_config_file);
   void (*copy_function) (gftp_config_vars * cv, gftp_config_vars * dest_cv);
   int (*compare_function) (gftp_config_vars * cv1, gftp_config_vars * cv2);
   void *(*ui_print_function) (gftp_config_vars * cv, void *user_data, void *value);
@@ -342,8 +342,8 @@
 
 typedef struct gftp_textcomboedt_data_tag
 {
-  char *description,
-       *text;
+  /*@null@*/ char *description,
+                  *text;
   int flags;
 } gftp_textcomboedt_data;
 
@@ -351,7 +351,7 @@
 typedef struct gftp_request_tag gftp_request;
 
 typedef void (*gftp_logging_func)		( gftp_logging_level level, 
-						  gftp_request * request, 
+						  /*@null@*/ gftp_request * request, 
 						  const char *string, ... );
 
 #define GFTP_ANONYMOUS_USER			"anonymous"
@@ -436,7 +436,7 @@
 					  int fd,
 					  off_t startsize,
 					  off_t totalsize );
-  long (*transfer_file) 		( gftp_request * fromreq, 
+  off_t (*transfer_file) 		( gftp_request * fromreq, 
 					  const char *fromfile, 
 					  off_t fromsize, 
 					  gftp_request * toreq, 
@@ -562,10 +562,10 @@
 
 typedef struct supported_gftp_protocols_tag 
 {
-  char *name;					/* Description of protocol */
-  int (*init) (gftp_request * request);		/* Init function */
-  void (*register_options) (void);		/* Protocol options */
-  char *url_prefix;				/* URL Prefix */
+  /*@null@*/ char *name;			/* Description of protocol */
+  /*@null@*/ int (*init) (gftp_request * request); /* Init function */
+  /*@null@*/ void (*register_options) (void);	/* Protocol options */
+  /*@null@*/ char *url_prefix;			/* URL Prefix */
   unsigned int default_port;			/* Default port */
   unsigned int shown : 1,			/* Whether this protocol is 
                                                    shown or not to the user in 
@@ -634,15 +634,15 @@
 
 
 /* Global config options. These are defined in options.h */
-extern GList * gftp_file_transfers, * gftp_file_transfer_logs,
-             * gftp_options_list;
-extern GHashTable * gftp_global_options_htable, * gftp_bookmarks_htable, 
-                  * gftp_config_list_htable;
+/*@null@*/ extern GList * gftp_file_transfers, * gftp_file_transfer_logs,
+                        * gftp_options_list;
+/*@null@*/ extern GHashTable * gftp_global_options_htable, * gftp_bookmarks_htable, 
+                             * gftp_config_list_htable;
+/*@null@*/ extern gftp_bookmarks_var * gftp_bookmarks;
+/*@null@*/ extern FILE * gftp_logfd;
 extern gftp_config_vars gftp_global_config_vars[];
 extern supported_gftp_protocols gftp_protocols[];
-extern gftp_bookmarks_var * gftp_bookmarks;
 extern char gftp_version[];
-extern FILE * gftp_logfd;
 extern int gftp_configuration_changed;
 
 /* This is defined in config_file.c */
@@ -651,7 +651,7 @@
 
 /* cache.c */
 void gftp_generate_cache_description 	( gftp_request * request, 
-					  char *description,
+					  /*@out@*/ char *description,
 					  size_t len, 
 					  int ignore_directory );
 
@@ -669,7 +669,7 @@
 int gftp_config_parse_args 		( char *str, 
 					  int numargs, 
 					  int lineno, 
-					  char **first, 
+					  /*@out@*/ char **first, 
 					  ... );
 
 void gftp_add_bookmark 			( gftp_bookmarks_var * newentry );
@@ -685,11 +685,12 @@
 void print_bookmarks 			( gftp_bookmarks_var * bookmarks );
 
 void gftp_lookup_global_option 		( const char * key, 
-					  void *value );
+					  /*@out@*/ void *value );
 
 void gftp_lookup_request_option 	( gftp_request * request, 
 					  const char * key, 
-					  void *value );
+					  /*@out@*/ void *value );
+
 
 void gftp_lookup_bookmark_option 	( gftp_bookmarks_var * bm, 
 					  const char * key, 
@@ -725,7 +726,7 @@
 GList * gftp_copy_proxy_hosts 		( GList * proxy_hosts );
 
 /* misc.c */
-char *insert_commas 			( off_t number, 
+/*@null@*/ char *insert_commas 		( off_t number, 
 					  char *dest_str, 
 					  size_t dest_len );
 
@@ -902,10 +903,10 @@
 
 int gftp_list_files 			( gftp_request * request );
 
-char * gftp_string_to_utf8		( gftp_request * request, 
+/*@null@*/ char * gftp_string_to_utf8	( gftp_request * request, 
 					  const char *str );
 
-char * gftp_string_from_utf8		( gftp_request * request, 
+/*@null@*/ char * gftp_string_from_utf8	( gftp_request * request, 
 					  const char *str );
 
 int gftp_parse_bookmark 		( gftp_request * request, 
@@ -967,7 +968,7 @@
 					  const char *file, 
 					  time_t datetime );
 
-char gftp_site_cmd 			( gftp_request * request, 
+int gftp_site_cmd 			( gftp_request * request, 
 					  int specify_site,
 					  const char *command );
 
@@ -1004,7 +1005,7 @@
 
 struct servent *r_getservbyname 	( const char *name, 
 					  const char *proto,
-					  struct servent *result_buf, 
+					  /*@out@*/ struct servent *result_buf, 
 					  int *h_errnop );
 
 int gftp_set_config_options 		( gftp_request * request );
@@ -1014,8 +1015,8 @@
 void gftp_free_getline_buffer 		( gftp_getline_buffer ** rbuf );
 
 ssize_t gftp_get_line 			( gftp_request * request, 
-					  gftp_getline_buffer ** rbuf,
-					  char * str, 
+					  /*@out@*/ gftp_getline_buffer ** rbuf,
+					  /*@out@*/ char * str, 
 					  size_t len, 
 					  int fd );
 
--- a/lib/local.c	Fri Jul 07 20:04:42 2006 +0000
+++ b/lib/local.c	Fri Jul 14 00:34:11 2006 +0000
@@ -28,7 +28,8 @@
 
 
 static void
-local_remove_key (gpointer key, gpointer value, gpointer user_data)
+local_remove_key (/*@unused@*/ gpointer key, gpointer value,
+                  /*@unused@*/ gpointer user_data)
 {
   g_free (value);
 }
@@ -154,7 +155,7 @@
 
 static int
 local_put_file (gftp_request * request, const char *filename, int fd,
-                off_t startsize, off_t totalsize)
+                off_t startsize, /*@unused@*/ off_t totalsize)
 {
   int flags;
 
@@ -225,7 +226,7 @@
 
 
 static int
-local_stat_filename (gftp_request * request, const char *filename,
+local_stat_filename (/*@unused@*/ gftp_request * request, const char *filename,
                      mode_t * mode)
 {
   struct stat st;
@@ -359,7 +360,7 @@
 
 
 static off_t 
-local_get_file_size (gftp_request * request, const char *filename)
+local_get_file_size (/*@unused@*/ gftp_request * request, const char *filename)
 {
   struct stat st;
 
--- a/lib/misc.c	Fri Jul 07 20:04:42 2006 +0000
+++ b/lib/misc.c	Fri Jul 14 00:34:11 2006 +0000
@@ -41,7 +41,7 @@
 {
   char *frompos, *topos, src[50], *dest;
   size_t num, rem, srclen;
-  int len, i;
+  size_t len, i;
 
   g_snprintf (src, sizeof (src), GFTP_OFF_T_PRINTF_MOD, number);
 
@@ -289,7 +289,6 @@
       else if(*wcpos++ != *filepos++) 
         return(0);
     }
-  return (1);
 }
 
 
@@ -964,7 +963,7 @@
   if (slen % 3 > 0)
     num++;
 
-  newstr = g_malloc (num * 4 + 1);
+  newstr = g_malloc ((gulong) num * 4 + 1);
   newstr[num * 4] = '\0';
   newpos = newstr;
 
@@ -1155,7 +1154,7 @@
         }
       
       retlen += len;
-      ret = g_realloc (ret, retlen + 1);
+      ret = g_realloc (ret, (gulong) retlen + 1);
 
       /* Don't append a / for VMS servers... */
       if (add_separator &&
@@ -1201,12 +1200,12 @@
   if (strcmp (password, "@EMAIL@") == 0)
     return (g_strdup (password));
 
-  newstr = g_malloc (strlen (password) * 2 + 2);
+  newstr = g_malloc ((gulong) strlen (password) * 2 + 2);
   newpos = newstr;
   
   *newpos++ = '$';
 
-  while (*password != 0)
+  while (*password != '\0')
     {
       *newpos++ = ((*password >> 2) & 0x3c) | 0x41;
       *newpos++ = ((*password << 2) & 0x3c) | 0x41;
@@ -1229,11 +1228,11 @@
     return (g_strdup (password));
 
   passwordpos = password + 1;
-  newstr = g_malloc (strlen (passwordpos) / 2 + 1);
+  newstr = g_malloc ((gulong) strlen (passwordpos) / 2 + 1);
   newpos = newstr;
  
   error = 0;
-  while (*passwordpos != '\0' && (*passwordpos + 1) != '\0')
+  while (*passwordpos != '\0' && *(passwordpos + 1) != '\0')
     {
       if ((*passwordpos & 0xc3) != 0x41 ||
           (*(passwordpos + 1) & 0xc3) != 0x41)
--- a/lib/options.h	Fri Jul 07 20:04:42 2006 +0000
+++ b/lib/options.h	Fri Jul 14 00:34:11 2006 +0000
@@ -21,11 +21,17 @@
 
 #include "gftp.h"
 
-static char *gftp_sort_columns[] = { N_("none"), N_("file"), N_("size"), 
-                                     N_("user"), N_("group"), 
-                                     N_("datetime"), N_("attribs"), NULL };
+typedef /*@null@*/ char *gftp_sort_columns_tag;
+static gftp_sort_columns_tag gftp_sort_columns[] = { N_("none"), N_("file"),
+                                                     N_("size"), N_("user"),
+                                                     N_("group"),
+                                                     N_("datetime"),
+                                                     N_("attribs"), NULL };
 
-static char *gftp_sort_direction[] = { N_("descending"), N_("ascending"), NULL };
+typedef /*@null@*/ char *gftp_sort_direction_tag;
+static gftp_sort_direction_tag gftp_sort_direction[] = { N_("descending"),
+                                                         N_("ascending"),
+                                                         NULL };
 
 static float gftp_maxkbs = 0.0;
 
@@ -271,7 +277,7 @@
       
 gftp_bookmarks_var * gftp_bookmarks = NULL;
 
-FILE * gftp_logfd = NULL;
+/*@null@*/ FILE * gftp_logfd = NULL;
 
 int gftp_configuration_changed = 0;
 
--- a/lib/protocols.c	Fri Jul 07 20:04:42 2006 +0000
+++ b/lib/protocols.c	Fri Jul 14 00:34:11 2006 +0000
@@ -413,7 +413,7 @@
 
 #if GLIB_MAJOR_VERSION > 1
 
-static char *
+static /*@null@*/ char *
 _gftp_get_next_charset (char **curpos)
 {
   char *ret, *endpos;
@@ -434,7 +434,7 @@
 }
 
 
-char *
+/*@null@*/ char *
 gftp_string_to_utf8 (gftp_request * request, const char *str)
 {
   char *ret, *remote_charsets, *stpos, *cur_charset, *tempstr;
@@ -1100,7 +1100,7 @@
 }
 
 
-char
+int
 gftp_site_cmd (gftp_request * request, int specify_site, const char *command)
 {
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
@@ -1228,7 +1228,7 @@
 
 
 static char *
-copy_token (char **dest, char *source)
+copy_token (/*@out@*/ char **dest, char *source)
 {
   /* This function is used internally by gftp_parse_ls () */
   char *endpos, savepos;
@@ -1237,11 +1237,14 @@
   while (*endpos != ' ' && *endpos != '\t' && *endpos != '\0')
     endpos++;
   if (*endpos == '\0')
-    return (NULL);
+    {
+      *dest = NULL;
+      return (NULL);
+    }
 
   savepos = *endpos;
   *endpos = '\0';
-  *dest = g_malloc (endpos - source + 1);
+  *dest = g_malloc ((gulong) (endpos - source + 1));
   strcpy (*dest, source);
   *endpos = savepos;
 
@@ -1671,7 +1674,7 @@
   if (GFTP_IS_SPECIAL_DEVICE (fle->st_mode) &&
       (endpos = strchr (startpos, ',')) != NULL)
     {
-      fle->size = strtol (startpos, NULL, 10) << 16;
+      fle->size = (unsigned long) strtol (startpos, NULL, 10) << 16;
 
       startpos = endpos + 1;
       while (*startpos == ' ')
@@ -2269,11 +2272,14 @@
 #else /* !HAVE_GETADDRINFO */
   struct sockaddr_in remote_address;
   struct servent serv_struct;
-
-  if ((request->use_proxy = gftp_need_proxy (request, service,
-                                             proxy_hostname, proxy_port)) < 0)
-    return (request->use_proxy);
-  else if (request->use_proxy == 1)
+  int ret;
+
+  if ((ret = gftp_need_proxy (request, service, proxy_hostname,
+                              proxy_port)) < 0)
+    return (ret);
+
+  request->use_proxy = ret;
+  if (request->use_proxy == 1)
     request->hostp = NULL;
 
   request->ai_family = AF_INET;
@@ -2471,7 +2477,7 @@
     {
       *rbuf = g_malloc0 (sizeof (**rbuf));
       (*rbuf)->max_bufsize = len;
-      (*rbuf)->buffer = g_malloc0 ((*rbuf)->max_bufsize + 1);
+      (*rbuf)->buffer = g_malloc0 ((gulong) ((*rbuf)->max_bufsize + 1));
 
       if ((ret = read_function (request, (*rbuf)->buffer, 
                                 (*rbuf)->max_bufsize, fd)) <= 0)
@@ -3049,7 +3055,7 @@
 {
   char *str;
 
-  str = g_malloc0 (11);
+  str = g_malloc0 (11UL);
   
   str[0] = '?';
   if (S_ISREG (mode))
--- a/lib/rfc2068.c	Fri Jul 07 20:04:42 2006 +0000
+++ b/lib/rfc2068.c	Fri Jul 14 00:34:11 2006 +0000
@@ -93,8 +93,9 @@
 rfc2068_read_response (gftp_request * request)
 {
   rfc2068_params * params;
+  unsigned int chunked;
   char tempstr[8192];
-  int ret, chunked;
+  int ret;
 
   params = request->protocol_data;
   *tempstr = '\0';
@@ -161,7 +162,7 @@
         {
           params->extra_read_buffer_len = params->chunk_size * -1;
           params->chunk_size = 0;
-          params->extra_read_buffer = g_malloc (params->extra_read_buffer_len + 1);
+          params->extra_read_buffer = g_malloc ((gulong) params->extra_read_buffer_len + 1);
           memcpy (params->extra_read_buffer, params->rbuf->curpos + (params->rbuf->cur_bufsize - params->extra_read_buffer_len), params->extra_read_buffer_len);
           params->extra_read_buffer[params->extra_read_buffer_len] = '\0';
           params->rbuf->cur_bufsize -= params->extra_read_buffer_len;
@@ -175,7 +176,7 @@
 
 
 static off_t 
-rfc2068_send_command (gftp_request * request, const void *command, size_t len)
+rfc2068_send_command (gftp_request * request, const char *command)
 {
   char *tempstr, *str, *proxy_hostname, *proxy_username, *proxy_password;
   intptr_t proxy_port;
@@ -309,7 +310,7 @@
       g_free (oldstr);
     }
 
-  size = rfc2068_send_command (request, tempstr, strlen (tempstr));
+  size = rfc2068_send_command (request, tempstr);
   g_free (tempstr);
   if (size < 0)
     return (size);
@@ -410,7 +411,7 @@
 
   g_free (hd);
 
-  ret = rfc2068_send_command (request, tempstr, strlen (tempstr));
+  ret = rfc2068_send_command (request, tempstr);
   g_free (tempstr);
   if (ret < 0)
     return ((int) ret);
@@ -454,7 +455,7 @@
 
   g_free (hf);
 
-  size = rfc2068_send_command (request, tempstr, strlen (tempstr));
+  size = rfc2068_send_command (request, tempstr);
   g_free (tempstr);
   return (size);
 }
@@ -803,7 +804,7 @@
           /* The current chunk size is split between multiple packets.
              Save this chunk and read the next */
 
-          params->extra_read_buffer = g_malloc (current_size + 1);
+          params->extra_read_buffer = g_malloc ((gulong) current_size + 1);
           memcpy (params->extra_read_buffer, stpos, current_size);
           params->extra_read_buffer[current_size] = '\0';
           params->extra_read_buffer_len = current_size;
--- a/lib/rfc959.c	Fri Jul 07 20:04:42 2006 +0000
+++ b/lib/rfc959.c	Fri Jul 14 00:34:11 2006 +0000
@@ -255,7 +255,7 @@
           *endpos = '\0';
 
           len += strlen (startpos) + 2;
-          newstr = g_realloc (newstr, sizeof (char) * (len + 1));
+          newstr = g_realloc (newstr, (gulong) sizeof (char) * (len + 1));
           strcat (newstr, startpos);
           strcat (newstr, "\r\n");
 
@@ -275,7 +275,7 @@
       len += strlen (startpos);
       if (!newval)
         {
-          newstr = g_realloc (newstr, sizeof (char) * (len + 1));
+          newstr = g_realloc (newstr, (gulong) sizeof (char) * (len + 1));
           strcat (newstr, startpos);
         }
       else
@@ -286,7 +286,7 @@
           else
             len += strlen (newval);
 
-          newstr = g_realloc (newstr, sizeof (char) * (len + 1));
+          newstr = g_realloc (newstr, (gulong) sizeof (char) * (len + 1));
           strcat (newstr, startpos);
 
           if (utf8 != NULL)
@@ -468,7 +468,8 @@
       gftp_set_password (request, email);
     }
    
-  if ((ret = gftp_connect_server (request, "ftp", proxy_hostname, proxy_port)) < 0)
+  if ((ret = gftp_connect_server (request, "ftp", proxy_hostname,
+                                  proxy_port)) < 0)
     return (ret);
 
   /* Get the banner */
@@ -1023,7 +1024,7 @@
 }
 
 
-static int
+static unsigned int
 rfc959_is_ascii_transfer (gftp_request * request, const char *filename)
 {
   gftp_config_list_vars * tmplistvar;
@@ -1058,9 +1059,10 @@
 static int
 rfc959_set_data_type (gftp_request * request, const char *filename)
 {
+  unsigned int new_ascii;
   rfc959_parms * parms;
-  int new_ascii, ret;
   char *tempstr;
+  int ret;
 
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
 
@@ -1227,7 +1229,7 @@
 }
 
 
-static long 
+static off_t
 rfc959_transfer_file (gftp_request *fromreq, const char *fromfile, 
                       off_t fromsize, gftp_request *toreq, 
                       const char *tofile, off_t tosize)
--- a/lib/sshv2.c	Fri Jul 07 20:04:42 2006 +0000
+++ b/lib/sshv2.c	Fri Jul 14 00:34:11 2006 +0000
@@ -147,7 +147,7 @@
   char *ret;
 
   params = request->protocol_data;
-  ret = g_malloc0 (len + 1);
+  ret = g_malloc0 ((gulong) len + 1);
 
   num = htonl (params->id++);
   memcpy (ret, &num, 4);
@@ -211,7 +211,7 @@
   va_end (argp);
 
   *logstr_len += strlen (tempstr);
-  *logstr = g_realloc (*logstr, *logstr_len + 1);
+  *logstr = g_realloc (*logstr, (gulong) *logstr_len + 1);
   strcat (*logstr, tempstr);
 
   curpos = tempstr;
@@ -317,7 +317,7 @@
 
   rem = len = SSH_LOGIN_BUFSIZE;
   diff = 0;
-  tempstr = g_malloc0 (len + 1);
+  tempstr = g_malloc0 ((gulong) len + 1);
   wrotepw = 0;
   ok = 1;
 
@@ -394,6 +394,7 @@
             break;
         }
 
+      clear_tempstr = 0;
       if (pwstrs[pwidx] != NULL)
         {
           clear_tempstr = 1;
@@ -464,8 +465,6 @@
           tempstr = g_realloc (tempstr, len);
           continue;
         }
-      else
-        clear_tempstr = 0;
 
       if (clear_tempstr)
         {
@@ -532,6 +531,7 @@
       case SSH_FXP_CLOSE:
         request->logging_function (level, request, 
                                    _("%d: Close\n"), id);
+        break;
       case SSH_FXP_OPENDIR:
         request->logging_function (level, request, 
                                    _("%d: Open Directory %s\n"), id,