[ghex] Fix compiler warnings - Fixes Bug 570688 (incorporates feedback from Daniel Macks)



commit 5c4e0e0cb24ab899b9bfb1d31e7b8bf0fd21bab2
Author: Martin Olsson <mnemo minimum se>
Date:   Wed Jan 27 20:27:08 2010 +0100

    Fix compiler warnings - Fixes Bug 570688 (incorporates feedback from Daniel Macks)

 src/gtkhex.c       |   20 ++++++++++++++++----
 src/gtkhex.h       |    2 +-
 src/hex-document.c |    5 ++++-
 src/ui.c           |    4 +++-
 4 files changed, 24 insertions(+), 7 deletions(-)
---
diff --git a/src/gtkhex.c b/src/gtkhex.c
index b28a355..15c0e4d 100644
--- a/src/gtkhex.c
+++ b/src/gtkhex.c
@@ -439,7 +439,11 @@ static void render_hex_highlights(GtkHex *gh, gint cursor_line)
 			el = curHighlight->end_line;
 
 			if (curHighlight->style)
-				gtk_style_attach(curHighlight->style, gh->xdisp->window);
+			{
+				// For an explanation of "style = gtk_style_attach(style, window)" see:
+				// http://library.gnome.org/devel/gtk/unstable/GtkStyle.html#gtk-style-attach
+				curHighlight->style = gtk_style_attach(curHighlight->style, gh->xdisp->window);
+			}
 			state = (gh->active_view == VIEW_HEX)?GTK_STATE_ACTIVE:GTK_STATE_INSENSITIVE;
 			if (cursor_line == sl)
 			{
@@ -517,7 +521,11 @@ static void render_ascii_highlights(GtkHex *gh, gint cursor_line)
 			el = curHighlight->end_line;
 
 			if (curHighlight->style)
-				gtk_style_attach(curHighlight->style, gh->adisp->window);
+			{
+				// For an explanation of "style = gtk_style_attach(style, window)" see:
+				// http://library.gnome.org/devel/gtk/unstable/GtkStyle.html#gtk-style-attach
+				curHighlight->style = gtk_style_attach(curHighlight->style, gh->adisp->window);
+			}
 			state = (gh->active_view == VIEW_ASCII)?GTK_STATE_ACTIVE:GTK_STATE_INSENSITIVE;
 			if (cursor_line == sl)
 			{
@@ -556,7 +564,11 @@ static void render_ascii_highlights(GtkHex *gh, gint cursor_line)
 								   gh->cpl*gh->char_width, gh->char_height);
 			}
 			if (curHighlight->style)
-				gtk_style_attach(curHighlight->style, gh->adisp->window);
+			{
+				// For an explanation of "style = gtk_style_attach(style, window)" see:
+				// http://library.gnome.org/devel/gtk/unstable/GtkStyle.html#gtk-style-attach
+				curHighlight->style = gtk_style_attach(curHighlight->style, gh->adisp->window);
+			}
 		}
 		curHighlight = curHighlight->next;
 		while (curHighlight == NULL && nextList)
@@ -2253,7 +2265,7 @@ void gtk_hex_set_group_type(GtkHex *gh, guint gt) {
 /*
  * sets font for displaying data
  */
-void gtk_hex_set_font(GtkHex *gh, const PangoFontMetrics *font_metrics, const PangoFontDescription *font_desc) {
+void gtk_hex_set_font(GtkHex *gh, PangoFontMetrics *font_metrics, const PangoFontDescription *font_desc) {
 	g_return_if_fail(gh != NULL);
 	g_return_if_fail(GTK_IS_HEX(gh));
 
diff --git a/src/gtkhex.h b/src/gtkhex.h
index 155c40f..da8ee96 100644
--- a/src/gtkhex.h
+++ b/src/gtkhex.h
@@ -143,7 +143,7 @@ void gtk_hex_set_group_type(GtkHex *, guint);
 
 void gtk_hex_set_starting_offset(GtkHex *, gint);
 void gtk_hex_show_offsets(GtkHex *, gboolean);
-void gtk_hex_set_font(GtkHex *, const PangoFontMetrics *, const PangoFontDescription *);
+void gtk_hex_set_font(GtkHex *, PangoFontMetrics *, const PangoFontDescription *);
 
 void gtk_hex_set_insert_mode(GtkHex *, gboolean);
 
diff --git a/src/hex-document.c b/src/hex-document.c
index cbd2361..0a8f9cd 100644
--- a/src/hex-document.c
+++ b/src/hex-document.c
@@ -658,7 +658,10 @@ hex_document_read(HexDocument *doc)
 		return FALSE;
 
 	doc->gap_size = doc->buffer_size - doc->file_size;
-	fread(doc->buffer + doc->gap_size, 1, doc->file_size, file);
+	if(fread(doc->buffer + doc->gap_size, 1, doc->file_size, file) != doc->file_size)
+	{
+		g_return_val_if_reached(FALSE);
+	}
 	doc->gap_pos = doc->buffer;
 	fclose(file);
 	undo_stack_free(doc);
diff --git a/src/ui.c b/src/ui.c
index fa8c0ea..199f2b8 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -236,7 +236,7 @@ about_response_cb(GtkDialog *dialog, gint response_id, gpointer user_data)
     switch (response_id) {
 		case GTK_RESPONSE_CLOSE:
 		case GTK_RESPONSE_CANCEL:
-			gtk_widget_destroy (dialog);
+			gtk_widget_destroy (GTK_WIDGET(dialog));
 			about = NULL;
 			break;
 		default:
@@ -917,6 +917,7 @@ display_error_dialog (GHexWindow *win, const gchar *msg)
 			GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
 			GTK_MESSAGE_ERROR,
 			GTK_BUTTONS_OK,
+			"%s",
 			msg);
 
 	gtk_dialog_set_default_response (GTK_DIALOG (error_dlg), GTK_RESPONSE_OK);
@@ -942,6 +943,7 @@ display_info_dialog (GHexWindow *win, const gchar *msg, ...)
 			GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
 			GTK_MESSAGE_ERROR,
 			GTK_BUTTONS_OK,
+			"%s",
 			real_msg);
 	g_free(real_msg);
 



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