gok r2500 - in trunk: . gok



Author: gerdk
Date: Wed Jul  9 15:42:04 2008
New Revision: 2500
URL: http://svn.gnome.org/viewvc/gok?rev=2500&view=rev

Log:
2008-07-09  Gerd Kohlberger  <gerdk svn gnome org>

	Patch reviewed by David Bolter. Fixes bug #540271.

	* gok/gok-editor.c: (gok_editor_message_filename_bad):
	Don't use a fixed size buffer + sprintf. Long filenames will
	trigger a stack overflow.

	* gok/gok-input.c: (gok_input_open): Fix format warnings and avoid
	a possible segfault if 'input' is NULL.

	* gok/gok-utf8-word-complete.c: (utf8_add_to_list_from_lines):
	Free GError. Use format specifier.

	* gok/gok-spy.c: (gok_spy_append_node): Plug 3 string leaks.

	* gok/gok-composer.c: (gok_composer_branch_textAction):
	Cast long int -> gint.
	
	* gok/main.c: (gok_main_create_window): Cast to GtkWindow.
	(gok_main_display_error) (gok_main_warn): Use format specifier.

	* gok/gok-page-actions.c: (gok_page_actions_button_clicked_del):
	Use format specifier.

	* gok/gok-page-feedbacks.c: (gok_page_feedbacks_button_clicked_d):
	Use format specifier.

	* gok/create-branching-keyboard.c:
	(kbd_file_create): Remove unused code.
	(create_kbd_from_file): Free GError. Use format specifier.

	* gok/command-vertex-data.c:
	* gok/command-vertex.c
	* gok/command-edge-data.c:
	* gok/command-edge.c:
	Use dummy ret vars for fwrite() to avoid unsed_result warnings.



Modified:
   trunk/ChangeLog
   trunk/gok/command-edge-data.c
   trunk/gok/command-edge.c
   trunk/gok/command-vertex-data.c
   trunk/gok/command-vertex.c
   trunk/gok/create-branching-keyboard.c
   trunk/gok/gok-composer.c
   trunk/gok/gok-editor.c
   trunk/gok/gok-input.c
   trunk/gok/gok-page-actions.c
   trunk/gok/gok-page-feedbacks.c
   trunk/gok/gok-spy.c
   trunk/gok/gok-utf8-word-complete.c
   trunk/gok/main.c

Modified: trunk/gok/command-edge-data.c
==============================================================================
--- trunk/gok/command-edge-data.c	(original)
+++ trunk/gok/command-edge-data.c	Wed Jul  9 15:42:04 2008
@@ -78,6 +78,7 @@
 void command_edge_data_dump_binary(const Command_Edge_Data data, FILE *stream)
 {
   const float weight = command_edge_data_get_weight(data);
+  size_t ret;
 
-  fwrite(&weight, float_size, 1, stream);
+  ret = fwrite(&weight, float_size, 1, stream);
 }

Modified: trunk/gok/command-edge.c
==============================================================================
--- trunk/gok/command-edge.c	(original)
+++ trunk/gok/command-edge.c	Wed Jul  9 15:42:04 2008
@@ -101,12 +101,13 @@
   const short keyboard_id_length = (short)strlen(keyboard_id);
   const char *key_id = command_vertex_data_get_key_id(command_vertex_get_vertex_data(command_edge_get_next_vertex(edge)));
   const short key_id_length = (short)strlen(key_id);
+  size_t ret;
 
-  fwrite(&type, short_size, 1, stream);
-  fwrite(&keyboard_id_length, short_size, 1, stream);
-  fwrite(&key_id_length, short_size, 1, stream);
-  fwrite(keyboard_id, char_size, keyboard_id_length, stream);
-  fwrite(key_id, char_size, key_id_length, stream);
+  ret = fwrite(&type, short_size, 1, stream);
+  ret = fwrite(&keyboard_id_length, short_size, 1, stream);
+  ret = fwrite(&key_id_length, short_size, 1, stream);
+  ret = fwrite(keyboard_id, char_size, keyboard_id_length, stream);
+  ret = fwrite(key_id, char_size, key_id_length, stream);
   command_edge_data_dump_binary(command_edge_get_edge_data(edge), stream);
   fflush(stream);
 }

