[totem] Remove some redundant NULL checks
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] Remove some redundant NULL checks
- Date: Sat, 4 Sep 2010 23:53:26 +0000 (UTC)
commit 6891adac18b5ee1a4cd78ab310c244982bc3ec3e
Author: Philip Withnall <philip tecnocode co uk>
Date: Sun Sep 5 00:50:34 2010 +0100
Remove some redundant NULL checks
g_settings_get_string() guarantees that it won't return NULL, so we can
remove some checks for NULL strings. Spotted by
Christian Persch <chpe gnome org>. Closes: bgo#628779
src/plugins/publish/totem-publish.c | 4 ++--
src/plugins/screenshot/totem-screenshot-plugin.c | 2 +-
src/totem-preferences.c | 22 +++++++---------------
src/totem-uri.c | 5 ++---
4 files changed, 12 insertions(+), 21 deletions(-)
---
diff --git a/src/plugins/publish/totem-publish.c b/src/plugins/publish/totem-publish.c
index 7d84cd4..47d1fcf 100644
--- a/src/plugins/publish/totem-publish.c
+++ b/src/plugins/publish/totem-publish.c
@@ -526,12 +526,12 @@ impl_activate (PeasActivatable *plugin)
protocol_name = g_settings_get_string (self->gsettings, "protocol");
service_pattern = g_settings_get_string (self->gsettings, "name-format");
- if (!protocol_name) {
+ if (*protocol_name == '\0') {
protocol_name = g_strdup ("http");
g_settings_set_string (self->gsettings, "protocol", protocol_name);
}
- if (!service_pattern) {
+ if (*service_pattern == '\0') {
service_pattern = g_strdup ("%a of %u on %h");
g_settings_set_string (self->gsettings, "name-format", service_pattern);
}
diff --git a/src/plugins/screenshot/totem-screenshot-plugin.c b/src/plugins/screenshot/totem-screenshot-plugin.c
index a8aa3d6..311e759 100644
--- a/src/plugins/screenshot/totem-screenshot-plugin.c
+++ b/src/plugins/screenshot/totem-screenshot-plugin.c
@@ -323,7 +323,7 @@ totem_screenshot_plugin_setup_file_chooser (const char *filename_format, const c
g_object_unref (settings);
/* Default to the Pictures directory */
- if (path == NULL || path[0] == '\0') {
+ if (*path == '\0') {
g_free (path);
path = totem_pictures_dir ();
/* No pictures dir, then it's the home dir */
diff --git a/src/totem-preferences.c b/src/totem-preferences.c
index fc73fd2..438803e 100644
--- a/src/totem-preferences.c
+++ b/src/totem-preferences.c
@@ -180,23 +180,15 @@ void
visual_menu_changed (GtkComboBox *combobox, Totem *totem)
{
GList *list;
- char *old_name, *name;
+ const gchar *name;
int i;
i = gtk_combo_box_get_active (combobox);
list = bacon_video_widget_get_visualization_list (totem->bvw);
name = g_list_nth_data (list, i);
- old_name = g_settings_get_string (totem->settings, "visualization-name");
-
- if (old_name == NULL || strcmp (old_name, name) != 0)
- {
- g_settings_set_string (totem->settings, "visualization-name", name);
-
- bacon_video_widget_set_visualization (totem->bvw, name);
- }
-
- g_free (old_name);
+ g_settings_set_string (totem->settings, "visualization-name", name);
+ bacon_video_widget_set_visualization (totem->bvw, name);
}
void
@@ -457,7 +449,7 @@ totem_setup_preferences (Totem *totem)
gtk_widget_show (menu);
visual = g_settings_get_string (totem->settings, "visualization-name");
- if (visual == NULL || strcmp (visual, "") == 0) {
+ if (*visual == '\0') {
g_free (visual);
visual = g_strdup ("goom");
}
@@ -517,7 +509,7 @@ totem_setup_preferences (Totem *totem)
gtk_font_button_set_title (GTK_FONT_BUTTON (item),
_("Select Subtitle Font"));
font = g_settings_get_string (totem->settings, "subtitle-font");
- if (font && strcmp (font, "") != 0) {
+ if (*font != '\0') {
gtk_font_button_set_font_name (GTK_FONT_BUTTON (item), font);
bacon_video_widget_set_subtitle_font (totem->bvw, font);
}
@@ -529,7 +521,7 @@ totem_setup_preferences (Totem *totem)
totem_subtitle_encoding_init (GTK_COMBO_BOX (item));
encoding = g_settings_get_string (totem->settings, "subtitle-encoding");
/* Make sure the default is UTF-8 */
- if (encoding == NULL || *encoding == '\0') {
+ if (*encoding == '\0') {
g_free (encoding);
encoding = g_strdup ("UTF-8");
}
@@ -553,7 +545,7 @@ totem_preferences_visuals_setup (Totem *totem)
char *visual;
visual = g_settings_get_string (totem->settings, "visualization-name");
- if (visual == NULL || strcmp (visual, "") == 0) {
+ if (*visual == '\0') {
g_free (visual);
visual = g_strdup ("goom");
}
diff --git a/src/totem-uri.c b/src/totem-uri.c
index f97decd..7104f77 100644
--- a/src/totem-uri.c
+++ b/src/totem-uri.c
@@ -611,9 +611,8 @@ totem_add_subtitle (GtkWindow *parent, const char *uri)
/* Add the last open path as a shortcut */
new_path = g_settings_get_string (settings, "open-uri");
- if (new_path != NULL && *new_path != '\0') {
+ if (*new_path != '\0')
gtk_file_chooser_add_shortcut_folder_uri (GTK_FILE_CHOOSER (fs), new_path, NULL);
- }
g_free (new_path);
/* Try to set the passed path as the current folder */
@@ -672,7 +671,7 @@ totem_add_files (GtkWindow *parent, const char *path)
(GTK_FILE_CHOOSER (fs), path);
} else {
new_path = g_settings_get_string (settings, "open-uri");
- if (new_path != NULL && *new_path != '\0') {
+ if (*new_path != '\0') {
set_folder = gtk_file_chooser_set_current_folder_uri
(GTK_FILE_CHOOSER (fs), new_path);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]