一部の人々にとって、静的アナライザーをプロジェクトに導入することは、克服できない障害のように見えます。何らかの理由で、最初の起動時に発行される分析結果の量が非常に多いため、2つのオプションのみが考慮されるという意見が非常に広まっています。それを台無しにしないか、すべての人を切り替えて警告を修正します。この記事では、GTKプロジェクトにアナライザーを実装して構成することにより、この神話を払拭しようとします。
前書き
GTK – . GTK 4, PVS-Studio. , . PVS-Studio C++ .
GTK
:
4 (Fails) + 1102 (High) + 1159 (Medium) + 3093 (Low) = 5358 .
, .
:
V530 [CWE-252] The return value of function 'g_strrstr_len' is required to be utilized. strfuncs.c 1803
/* Testing functions bounds */
static void
test_bounds (void)
{
....
g_strrstr_len (string, 10000, "BUGS");
g_strrstr_len (string, 10000, "B");
g_strrstr_len (string, 10000, ".");
g_strrstr_len (string, 10000, "");
....
}
, GTK, PVS-Studio.
:
gtk/_build/
gtk/subprojects/
gtk/tests/
gtk/testsuite/
:
2 (Fails) + 819 (High) + 461 (Medium) + 1725 (Low) = 3007 .
, , — .
, , - . :
V501 There are identical sub-expressions '* (& pipe->ref_count)' to the left and to the right of the '^' operator. gdkpipeiostream.c 65
static GdkIOPipe *
gdk_io_pipe_ref (GdkIOPipe *pipe)
{
g_atomic_int_inc (&pipe->ref_count);
return pipe;
}
- - . . . , :
#V501
//-V:g_atomic_int_:501
#V547
//-V:GTK_IS_:547
//-V:GDK_IS_:547
//-V:G_IS_:547
//-V:G_VALUE_HOLDS:547
#V568
//-V:g_set_object:568
:
2 (Fails) + 773 (High) + 417 (Medium) + 1725 (Low) = 2917 .
. V1042:
V1042 [CWE-1177] This file is marked with copyleft license, which requires you to open the derived source code. main.c 12
, . GTK , :
2 (Fails) + 164 (High) + 417 (Medium) + 1725 (Low) = 2308 .
2 Fails:
V002 Some diagnostic messages may contain incorrect line number in this file. gdkrectangle.c 1
V002 Some diagnostic messages may contain incorrect line number in this file. gdktoplevelsize.c 1
.
:
164 (High) + 417 (Medium) + 1725 (Low) = 2306 .
, , , , : , . , V501 , :
V501 There are identical sub-expressions 'G_PARAM_EXPLICIT_NOTIFY' to the left and to the right of the '|' operator. gtklistbase.c 1151
static void
gtk_list_base_class_init (GtkListBaseClass *klass)
{
....
properties[PROP_ORIENTATION] =
g_param_spec_enum ("orientation",
P_("Orientation"),
P_("The orientation of the orientable"),
GTK_TYPE_ORIENTATION,
GTK_ORIENTATION_VERTICAL,
G_PARAM_READWRITE |
G_PARAM_EXPLICIT_NOTIFY | // <=
G_PARAM_EXPLICIT_NOTIFY); // <=
....
}
! . 57%. , .
, , . , , . , .
.
, , . , , , . , .
, . , . , , , . , . , EFL Core Libraries , , 10-15% . , , 1-2 8-9 .
, . . . , . " legacy ".
.
, : Svyatoslav Razmyslov. GTK: The First Analyzer Run in Figures.