Modified: trunk/gok/command-vertex-data.c
==============================================================================
--- trunk/gok/command-vertex-data.c	(original)
+++ trunk/gok/command-vertex-data.c	Wed Jul  9 15:42:04 2008
@@ -188,10 +188,11 @@
   const char *key_id = command_vertex_data_get_key_id(data);
   const short key_id_length = (short)strlen(key_id);
   const float weight = command_vertex_data_get_weight(data);
+  size_t ret;
 
-  fwrite(&keyboard_id_length, short_size, 1, stream);
-  fwrite(&key_id_length, short_size, 1, stream);
-  fwrite(keyboard_id, char_size, keyboard_id_length, stream);
-  fwrite(key_id, char_size, key_id_length, stream);
-  fwrite(&weight, float_size, 1, stream);
+  ret = fwrite(&keyboard_id_length, short_size, 1, stream);
+  ret = fwrite(&key_id_length, short_size, 1, stream);
+  ret = fwrite(keyboard_id, char_size, keyboard_id_length, stream);
+  ret = fwrite(key_id, char_size, key_id_length, stream);
+  ret = fwrite(&weight, float_size, 1, stream);
 }

Modified: trunk/gok/command-vertex.c
==============================================================================
--- trunk/gok/command-vertex.c	(original)
+++ trunk/gok/command-vertex.c	Wed Jul  9 15:42:04 2008
@@ -181,8 +181,9 @@
 void command_vertex_dump_binary(const Command_Vertex vertex, FILE *stream)
 {
   static const short type = (short)STORAGE_TYPE_COMMAND_VERTEX;
+  size_t ret;
 
-  fwrite(&type, short_size, 1, stream);
+  ret = fwrite(&type, short_size, 1, stream);
   command_vertex_data_dump_binary(command_vertex_get_vertex_data(vertex), stream);
   fflush(stream);
 }

Modified: trunk/gok/create-branching-keyboard.c
==============================================================================
--- trunk/gok/create-branching-keyboard.c	(original)
+++ trunk/gok/create-branching-keyboard.c	Wed Jul  9 15:42:04 2008
@@ -76,7 +76,6 @@
 		       "<GOK:keyboard name=\"", name, "\" wordcompletion=\"yes\">\n", NULL);
     g_io_channel_write_chars (kbd->io, buf, -1, &bytz, NULL);
     g_free (buf);
-    buf = g_strconcat ("\t<GOK:key ");
     g_io_channel_write_chars (kbd->io, "\t<GOK:key left = \"0\" right = \"1\" top = \"0\" bottom = \"1\" type=\"branchBack\">\n", -1, &bytz, NULL);
     g_io_channel_write_chars (kbd->io, "\t\t<GOK:label type = \"branchBack\">\345\220\216\351\200\200</GOK:label>\n", -1, &bytz, NULL);
     g_io_channel_write_chars (kbd->io, "\t</GOK:key>\n", -1, &bytz, NULL);
@@ -157,7 +156,8 @@
 	{
 	    if (error != NULL) 
 	    {
-		g_message (error->message);
+		g_message ("%s", error->message);
+		g_clear_error (&error);
 	    }
 	    continue;
 	}

Modified: trunk/gok/gok-composer.c
==============================================================================
--- trunk/gok/gok-composer.c	(original)
+++ trunk/gok/gok-composer.c	Wed Jul  9 15:42:04 2008
@@ -236,7 +236,7 @@
 	}
 
 	currentCaretPos = AccessibleText_getCaretOffset( paccessibleText );
