Bug #801
closedAnalyse Logiscope LFR_3.1.0.4 : Don_Initialisation_P2 Severity is High
0%
Description
Rappel de la règle :
Don_Initialisation_P2 :
Definition:
-----------
All variables must be initialized before they are used, without aking into account
on the default value attributed by the compiler.
Global variables, parameters of a function in the function body, and data fields
of a class in its methods are considered to be initialized.
Justification:
--------------
Not all compilers give the same default values. Unexpected behaviour can be
avoided with better control over variable values.
Limitations:
------------
This rule is not violated in the following cases:
If an array, a struct or a class are used, they will be consided initialized as
soon as a part of them has been initialized.
For example:
int a2;
int b2 = {6, 7};
int h;
a[0] = b[0]; // ok
h = a[1]; // ok
struct
{
int i;
int j;
} e, f;
e.i = 0;
g = e; // ok
This rule is violated in the following cases where initialization is uncertain:
Using a variable in a function call is considered as "being used": if it is not
initialized, the rule will be violated.
This will occur whatever the use of the function, even initializing the variable.
In cases including a conditional initialization, the rule is violated even though
the variable may well be initialized.
int i, j, k;
j = func();
if (j)
i = 0;
k = i; // violation
This applies even when there is an else branch, for example in
int i, j, k;
j = func();
if (j)
i = 0;
else
i = 5;
k = i; // violation
where initialization is certain.
In the case of a loop, for example
int j, k;
for (int i=0; i<glob; i++)
{
j=func(i);
}
k = j; // violation
where glob is a global variable, depending on the value of glob, j will have been
initialized or not: the rule is violated, even if the loop condition occurs or not.
La règle n'est pas respectée dans 352 cas d'après Logiscope:
Fichier avf0_prc0.c : lignes 70, 77, 174, 207, 210, 218, 221, 227, 230, 236, 239, 248, 253, 262, 262, 287, 289, 290, 293, 300, 302, 303, 306, 325, 327, 328, 331, 337, 339, 340, 343, 357, 360, 366
Fichier avf1_prc1.c : lignes 71, 78, 175, 208, 211, 219, 222, 228, 231, 240, 245, 254, 254, 279, 281, 282, 285, 292, 294, 295, 298, 317, 319, 320, 323, 329, 331, 332, 335, 349, 352, 358
Fichier avf2_prc2.c : lignes 59, 66, 125, 156, 159, 163, 168, 177, 177, 202, 204, 205, 208, 216, 218, 219, 222, 238, 244
Fichier fsw_init.c : lignes 274, 278, 743, 752, 761, 770, 779, 805, 891, 893
Fichier fsw_misc.c : lignes 30, 195, 210, 235, 260, 262, 270, 323, 378, 379, 565, 567, 802, 802, 803, 803, 805, 806, 807, 808
Fichier fsw_processing.c : ligne 574
Fichier fsw_spacewire.c : lignes 45, 59, 60, 66, 67, 136, 142, 152, 166, 173, 173, 175, 175, 184, 186, 186, 188, 193, 193, 199, 240, 250, 250, 259, 314, 329, 346, 348, 349, 352, 406, 522, 588, 611, 613, 615, 617, 619, 621, 623, 625, 627, 629, 631, 649, 674, 674, 681, 681, 688, 688, 695, 695, 702, 702, 709, 709, 716, 716, 723, 723, 730, 730, 737, 737, 744, 744, 754, 754, 757, 1122, 1124, 1125, 1208, 1209, 1211, 1296, 1298, 1299, 1360, 1362, 1363, 1440, 1442, 1443, 1520, 1522, 1523, 1586, 1586
Fichier lfr_cpu_usage_report.c : ligne 110
Fichier tc_acceptance.c : lignes 130, 130, 204, 287, 470
Fichier tc_handler.c : lignes 39, 45, 58, 58, 58, 67, 71, 71, 72, 72, 75, 76, 76, 79, 79, 80, 80, 83, 83, 84, 84, 87, 87, 88, 88, 91, 91, 92, 92, 95, 95, 96, 96, 99, 99, 100, 100, 103, 103, 104, 104, 107, 107, 108, 108, 111, 111, 112, 112, 115, 115, 116, 116, 119, 119, 120, 120, 123, 123, 124, 124, 127, 127, 128, 128, 131, 132, 132, 393
Fichier tc_load_dump_parameters.c : lignes 878, 897, 914, 1021, 1043, 1044, 1045
Fichier tm_lfr_tc_exe.c : lignes 379, 379
Fichier wf_handler.c : lignes 145, 185, 191, 197, 197, 199, 204, 204, 212, 216, 221, 221, 223, 228, 228, 236, 241, 246, 246, 248, 253, 253, 343, 354, 356, 362, 363, 364, 366, 390, 412, 421, 426, 457, 469, 471, 473, 475, 482, 523, 534, 542, 585, 586, 838, 843, 924, 953, 1183, 1207, 1230, 1264, 1290, 1293, 1293, 1295, 1301, 1303, 1303, 1307, 1313, 1313
Fichier : lignes