Bug Summary

File:previewer/ev-previewer.c
Warning:line 159, column 3
This statement is never executed

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name ev-previewer.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/previewer -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I .. -I .. -I .. -I ../libdocument -I ../libview -I ../libmisc -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/ctk-3.0/unix-print -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/previewer -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-02-18-122410-54188-1 -x c ev-previewer.c
1/* ev-previewer.c:
2 * this file is part of lector, a cafe document viewer
3 *
4 * Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
5 *
6 * Lector is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * Lector is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20
21#include <config.h>
22
23#include <ctk/ctk.h>
24#include <glib/gi18n.h>
25#include <lector-document.h>
26#include <lector-view.h>
27
28#include "ev-previewer-window.h"
29
30static gboolean unlink_temp_file = FALSE(0);
31static const gchar *print_settings;
32static const gchar **filenames;
33
34static const GOptionEntry goption_options[] = {
35 { "unlink-tempfile", 'u', 0, G_OPTION_ARG_NONE, &unlink_temp_file, N_("Delete the temporary file")("Delete the temporary file"), NULL((void*)0) },
36 { "print-settings", 'p', 0, G_OPTION_ARG_FILENAME, &print_settings, N_("Print settings file")("Print settings file"), N_("FILE")("FILE") },
37 { G_OPTION_REMAINING"", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL((void*)0), N_("FILE")("FILE") },
38 { NULL((void*)0) }
39};
40
41static void
42ev_previewer_unlink_tempfile (const gchar *filename)
43{
44 GFile *file, *tempdir;
45
46 file = g_file_new_for_path (filename);
47 tempdir = g_file_new_for_path (g_get_tmp_dir ());
48
49 if (g_file_has_prefix (file, tempdir)) {
50 g_file_delete (file, NULL((void*)0), NULL((void*)0));
51 }
52
53 g_object_unref (file);
54 g_object_unref (tempdir);
55}
56
57static void
58ev_previewer_load_job_finished (EvJob *job,
59 EvDocumentModel *model)
60{
61 if (ev_job_is_failed (job)) {
62 g_warning ("%s", job->error->message);
63 g_object_unref (job);
64
65 return;
66 }
67 ev_document_model_set_document (model, job->document);
68 g_object_unref (job);
69}
70
71static void
72ev_previewer_load_document (const gchar *filename,
73 EvDocumentModel *model)
74{
75 EvJob *job;
76 gchar *uri;
77 GFile *file;
78
79 file = g_file_new_for_commandline_arg (filename);
80 uri = g_file_get_uri (file);
81 g_object_unref (file);
82
83 job = ev_job_load_new (uri);
84 g_signal_connect (job, "finished",g_signal_connect_data ((job), ("finished"), (((GCallback) (ev_previewer_load_job_finished
))), (model), ((void*)0), (GConnectFlags) 0)
85 G_CALLBACK (ev_previewer_load_job_finished),g_signal_connect_data ((job), ("finished"), (((GCallback) (ev_previewer_load_job_finished
))), (model), ((void*)0), (GConnectFlags) 0)
86 model)g_signal_connect_data ((job), ("finished"), (((GCallback) (ev_previewer_load_job_finished
))), (model), ((void*)0), (GConnectFlags) 0)
;
87 ev_job_scheduler_push_job (job, EV_JOB_PRIORITY_NONE);
88 g_free (uri);
89}
90
91gint
92main (gint argc, gchar **argv)
93{
94 CtkWidget *window;
95 GOptionContext *context;
96 const gchar *filename;
97 EvDocumentModel *model;
98 GError *error = NULL((void*)0);
99
100#ifdef ENABLE_NLS1
101 /* Initialize the i18n stuff */
102 bindtextdomain (GETTEXT_PACKAGE"lector", ev_get_locale_dir());
103 bind_textdomain_codeset (GETTEXT_PACKAGE"lector", "UTF-8");
104 textdomain (GETTEXT_PACKAGE"lector");
105#endif
106
107 context = g_option_context_new (_("CAFE Document Previewer")gettext ("CAFE Document Previewer"));
108 g_option_context_set_translation_domain (context, GETTEXT_PACKAGE"lector");
109 g_option_context_add_main_entries (context, goption_options, GETTEXT_PACKAGE"lector");
110
111 g_option_context_add_group (context, ctk_get_option_group (TRUE(!(0))));
112
113 if (!g_option_context_parse (context, &argc, &argv, &error)) {
114 g_warning ("Error parsing command line arguments: %s", error->message);
115 g_error_free (error);
116 g_option_context_free (context);
117
118 return 1;
119 }
120 g_option_context_free (context);
121
122 if (!filenames) {
123 g_warning ("File argument is required");
124
125 return 1;
126 }
127
128 filename = filenames[0];
129
130 if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
131 g_warning ("Filename \"%s\" does not exist or is not a regular file", filename);
132
133 return 1;
134 }
135
136 if (!ev_init ())
137 return 1;
138
139 ev_stock_icons_init ();
140
141 g_set_application_name (_("CAFE Document Previewer")gettext ("CAFE Document Previewer"));
142 ctk_window_set_default_icon_name ("lector");
143
144 model = ev_document_model_new ();
145 window = ev_previewer_window_new (model);
146 ev_previewer_window_set_source_file (EV_PREVIEWER_WINDOW (window)((((EvPreviewerWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((window)), ((ev_previewer_window_get_type()
))))))
, filename);
147 ev_previewer_window_set_print_settings (EV_PREVIEWER_WINDOW (window)((((EvPreviewerWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((window)), ((ev_previewer_window_get_type()
))))))
, print_settings);
148 g_signal_connect (window, "delete-event",g_signal_connect_data ((window), ("delete-event"), (((GCallback
) (ctk_main_quit))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
149 G_CALLBACK (ctk_main_quit), NULL)g_signal_connect_data ((window), ("delete-event"), (((GCallback
) (ctk_main_quit))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
150 g_signal_connect (window, "destroy",g_signal_connect_data ((window), ("destroy"), (((GCallback) (
ctk_main_quit))), (((void*)0)), ((void*)0), (GConnectFlags) 0
)
151 G_CALLBACK (ctk_main_quit), NULL)g_signal_connect_data ((window), ("destroy"), (((GCallback) (
ctk_main_quit))), (((void*)0)), ((void*)0), (GConnectFlags) 0
)
;
152 ctk_widget_show (window);
153
154 ev_previewer_load_document (filename, model);
155
156 ctk_main ();
157
158 if (unlink_temp_file)
159 ev_previewer_unlink_tempfile (filename);
This statement is never executed
160 if (print_settings)
161 ev_previewer_unlink_tempfile (print_settings);
162
163 ev_shutdown ();
164 ev_stock_icons_shutdown ();
165 g_object_unref (model);
166
167 return 0;
168}