-	fprintf (stderr, "starting caret position is %d\n", currentCaretPos);
+	fprintf (stderr, "starting caret position is %d\n", (gint) currentCaretPos);
 	if (currentCaretPos < 0)
 	{
 		currentCaretPos = 0;
@@ -359,7 +359,7 @@
 			currentCaretPos = rangeEnd;
 		returncode = AccessibleText_setCaretOffset (paccessibleText,
 							    currentCaretPos);
-		fprintf (stderr, "setting caret position to %d\n", currentCaretPos);
+		fprintf (stderr, "setting caret position to %d\n", (gint) currentCaretPos);
 	}
 	if ((command->type == TEXT_COMMAND_SELECT) || (select_mode == TRUE)) {
 		if (command->type == TEXT_COMMAND_SELECT) {

Modified: trunk/gok/gok-editor.c
==============================================================================
--- trunk/gok/gok-editor.c	(original)
+++ trunk/gok/gok-editor.c	Wed Jul  9 15:42:04 2008
@@ -1047,19 +1047,21 @@
 void gok_editor_message_filename_bad (gchar* Filename)
 {
 	GtkWidget* pDialog;
-	gchar buffer[101];
+	gchar *buffer;
 
-	sprintf (buffer, _("This is not a valid keyboard filename:\n%s"), Filename);
+	buffer = g_strdup_printf (_("This is not a valid keyboard filename:\n%s"),
+				  Filename);
 
 	pDialog = gtk_message_dialog_new (GTK_WINDOW(m_pWindowEditor),
 				GTK_DIALOG_DESTROY_WITH_PARENT,
 				GTK_MESSAGE_ERROR,
 				GTK_BUTTONS_CLOSE,
-				_(buffer));
+				"%s", buffer);
 
 	gtk_window_set_title (GTK_WINDOW (pDialog), _("Keyboard Filename Invalid"));
 	gtk_dialog_run (GTK_DIALOG (pDialog));
 	gtk_widget_destroy (pDialog);
+	g_free (buffer);
 }
 
 /**

Modified: trunk/gok/gok-input.c
==============================================================================
--- trunk/gok/gok-input.c	(original)
+++ trunk/gok/gok-input.c	Wed Jul  9 15:42:04 2008
@@ -239,13 +239,15 @@
 static gboolean   
 gok_input_open (GokInput *input)
 {
-  GtkWidget *window = gok_main_get_main_window ();
-  if (input) 
-      input->open = FALSE;
+  GtkWidget *window;
 
-#ifdef HAVE_XINPUT  
+  g_return_val_if_fail (input != NULL, FALSE);
+  input->open = FALSE;
+
+#ifdef HAVE_XINPUT
+  window = gok_main_get_main_window ();
   if (window && window->window && 
-      input && input->info && (input->info->use == IsXExtensionDevice))
+      input->info && (input->info->use == IsXExtensionDevice))
     {
       gdk_error_trap_push ();
       input->device = XOpenDevice(GDK_WINDOW_XDISPLAY (window->window), 
@@ -254,9 +256,9 @@
 	  input->open = TRUE;
     }
 #endif
-  if (!input && !input->open)
-    g_warning ("could not open device %s", input);
-  
+  if (input->name && !input->open)
+    g_warning ("could not open device %s", input->name);
+
   return input->open;
 }
 

Modified: trunk/gok/gok-page-actions.c
==============================================================================
--- trunk/gok/gok-page-actions.c	(original)
+++ trunk/gok/gok-page-actions.c	Wed Jul  9 15:42:04 2008
@@ -555,7 +555,7 @@
 			GTK_DIALOG_DESTROY_WITH_PARENT,
 			GTK_MESSAGE_QUESTION,
 			GTK_BUTTONS_YES_NO,
-			buffer);
+			"%s", buffer);
 	
 	gtk_window_set_title (GTK_WINDOW (pDialog), _("GOK Delete Action"));
 	result = gtk_dialog_run (GTK_DIALOG (pDialog));

Modified: trunk/gok/gok-page-feedbacks.c
==============================================================================
--- trunk/gok/gok-page-feedbacks.c	(original)
+++ trunk/gok/gok-page-feedbacks.c	Wed Jul  9 15:42:04 2008
@@ -644,7 +644,7 @@
 			GTK_DIALOG_DESTROY_WITH_PARENT,
 			GTK_MESSAGE_QUESTION,
 			GTK_BUTTONS_YES_NO,
-			buffer);
+			"%s", buffer);
 	
 	gtk_window_set_title (GTK_WINDOW (pDialog), _("GOK Delete Feedback"));
 	result = gtk_dialog_run (GTK_DIALOG (pDialog));

Modified: trunk/gok/gok-spy.c
==============================================================================
--- trunk/gok/gok-spy.c	(original)
+++ trunk/gok/gok-spy.c	Wed Jul  9 15:42:04 2008
@@ -1958,7 +1958,7 @@
 					    firstcellname = NULL;
 					}
 					/* use row index */
-					pName = g_strdup_printf ("%d",irow);
+					pName = g_strdup_printf ("%d", (gint) irow);
 				    }
 				}
 				if (rowstring) SPI_freeString (rowstring);
