summaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2008-09-07 17:06:39 +0000
committerjstebbins <[email protected]>2008-09-07 17:06:39 +0000
commitb97863af3eb0b376403de71d89b070d65b6bbe9b (patch)
tree50d537dbb11c6f1ebd3febf095dc3932401563a6 /gtk
parent5917f628bf5aa7d6c19aa4bb67588ef064dc709c (diff)
LinGui: Fix several strict-aliasing warnings and a null pointer dereference
that can happen if preferences don't yet exist and your running the app over an ssh session. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1673 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk')
-rw-r--r--gtk/src/callbacks.c5
-rw-r--r--gtk/src/hb-backend.c7
-rw-r--r--gtk/src/presets.c69
-rw-r--r--gtk/src/values.c5
4 files changed, 67 insertions, 19 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c
index ff07928dc..a4f7af21c 100644
--- a/gtk/src/callbacks.c
+++ b/gtk/src/callbacks.c
@@ -196,7 +196,10 @@ ghb_check_all_depencencies(signal_user_data_t *ud)
g_debug("ghb_check_all_depencencies ()");
ghb_dict_iter_init(&iter, rev_map);
- while (g_hash_table_iter_next(&iter, (gpointer*)&dep_name, (gpointer*)&value))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&dep_name, (gpointer*)(void*)&value))
{
gboolean sensitive;
dep_object = gtk_builder_get_object (ud->builder, dep_name);
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index 8054320e5..44ca2346d 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -688,16 +688,15 @@ ghb_get_title_number(gint titleindex)
{
hb_list_t * list;
hb_title_t * title;
- hb_audio_config_t *audio = NULL;
- if (h_scan == NULL) return 1;
+ if (h_scan == NULL) return 1;
list = hb_get_titles( h_scan );
if( !hb_list_count( list ) )
{
/* No valid title, stop right there */
- return NULL;
+ return 1;
}
- title = hb_list_item( list, titleindex );
+ title = hb_list_item( list, titleindex );
if (title == NULL) return 1; // Bad titleindex
return title->index;
}
diff --git a/gtk/src/presets.c b/gtk/src/presets.c
index 8f032d819..9052e1ec7 100644
--- a/gtk/src/presets.c
+++ b/gtk/src/presets.c
@@ -213,7 +213,10 @@ init_settings_from_dict(
GValue *gval, *val;
ghb_dict_iter_init(&iter, internal);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&gval))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
{
val = NULL;
if (dict)
@@ -259,7 +262,10 @@ init_ui_from_dict(
GValue *gval, *val;
ghb_dict_iter_init(&iter, internal);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&gval))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
{
val = NULL;
if (dict)
@@ -427,7 +433,10 @@ ghb_prefs_to_ui(signal_user_data_t *ud)
// then update the ui.
internal = plist_get_dict(internalPlist, "Initialization");
ghb_dict_iter_init(&iter, internal);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&gval))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
{
ghb_ui_update(ud, key, gval);
}
@@ -435,7 +444,10 @@ ghb_prefs_to_ui(signal_user_data_t *ud)
dict = plist_get_dict(prefsPlist, "Preferences");
internal = plist_get_dict(internalPlist, "Preferences");
ghb_dict_iter_init(&iter, internal);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&gval))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
{
const GValue *value = NULL;
if (dict)
@@ -446,7 +458,10 @@ ghb_prefs_to_ui(signal_user_data_t *ud)
}
internal = plist_get_dict(internalPlist, "Preferences");
ghb_dict_iter_init(&iter, internal);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&gval))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
{
const GValue *value = NULL;
if (dict)
@@ -497,7 +512,10 @@ ghb_prefs_save(GValue *settings)
pref_dict = plist_get_dict(prefsPlist, "Preferences");
if (pref_dict == NULL) return;
ghb_dict_iter_init(&iter, dict);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&value))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&value))
{
value = ghb_settings_get_value(settings, key);
if (value != NULL)
@@ -545,21 +563,30 @@ ghb_settings_init(signal_user_data_t *ud)
// then update the ui.
internal = plist_get_dict(internalPlist, "Initialization");
ghb_dict_iter_init(&iter, internal);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&gval))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
{
ghb_settings_set_value(ud->settings, key, gval);
}
internal = plist_get_dict(internalPlist, "Presets");
ghb_dict_iter_init(&iter, internal);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&gval))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
{
ghb_settings_set_value(ud->settings, key, gval);
}
internal = plist_get_dict(internalPlist, "Preferences");
ghb_dict_iter_init(&iter, internal);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&gval))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
{
ghb_settings_set_value(ud->settings, key, gval);
}
@@ -587,11 +614,18 @@ ghb_prefs_load(signal_user_data_t *ud)
// Get defaults from internal defaults
ghb_dict_iter_init(&iter, internal);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&gval))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
{
ghb_dict_insert(dict, g_strdup(key), ghb_value_dup(gval));
}
const gchar *dir = g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS);
+ if (dir == NULL)
+ {
+ dir = ".";
+ }
ghb_dict_insert(dict,
g_strdup("destination_dir"), ghb_value_dup(ghb_string_value(dir)));
store_plist(prefsPlist, "preferences");
@@ -613,7 +647,10 @@ ghb_presets_reload(signal_user_data_t *ud)
GValue *orig_dict;
ghb_dict_iter_init(&std_iter, std_dict);
- while (g_hash_table_iter_next(&std_iter, (gpointer*)&name, (gpointer*)&orig_dict))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &std_iter, (gpointer*)(void*)&name, (gpointer*)(void*)&orig_dict))
{
GHashTableIter iter;
gchar *key;
@@ -622,7 +659,10 @@ ghb_presets_reload(signal_user_data_t *ud)
dict = ghb_dict_value_new();
ghb_dict_insert(presetsPlist, g_strdup(name), dict);
ghb_dict_iter_init(&iter, orig_dict);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&value))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&value))
{
ghb_dict_insert(dict, g_strdup(key), ghb_value_dup(value));
}
@@ -702,7 +742,10 @@ ghb_settings_save(signal_user_data_t *ud, const gchar *name)
internal = plist_get_dict(internalPlist, "Presets");
ghb_dict_iter_init(&iter, internal);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&value))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&value))
{
if (!autoscale)
{
diff --git a/gtk/src/values.c b/gtk/src/values.c
index 8ef3bf365..b6be28af4 100644
--- a/gtk/src/values.c
+++ b/gtk/src/values.c
@@ -528,7 +528,10 @@ dict_copy(gpointer boxed)
dict_delete_key, dict_delete_value);
g_hash_table_iter_init(&iter, dict);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&gval))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
{
g_hash_table_insert(copy, g_strdup(key), ghb_value_dup(gval));
}