From b4c01b4ecfc640af3d420b1358e36da0e7254a4a Mon Sep 17 00:00:00 2001 From: Antoine Fontaine <antoine.fontaine@epfl.ch> Date: Sun, 4 Aug 2019 12:46:55 +0200 Subject: [PATCH] Readability changes --- src/gui-window.c | 2 +- src/moodle-provider.c | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/gui-window.c b/src/gui-window.c index 8a0d2e2..32b5e62 100644 --- a/src/gui-window.c +++ b/src/gui-window.c @@ -141,7 +141,7 @@ gui_window_key_pressed_cb (GtkWidget *sender, if (self->course_count > 1) { // that's a little hackish, but works well enough const gchar *name = gtk_stack_get_visible_child_name (self->stack); for (guint i=0; i<self->course_count; i++) { - if (!g_strcmp0 (name, self->courses[i].name)) { + if (g_strcmp0 (name, self->courses[i].name) != 0) { if (i > 0) { // we don't go before the first element const gchar *target_name = self->courses[i-1].name; gtk_stack_set_visible_child_name (self->stack, target_name); diff --git a/src/moodle-provider.c b/src/moodle-provider.c index 8461e9d..1222ca2 100644 --- a/src/moodle-provider.c +++ b/src/moodle-provider.c @@ -199,21 +199,23 @@ moodle_downloaded_file_cb (GInputStream *is, const char *header = soup_message_headers_get_one (headers, "Content-Disposition"); g_autofree char *real_filename = NULL, *name = NULL; - if (sscanf (header, "inline;" " filename=\"%m[^\"]\"", &name) == 1 - || sscanf (header, "attachment;"" filename=\"%m[^\"]\"", &name) == 1) { + if (sscanf (header, "inline;" " filename=\"%m[^\"]\"", &name) != 1 + && sscanf (header, "attachment;"" filename=\"%m[^\"]\"", &name) != 1) { + + g_warning ("could not read header '%s' to get the filename\n", header); + + } else { // we could get the file name real_filename = get_resource_filename (RESOURCE_FILE, 0, name); g_autofree gchar *path1 = g_filename_from_uri (real_filename, NULL, NULL); g_autofree gchar *path2 = g_filename_from_uri (filename_looked_for, NULL, NULL); - if (g_strcmp0 (path1, path2)) { // paths are different: make a symlink! + if (g_strcmp0 (path1, path2) != 0) { // paths are different: make a symlink! g_autoptr (GFile) link_file = g_file_new_for_uri (filename_looked_for); g_file_make_symbolic_link (link_file, name, NULL, NULL); // name is the name without the path: we want to make a relative link, so that's perfect } - } else { - g_warning ("could not read header '%s'\n", header); } write_g_input_stream_to_file (is, real_filename ?: filename_looked_for); -- GitLab