@@ -1968,19 +1968,18 @@
 					Accessible_unref (col);
 				}
 				if (colstring) {
-				    gchar* free_string = pName;
 				    if (strlen (colstring)) {
+					gchar *free_string = pName;
 					/* use header name */
 					pName = g_strconcat (pName, " ", colstring, NULL);
 					g_free (free_string);
 				    }
-				    else
-					SPI_freeString (colstring);
+				    SPI_freeString (colstring);
 				}
 				else {
 				    gchar *free_string = pName;
 				    /* use col index */
-				    pName = g_strconcat (pName, " ", g_strdup_printf ("%d",icol), NULL);
+				    pName = g_strdup_printf ("%s %d", pName, (gint) icol);
 				    g_free (free_string);
 				}
 				AccessibleTable_unref (table);

Modified: trunk/gok/gok-utf8-word-complete.c
==============================================================================
--- trunk/gok/gok-utf8-word-complete.c	(original)
+++ trunk/gok/gok-utf8-word-complete.c	Wed Jul  9 15:42:04 2008
@@ -644,7 +644,10 @@
 				gsize bytes_read, bytes_written;
 				string = g_convert (string, -1, "UTF-8", "ISO-8859-1", &bytes_read, &bytes_written, &error);
 				if (error)
-					g_warning (error->message);
+				{
+					g_warning ("%s", error->message);
+					g_error_free (error);
+				}
 			}
 			if (string)
 			{

Modified: trunk/gok/main.c
==============================================================================
--- trunk/gok/main.c	(original)
+++ trunk/gok/main.c	Wed Jul  9 15:42:04 2008
@@ -1860,7 +1860,7 @@
 			     "signal::destroy", on_window1_destroy, NULL,
 			     NULL);
 
-	gtk_window_set_keep_above (window1, TRUE); /* please! */
+	gtk_window_set_keep_above (GTK_WINDOW (window1), TRUE); /* please! */
 	
 	g_set_application_name (_("GOK"));
 	gtk_window_set_default_icon_name ("gok");
@@ -1869,7 +1869,6 @@
 	m_OurResizeHeight = 100;
 	gtk_window_set_default_size (GTK_WINDOW (window1), m_OurResizeWidth, m_OurResizeHeight);
 
-
 	fixed1 = gtk_fixed_new ();
 	gtk_widget_ref (fixed1);
 	gtk_object_set_data_full (GTK_OBJECT (window1), "fixed1", fixed1,
@@ -2774,7 +2773,7 @@
 		GTK_DIALOG_DESTROY_WITH_PARENT,
 		GTK_MESSAGE_ERROR,
 		GTK_BUTTONS_CLOSE,
-		buffer);
+		"%s", buffer);
 	
 	gtk_window_set_title (GTK_WINDOW (pDialog), _("GOK Fatal Error"));
 	gtk_dialog_run (GTK_DIALOG (pDialog));
@@ -3189,7 +3188,7 @@
 				GTK_DIALOG_DESTROY_WITH_PARENT,
 				GTK_MESSAGE_WARNING, 
 				GTK_BUTTONS_NONE,			
-				message);
+				"%s", message);
 			
 			button = gtk_button_new_from_stock(GTK_STOCK_HELP);
 			gtk_container_add (GTK_CONTAINER (GTK_DIALOG(_corepointer_warning)->action_area),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]