Description: Fix some compiler warnings.
Forwarded: nowhere-to
Author: Peter Pentchev <roam@ringlet.net>
Last-Update: 2011-03-10

--- a/gtkcookie.c
+++ b/gtkcookie.c
@@ -43,13 +43,21 @@
 
 #define COOKIE_COLUMNS 8
 
+#ifndef __unused
+#ifdef __GNUC__
+#define __unused __attribute__((unused))
+#else
+#define __unused
+#endif
+#endif
+
 /*
   "The static declaration, applied to an external variable or function,
   limits the scope of that object to the rest of the source file being
   compiled."  -- K & R, p. 83
 */
 
-int intcmp(const char *s1, const char *s2) {
+static int intcmp(const char *s1, const char *s2) {
     double v1, v2;
 
     v1 = atof(s1);
@@ -242,7 +250,7 @@
 static void show_about_dialog_box(GtkWidget *calling_widget, gpointer func_data);
 
 /* show an error dialogue box, with the following message */
-static void show_error_dialog_box (gchar *message);
+static void show_error_dialog_box (const gchar *message);
 
 /* FILE SELECTION AND SAVE FUNCTIONS */
 
@@ -328,7 +336,7 @@
 /* static gchar *glbl_netscape_dot_dir_str = NULL; netscape dot directory */
 static FILE *glbl_cookie_FILE = NULL;
     
-static gchar *glbl_cookie_titles_str[] = {
+static const gchar *glbl_cookie_titles_str[] = {
     "Domain",
     "Suffix",
     "Path",
@@ -428,7 +436,7 @@
     glbl_cookie_xpm = gdk_pixmap_create_from_xpm_d (glbl_main_window->window,
 						    &glbl_cookie_xpm_mask, 
 						    transparent, 
-						    cookiepic);
+						    (gchar **)(void *)cookiepic);
 
     gdk_window_set_icon(glbl_main_window->window, NULL,
 			glbl_cookie_xpm, glbl_cookie_xpm);
@@ -756,7 +764,7 @@
 }
 
 
-static void save_file(GtkWidget *calling_widget, gpointer func_data) {
+static void save_file(GtkWidget *calling_widget __unused, gpointer func_data __unused) {
     if (glbl_selected_filename_str == NULL) {
 	/* show_save_as_dialog_box, when called as a callback,
 	   takes a pointer to the calling widget, and a pointer
@@ -814,7 +822,7 @@
     fclose(glbl_cookie_FILE);
 }
 
-static void show_about_dialog_box(GtkWidget *calling_widget, gpointer func_data) {
+static void show_about_dialog_box(GtkWidget *calling_widget __unused, gpointer func_data __unused) {
     static GtkWidget *about_window = NULL;
     GtkWidget *box1;
     GtkWidget *about_text_label;
@@ -856,7 +864,7 @@
 }
 
 static void
-show_find_dialog_box (GtkWidget* wdg, gpointer data) {
+show_find_dialog_box (GtkWidget* wdg __unused, gpointer data __unused) {
 	static GtkWidget *search_dlg = NULL;
     GtkWidget *box1;
     GtkWidget *hbox2;
@@ -956,7 +964,7 @@
     }
 }
 
-static void show_error_dialog_box (gchar *message) {
+static void show_error_dialog_box (const gchar *message) {
     static GtkWidget *error_window = NULL;
     GtkWidget *box1;
     GtkWidget *about_text_label;
@@ -1007,14 +1015,14 @@
     glbl_clist_rows = 0;
 }
 
-static void remove_selected_row_from_glbl_clist(GtkWidget *calling_widget, gpointer func_data) {
+static void remove_selected_row_from_glbl_clist(GtkWidget *calling_widget __unused, gpointer func_data __unused) {
     gtk_clist_remove (GTK_CLIST (glbl_clist), glbl_clist_selected_row);
     glbl_clist_rows--;
 }
 
-static void sort_by_column_glbl_clist (GtkWidget *clist,
+static void sort_by_column_glbl_clist (GtkWidget *clist __unused,
 			 gint sort_column, 
-			 GdkEventButton * bevent) {
+			 GdkEventButton * bevent __unused) {
 
     /* if the sort_column is the human readable date,
        make sort_comumn equal the numeric date column,
@@ -1099,7 +1107,7 @@
 
 static void select_clist (GtkWidget *clist,
 	 	   gint row, 
-		   gint column, 
+		   gint column __unused,
 		   GdkEventButton * bevent) {
     
     gchar *tmp_cookie[COOKIE_COLUMNS];
@@ -1152,7 +1160,7 @@
        4. scroll the glbl_clist so that the new, selected cookie is visible
        5. call the double-click function that brings up the cookie edit
        window */
-    static gchar *text[] = {
+    static const gchar *text[] = {
 	"url.com",
 	"TRUE",
 	"/",
@@ -1163,7 +1171,7 @@
 	"Thu Jan  1 00:00:00 1970"
     };
 
-    gtk_clist_insert (GTK_CLIST(glbl_clist), glbl_clist_selected_row, text);
+    gtk_clist_insert (GTK_CLIST(glbl_clist), glbl_clist_selected_row, (gchar **)(void *)text);
     glbl_clist_rows++;
     glbl_last_sorted_column = -1;  /* because we just added
 				      a new row, no columns
@@ -1183,7 +1191,7 @@
 
     /* create GtkCList here so we have a pointer to throw at the 
      * button callbacks -- more is done with it later */
-    glbl_clist = gtk_clist_new_with_titles (COOKIE_COLUMNS, glbl_cookie_titles_str);
+    glbl_clist = gtk_clist_new_with_titles (COOKIE_COLUMNS, (gchar **)(void *)glbl_cookie_titles_str);
 
     /* 
      * the rest of the glbl_clist configuration
@@ -1566,7 +1574,7 @@
  * GtkEntry
  */
 
-static void show_edit_dialog_box (GtkWidget *calling_widget, gpointer func_data) {
+static void show_edit_dialog_box (GtkWidget *calling_widget __unused, gpointer func_data __unused) {
     static GtkWidget *window = NULL;
     GtkWidget *box1;
     GtkWidget *box2;
@@ -1856,7 +1864,7 @@
 
 
 static void change_callback(GtkWidget *entry, gpointer func_data) {
-    gchar *entry_text;
+    const gchar *entry_text;
     int i;  /* the number of the cookie column */
     size_t field_length;
 
@@ -1877,7 +1885,7 @@
 
 
 static void change_time_callback(GtkWidget *entry, gpointer func_data) {
-    gchar *entry_text;
+    const gchar *entry_text;
     int i;  /* the number of the cookie column */
     size_t field_length;
 
@@ -1917,9 +1925,9 @@
 static void change_tf_callback(GtkWidget *toggle_button, gpointer func_data) {
     int i;  /* the number of the cookie column */
     size_t field_length;
-    gchar *True = "TRUE";
-    gchar *False = "FALSE";
-    gchar *Bool = NULL;
+    const gchar *True = "TRUE";
+    const gchar *False = "FALSE";
+    const gchar *Bool = NULL;
     
     i = *(int *) func_data;
 
@@ -1939,7 +1947,7 @@
 }
 
 /* static void update_clist(GtkWidget *clist, gpointer window) { */
-static void update_glbl_clist(GtkWidget *calling_widget,
+static void update_glbl_clist(GtkWidget *calling_widget __unused,
 			      GtkWidget *edit_win_to_destroy) {
     int column;
     for (column = 0; column < COOKIE_COLUMNS; column++) {
@@ -1959,9 +1967,9 @@
 /* FILE SELECTION STUFF */
 
 
-static void file_selection_ok (GtkWidget *w, GtkFileSelection *fs) {
+static void file_selection_ok (GtkWidget *w __unused, GtkFileSelection *fs) {
     size_t length;
-    gchar *filename;
+    const gchar *filename;
     filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs));
     if (glbl_selected_filename_str != NULL) {
 	free(glbl_selected_filename_str);
@@ -1978,7 +1986,7 @@
     populate_glbl_clist();
 }
 
-static void show_open_file_dialog_box (GtkWidget *calling_widget, gpointer func_data) {
+static void show_open_file_dialog_box (GtkWidget *calling_widget __unused, gpointer func_data __unused) {
     static GtkWidget *window = NULL;
 
     if (!window) {
@@ -2009,7 +2017,7 @@
 }
 
 
-static void show_save_as_dialog_box (GtkWidget *calling_widget, gpointer func_data) {
+static void show_save_as_dialog_box (GtkWidget *calling_widget __unused, gpointer func_data __unused) {
     static GtkWidget *window = NULL;
 
     if (!window) {
@@ -2043,9 +2051,9 @@
 }
 
 
-static void save_as_ok (GtkWidget *w, GtkFileSelection *fs) {
+static void save_as_ok (GtkWidget *w __unused, GtkFileSelection *fs) {
     size_t length;
-    gchar *filename;
+    const gchar *filename;
     filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs));
     if (glbl_selected_filename_str != NULL) {
 	free(glbl_selected_filename_str);  /* don't I set to null as well? 55555 */
@@ -2106,17 +2114,18 @@
 }
 
 static void
-search (GtkWidget* wdg, gpointer data) {
+search (GtkWidget* wdg __unused, gpointer data) {
     gint row;
     gint column;
-	gchar *needle, *cell_contents;
+    const gchar *needle;
+    gchar *cell_contents;
 
     /* time to try to use gstrings, methinks... */
     /* oooh, gstrings are sexy! */
     GString *cell_str;  /* the string from a cell in the clist */
     GString *find_str;  /* the string in the "find" text entry box */
 
-	needle = (gchar*) gtk_entry_get_text (GTK_ENTRY (data));
+	needle = gtk_entry_get_text (GTK_ENTRY (data));
 	if (!strlen (needle)) {
 		return;
 	}
@@ -2185,14 +2194,14 @@
 }
 
 static void
-clear_search (GtkWidget* wdg, gpointer data) {
+clear_search (GtkWidget* wdg __unused, gpointer data) {
 	gtk_entry_set_text (GTK_ENTRY (data), "");
     /* the last found row is rendered invalid when the user clears
        the text box, so reset that variable to -1 */
     glbl_last_found_row = -1;
 }
 
-static void reset_last_found_row(GtkWidget *calling_widget, gpointer func_data) {
+static void reset_last_found_row(GtkWidget *calling_widget __unused, gpointer func_data __unused) {
     glbl_last_found_row = -1;
 }
 
@@ -2328,7 +2337,7 @@
 
 /* set case sensitive searching TRUE/FALSE */
 /* (held in the global variable glbl_search_case_sensitive) */
-static void set_tf_case_sensitive_search(GtkWidget *toggle_button, gpointer func_data) {
+static void set_tf_case_sensitive_search(GtkWidget *toggle_button, gpointer func_data __unused) {
     if (GTK_TOGGLE_BUTTON (toggle_button)->active) {
 	glbl_search_case_sensitive = TRUE;
     } else {
@@ -2349,7 +2358,7 @@
 }
 
 
-gint handle_keypress_in_edit_win(GtkWidget *edit_window, GdkEventKey *event, gpointer func_data) {
+gint handle_keypress_in_edit_win(GtkWidget *edit_window, GdkEventKey *event, gpointer func_data __unused) {
     if (event->keyval == GDK_Return) {
 	/* note how the first arg below is NULL. update_glbl_clist
 	   often gets called as a callback function, so a pointer to
@@ -2367,7 +2376,7 @@
 }
 
 
-gint handle_keypress_in_main_win(GtkWidget *calling_widget, GdkEventKey *event, gpointer func_data) {
+gint handle_keypress_in_main_win(GtkWidget *calling_widget __unused, GdkEventKey *event, gpointer func_data __unused) {
     if (event->keyval == GDK_Delete) {
 	/* note arg1 below is null, because with callback functions,
 	   arg1 is automatically populated with a pointer to the
--- a/cookie.xpm
+++ b/cookie.xpm
@@ -1,5 +1,5 @@
 /* XPM */
-static char *cookiepic[] = {
+static const char *cookiepic[] = {
 /* width height num_colors chars_per_pixel */
 "    50    50      137            2",
 /* colors */
--- a/getline.c
+++ b/getline.c
@@ -41,7 +41,7 @@
        it runs out of space */
     const size_t alloc_length = 1024;
     size_t chars_read_from_file_line = 0;
-    gchar next_char = '\0';
+    int next_char = '\0';
 
     while (next_char != '\n' && next_char != EOF) {
 	next_char = fgetc(filehandle);
@@ -64,7 +64,7 @@
 		line_length += alloc_length;
 	    }
 	    /* finally, we can append the char! */
-	    line[chars_read_from_file_line - 1] = next_char;
+	    line[chars_read_from_file_line - 1] = (gchar)next_char;
 	    /* don't forget the terminating null, which we have
 	       just overwritten with next_char! The math above
 	       should always be leaving me enough memory for that
