Bug Summary

File:tests/testmountoperation.c
Warning:line 148, column 11
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 testmountoperation.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/tests -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I .. -I .. -I ../cdk -I ../cdk -D G_ENABLE_DEBUG -D G_ENABLE_CONSISTENCY_CHECKS -D GLIB_MIN_REQUIRED_VERSION=GLIB_VERSION_2_66 -D GLIB_MAX_ALLOWED_VERSION=GLIB_VERSION_2_66 -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/sysprof-6 -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/atk-1.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -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/gio-unix-2.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/pango-1.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -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/sysprof-6 -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 -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../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/tests -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-09-19-172934-43638-1 -x c testmountoperation.c
1/* testmultidisplay.c
2 * Copyright (C) 2008 Christian Kellner
3 * Author: Christian Kellner <gicmo@gnome.org>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "config.h"
20#include <ctk/ctk.h>
21
22static gboolean ask_question = FALSE(0);
23static gboolean anonymous = FALSE(0);
24static gboolean dont_ask_username = FALSE(0);
25static gboolean dont_ask_domain = FALSE(0);
26static gboolean dont_ask_password = FALSE(0);
27static gboolean dont_save_password = FALSE(0);
28
29
30static void
31got_reply (GMountOperation *op,
32 GMountOperationResult result,
33 gpointer user_data)
34{
35 if (result == G_MOUNT_OPERATION_HANDLED)
36 {
37
38 if (ask_question)
39 {
40 gint choice = g_mount_operation_get_choice (op);
41 g_print ("User chose: %d\n", choice);
42 }
43 else
44 {
45 if (anonymous)
46 g_print ("Anymous: %s\n",
47 g_mount_operation_get_anonymous (op) ? "true" : "false");
48
49 if (!dont_ask_username)
50 g_print ("Username: %s\n", g_mount_operation_get_username (op));
51
52 if (!dont_ask_domain)
53 g_print ("Domain: %s\n", g_mount_operation_get_domain (op));
54
55 if (!dont_ask_password)
56 g_print ("Password: %s\n", g_mount_operation_get_password (op));
57
58 if (!dont_save_password)
59 {
60 GPasswordSave pw_save;
61
62 pw_save = g_mount_operation_get_password_save (op);
63 g_print ("Save password: ");
64 switch (pw_save)
65 {
66 case G_PASSWORD_SAVE_NEVER:
67 g_print ("never");
68 break;
69
70 case G_PASSWORD_SAVE_FOR_SESSION:
71 g_print ("session");
72 break;
73
74 case G_PASSWORD_SAVE_PERMANENTLY:
75 g_print ("forever");
76 break;
77
78 default:
79 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "testmountoperation.c"
, 79, ((const char*) (__func__)), ((void*)0)); } while (0)
;
80 }
81 g_print ("\n");
82 }
83 }
84 }
85 else if (result == G_MOUNT_OPERATION_ABORTED)
86 g_print ("Operation aborted.\n");
87 else if (G_MOUNT_OPERATION_UNHANDLED)
88 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "testmountoperation.c"
, 88, ((const char*) (__func__)), ((void*)0)); } while (0)
;
89
90 ctk_main_quit ();
91}
92
93int
94main (int argc, char *argv[])
95{
96 GMountOperation *op;
97 gboolean force_rtl = FALSE(0);
98 GError *error = NULL((void*)0);
99 GOptionEntry options[] = {
100 { "ask-question", 'q', 0, G_OPTION_ARG_NONE, &ask_question, "Ask a question not a password.", NULL((void*)0) },
101 { "right-to-left", 'r', 0, G_OPTION_ARG_NONE, &force_rtl, "Force right-to-left layout.", NULL((void*)0) },
102 { "anonymous", 'a', 0, G_OPTION_ARG_NONE, &anonymous, "Anonymous login allowed.", NULL((void*)0) },
103 { "no-username", 'u', 0, G_OPTION_ARG_NONE, &dont_ask_username, "Don't ask for the username.", NULL((void*)0) },
104 { "no-password", 'p', 0, G_OPTION_ARG_NONE, &dont_ask_password, "Don't ask for the password.", NULL((void*)0) },
105 { "no-domain", 'd', 0, G_OPTION_ARG_NONE, &dont_ask_domain, "Don't ask for the domain.", NULL((void*)0) },
106 { "no-pw-save", 's', 0, G_OPTION_ARG_NONE, &dont_save_password, "Don't show password save options.", NULL((void*)0) },
107 { NULL((void*)0) }
108 };
109
110 if (!ctk_init_with_args (&argc, &argv, "", options, NULL((void*)0), &error))
111 {
112 g_print ("Failed to parse args: %s\n", error->message);
113 g_error_free (error);
114 return 1;
115 }
116
117 if (force_rtl)
118 ctk_widget_set_default_direction (CTK_TEXT_DIR_RTL);
119
120 op = ctk_mount_operation_new (NULL((void*)0));
121
122 g_signal_connect (op, "reply", G_CALLBACK (got_reply), NULL)g_signal_connect_data ((op), ("reply"), (((GCallback) (got_reply
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
123
124 if (ask_question)
125 {
126 static const char *choices[] = {
127 "Yes", "No", "Sauerkraut", NULL((void*)0)
128 };
129
130 g_signal_emit_by_name (op, "ask_question", "Foo\nbar", choices);
131 }
132 else
133 {
134 GAskPasswordFlags flags;
135
136 flags = 0;
137
138 if (!dont_ask_password)
139 flags |= G_ASK_PASSWORD_NEED_PASSWORD;
140
141 if (!dont_ask_username)
142 flags |= G_ASK_PASSWORD_NEED_USERNAME;
143
144 if (!dont_ask_domain)
145 flags |= G_ASK_PASSWORD_NEED_DOMAIN;
146
147 if (anonymous)
148 flags |= G_ASK_PASSWORD_ANONYMOUS_SUPPORTED;
This statement is never executed
149
150 if (!dont_save_password)
151 flags |= G_ASK_PASSWORD_SAVING_SUPPORTED;
152
153 g_signal_emit_by_name (op, "ask_password",
154 argc > 1 ? argv[1] : "Credentials needed",
155 argc > 2 ? argv[2] : "default user",
156 argc > 3 ? argv[3] : "default domain",
157 flags);
158 }
159
160 ctk_main ();
161 return 0;
162}