Removal of warnings

Hrvoje Niksic <[email protected]> Mon, 27 Jun 2005 20:18:17 +0200
Newsgroups gmane.comp.web.wget.patches
Message-ID <[email protected]>
Removes some warnings noticed by icc -w2 simply by moving external
definitions to .h files.

2005-06-27  Hrvoje Niksic  <[email protected]>

	* wget.h (PTR_FORMAT): Cast the result of sizeof to int before
	passing it to printf's %*.

	* retr.h: Declare output_stream and output_stream_regular.

	* ftp.h: Declare ftp_last_respline.

	* convert.h: Declare dl_url_file_map.

	* http.h: New file.

Index: src/utils.c
===================================================================
--- src/utils.c	(revision 1873)
+++ src/utils.c	(working copy)
@@ -1477,6 +1477,7 @@
 
 #undef PR
 #undef W
+#undef SPRINTF_WGINT
 #undef DIGITS_1
 #undef DIGITS_2
 #undef DIGITS_3
Index: src/init.c
===================================================================
--- src/init.c	(revision 1832)
+++ src/init.c	(working copy)
@@ -51,6 +51,8 @@
 #include "recur.h"		/* for INFINITE_RECURSION */
 #include "convert.h"		/* for convert_cleanup */
 #include "res.h"		/* for res_cleanup */
+#include "http.h"		/* for http_cleanup */
+#include "retr.h"		/* for output_stream */
 
 /* We want tilde expansion enabled only when reading `.wgetrc' lines;
    otherwise, it will be performed by the shell.  This variable will
@@ -1415,7 +1417,6 @@
 
 
 void cleanup_html_url (void);
-void http_cleanup (void);
 
 
 /* Free the memory allocated by global variables.  */
@@ -1424,13 +1425,10 @@
 {
   /* Free external resources, close files, etc. */
 
-  {
-    extern FILE *output_stream;
-    if (output_stream)
-      fclose (output_stream);
-    /* No need to check for error because Wget flushes its output (and
-       checks for errors) after any data arrives.  */
-  }
+  if (output_stream)
+    fclose (output_stream);
+  /* No need to check for error because Wget flushes its output (and
+     checks for errors) after any data arrives.  */
 
   /* We're exiting anyway so there's no real need to call free()
      hundreds of times.  Skipping the frees will make Wget exit
Index: src/netrc.c
===================================================================
--- src/netrc.c	(revision 1832)
+++ src/netrc.c	(working copy)
@@ -46,7 +46,7 @@
 
 #define NETRC_FILE_NAME ".netrc"
 
-acc_t *netrc_list;
+static acc_t *netrc_list;
 
 static acc_t *parse_netrc (const char *);
 
Index: src/http.c
===================================================================
--- src/http.c	(revision 1868)
+++ src/http.c	(working copy)
@@ -41,6 +41,7 @@
 #include <locale.h>
 
 #include "wget.h"
+#include "http.h"
 #include "utils.h"
 #include "url.h"
 #include "host.h"
@@ -61,9 +62,6 @@
 
 extern char *version_string;
 
-extern FILE *output_stream;
-extern bool output_stream_regular;
-
 #ifndef MIN
 # define MIN(x, y) ((x) > (y) ? (y) : (x))
 #endif
@@ -1089,8 +1087,6 @@
 static char *basic_authentication_encode (const char *, const char *);
 static bool known_authentication_scheme_p (const char *, const char *);
 
-time_t http_atotm (const char *);
-
 #define BEGINS_WITH(line, string_constant)				\
   (!strncasecmp (line, string_constant, sizeof (string_constant) - 1)	\
    && (ISSPACE (line[sizeof (string_constant) - 1])			\
@@ -2683,7 +2679,7 @@
    buffer of 33 writable characters (32 for hex digits plus one for
    zero termination).  */
 static void
-dump_hash (unsigned char *buf, const unsigned char *hash)
+dump_hash (char *buf, const unsigned char *hash)
 {
   int i;
 
@@ -2772,8 +2768,8 @@
   {
     ALLOCA_MD5_CONTEXT (ctx);
     unsigned char hash[MD5_HASHLEN];
-    unsigned char a1buf[MD5_HASHLEN * 2 + 1], a2buf[MD5_HASHLEN * 2 + 1];
-    unsigned char response_digest[MD5_HASHLEN * 2 + 1];
+    char a1buf[MD5_HASHLEN * 2 + 1], a2buf[MD5_HASHLEN * 2 + 1];
+    char response_digest[MD5_HASHLEN * 2 + 1];
 
     /* A1BUF = H(user ":" realm ":" password) */
     gen_md5_init (ctx);
@@ -2795,11 +2791,11 @@
 
     /* RESPONSE_DIGEST = H(A1BUF ":" nonce ":" A2BUF) */
     gen_md5_init (ctx);
-    gen_md5_update (a1buf, MD5_HASHLEN * 2, ctx);
+    gen_md5_update ((unsigned char *)a1buf, MD5_HASHLEN * 2, ctx);
     gen_md5_update ((unsigned char *)":", 1, ctx);
     gen_md5_update ((unsigned char *)nonce, strlen (nonce), ctx);
     gen_md5_update ((unsigned char *)":", 1, ctx);
-    gen_md5_update (a2buf, MD5_HASHLEN * 2, ctx);
+    gen_md5_update ((unsigned char *)a2buf, MD5_HASHLEN * 2, ctx);
     gen_md5_finish (ctx, hash);
     dump_hash (response_digest, hash);
 
Index: src/http.h
===================================================================
--- src/http.h	(revision 0)
+++ src/http.h	(revision 0)
@@ -0,0 +1,41 @@
+/* Declarations for HTTP.
+   Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Wget.
+
+GNU Wget is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+GNU Wget is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Wget; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+In addition, as a special exception, the Free Software Foundation
+gives permission to link the code of its release of Wget with the
+OpenSSL project's "OpenSSL" library (or with modified versions of it
+that use the same license as the "OpenSSL" library), and distribute
+the linked executables.  You must obey the GNU General Public License
+in all respects for all of the code used other than "OpenSSL".  If you
+modify this file, you may extend this exception to your version of the
+file, but you are not obligated to do so.  If you do not wish to do
+so, delete this exception statement from your version.  */
+
+#ifndef HTTP_H
+#define HTTP_H
+
+struct url;
+
+uerr_t http_loop (struct url *, char **, char **, const char *, int *,
+		  struct url *);
+void save_cookies (void);
+void http_cleanup (void);
+time_t http_atotm (const char *);
+
+#endif /* HTTP_H */
Index: src/ftp.c
===================================================================
--- src/ftp.c	(revision 1832)
+++ src/ftp.c	(working copy)
@@ -53,11 +53,6 @@
 /* File where the "ls -al" listing will be saved.  */
 #define LIST_FILENAME ".listing"
 
-extern char ftp_last_respline[];
-
-extern FILE *output_stream;
-extern bool output_stream_regular;
-
 typedef struct
 {
   int st;			/* connection status */
@@ -1308,7 +1303,7 @@
 
 /* Return the directory listing in a reusable format.  The directory
    is specifed in u->dir.  */
-uerr_t
+static uerr_t
 ftp_get_listing (struct url *u, ccon *con, struct fileinfo **f)
 {
   uerr_t err;
Index: src/cookies.c
===================================================================
--- src/cookies.c	(revision 1875)
+++ src/cookies.c	(working copy)
@@ -55,9 +55,7 @@
 #include "utils.h"
 #include "hash.h"
 #include "cookies.h"
-
-/* This should *really* be in a .h file!  */
-time_t http_atotm (const char *);
+#include "http.h"		/* for http_atotm */
 
 /* Declarations of `struct cookie' and the most basic functions. */
 
Index: src/ftp.h
===================================================================
--- src/ftp.h	(revision 1832)
+++ src/ftp.h	(working copy)
@@ -42,7 +42,9 @@
   ST_OS400,
   ST_OTHER
 };
-  
+
+extern char ftp_last_respline[];
+
 uerr_t ftp_response (int, char **);
 uerr_t ftp_login (int, const char *, const char *);
 uerr_t ftp_port (int, int *);
Index: src/ftp-ls.c
===================================================================
--- src/ftp-ls.c	(revision 1832)
+++ src/ftp-ls.c	(working copy)
@@ -44,9 +44,8 @@
 #include "ftp.h"
 #include "url.h"
 #include "convert.h"		/* for html_quote_string prototype */
+#include "retr.h"		/* for output_stream */
 
-extern FILE *output_stream;
-
 /* Converts symbolic permissions to number-style ones, e.g. string
    rwxr-xr-x to 755.  For now, it knows nothing of
    setuid/setgid/sticky.  ACLs are ignored.  */
Index: src/html-url.c
===================================================================
--- src/html-url.c	(revision 1837)
+++ src/html-url.c	(working copy)
@@ -170,8 +170,8 @@
   "action"			/* used by tag_handle_form */
 };
 
-struct hash_table *interesting_tags;
-struct hash_table *interesting_attributes;
+static struct hash_table *interesting_tags;
+static struct hash_table *interesting_attributes;
 
 static void
 init_interesting (void)
Index: src/wget.h
===================================================================
--- src/wget.h	(revision 1840)
+++ src/wget.h	(working copy)
@@ -247,7 +247,7 @@
    using printf ("%0*lx", PTR_FORMAT (p)).  (%p is too unpredictable;
    some implementations prepend 0x, while some don't, and most don't
    0-pad the address.)  */
-#define PTR_FORMAT(p) 2 * sizeof (void *), (unsigned long) (p)
+#define PTR_FORMAT(p) (int) (2 * sizeof (void *)), (unsigned long) (p)
 
 extern const char *exec_name;
 
Index: src/retr.c
===================================================================
--- src/retr.c	(revision 1832)
+++ src/retr.c	(working copy)
@@ -45,6 +45,7 @@
 #include "url.h"
 #include "recur.h"
 #include "ftp.h"
+#include "http.h"
 #include "host.h"
 #include "connect.h"
 #include "hash.h"
Index: src/retr.h
===================================================================
--- src/retr.h	(revision 1832)
+++ src/retr.h	(working copy)
@@ -30,8 +30,12 @@
 #ifndef RETR_H
 #define RETR_H
 
+/* These global vars should be made static to retr.c and exported via
+   functions! */
 extern SUM_SIZE_INT total_downloaded_bytes;
 extern double total_download_time;
+extern FILE *output_stream;
+extern bool output_stream_regular;
 
 /* Flags for fd_read_body. */
 enum {
@@ -57,13 +61,4 @@
 
 void rotate_backups (const char *);
 
-/* Because there's no http.h. */
-
-struct url;
-
-uerr_t http_loop (struct url *, char **, char **, const char *, int *,
-		  struct url *);
-void save_cookies (void);
-
-
 #endif /* RETR_H */
Index: src/recur.c
===================================================================
--- src/recur.c	(revision 1832)
+++ src/recur.c	(working copy)
@@ -48,12 +48,6 @@
 #include "hash.h"
 #include "res.h"
 #include "convert.h"
-
-extern char *version_string;
-extern SUM_SIZE_INT total_downloaded_bytes;
-
-extern struct hash_table *dl_url_file_map;
-extern struct hash_table *downloaded_html_set;
 
 /* Functions for maintaining the URL queue.  */
 
Index: src/log.c
===================================================================
--- src/log.c	(revision 1832)
+++ src/log.c	(working copy)
@@ -769,7 +769,7 @@
 
 /* When SIGHUP or SIGUSR1 are received, the output is redirected
    elsewhere.  Such redirection is only allowed once. */
-enum { RR_NONE, RR_REQUESTED, RR_DONE } redirect_request = RR_NONE;
+static enum { RR_NONE, RR_REQUESTED, RR_DONE } redirect_request = RR_NONE;
 static const char *redirect_request_signal_name;
 
 /* Redirect output to `wget-log'.  */
Index: src/openssl.c
===================================================================
--- src/openssl.c	(revision 1832)
+++ src/openssl.c	(working copy)
@@ -50,7 +50,7 @@
 
 /* Application-wide SSL context.  This is common to all SSL
    connections.  */
-SSL_CTX *ssl_ctx;
+static SSL_CTX *ssl_ctx;
 
 /* Initialize the SSL's PRNG using various methods. */
 
Index: src/main.c
===================================================================
--- src/main.c	(revision 1859)
+++ src/main.c	(working copy)
@@ -51,6 +51,7 @@
 #include "url.h"
 #include "progress.h"		/* for progress_handle_sigwinch */
 #include "convert.h"
+#include "http.h"		/* for save_cookies */
 
 /* On GNU system this will include system-wide getopt.h. */
 #include "getopt.h"
@@ -63,8 +64,6 @@
 
 extern char *version_string;
 
-extern struct cookie_jar *wget_cookie_jar;
-
 static void redirect_output_signal (int);
 
 const char *exec_name;
@@ -123,7 +122,7 @@
   int argtype;			/* for non-standard options */
 };
 
-struct cmdline_option option_data[] =
+static struct cmdline_option option_data[] =
   {
     { "accept", 'A', OPT_VALUE, "accept", -1 },
     { "append-output", 'a', OPT__APPEND_OUTPUT, NULL, required_argument },
@@ -896,9 +895,6 @@
   /* Open the output filename if necessary.  */
   if (opt.output_document)
     {
-      extern FILE *output_stream;
-      extern bool output_stream_regular;
-
       if (HYPHENP (opt.output_document))
 	output_stream = stdout;
       else
Index: src/convert.h
===================================================================
--- src/convert.h	(revision 1832)
+++ src/convert.h	(working copy)
@@ -31,6 +31,7 @@
 #define CONVERT_H
 
 struct hash_table;		/* forward decl */
+extern struct hash_table *dl_url_file_map;
 extern struct hash_table *downloaded_html_set;
 
 enum convert_options {