Project

General

Profile

Actions

Bug #809

closed

Analyse Logiscope LFR_3.1.0.4 : Tr_Parenthèses Severity is Medium

Added by William Recart over 7 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Low
Category:
-
Target version:
-
Start date:
19/10/2016
Due date:
% Done:

0%

Estimated time:
revision:
r0

Description

Rappel de la règle :
Tr_Parenthèses
Definition:
-----------
In expressions, every binary and ternary operator has to be put in parenthesis,
so that the evaluation priorities are not ambiguous.
Use the partpar option to allow the following rules: when the right operand of
a + or * operator uses the same operator, you can omit parenthesis for it.
In the same way, you can omit parenthesis in the case of the right operand of an
assignment operator. Moreover, you can omit parenthesis at the first level of
the expression.

Parameters:
----------
The character string "partpar", which, if used, allows programmers not to put
systematically parenthesis, according to the rule above.

Justification:
--------------
Removes ambiguity about the evaluation priorities.

Example:
--------

// do not write
result = fact / 100 + rem;

// write
result = ((fact / 100) + rem);

// or write, with the partpar option
result = (fact / 100) + rem;

// with the partpar option, write
result = (fact * ind * 100) + rem + 10 + (coeff ** c);

// instead of
result = ((fact * (ind * 100)) + (rem + (10 + (coeff ** c))));

La règle n'est pas respectée dans 75 cas d'après Logiscope:
Fichier avf0_prc0.c : ligne 378
Fichier avf1_prc1.c : ligne 370
Fichier avf2_prc2.c : ligne 256
Fichier fsw_misc.c : lignes 374, 705, 706, 707
Fichier fsw_processing.c : lignes 236, 549, 556, 584, 585, 587, 651, 654, 658, 664, 668, 702, 782, 783
Fichier fsw_processing.h : lignes 280, 283, 286, 306, 309
Fichier fsw_spacewire.c : lignes 162, 167, 267, 1586
Fichier tc_acceptance.c : lignes 223, 274
Fichier tc_handler.c : lignes 279, 365, 382, 970, 1037, 1407, 1413, 1416, 1519, 1549
Fichier tc_load_dump_parameters.c : lignes 403, 408, 417, 422, 431, 436, 462, 467, 551, 555, 559, 867, 885, 999, 1000, 1353, 1365, 1367, 1514
Fichier tm_lfr_tc_exe.c : ligne 380
Fichier wf_handler.c : lignes 113, 843, 905, 906, 1170, 1184, 1185, 1208, 1209, 1231, 1233, 1266, 1277

Actions #1

Updated by paul leroy about 7 years ago

  • Status changed from New to In Progress

S'agissant du même opérateur répété N fois, on peut éviter les parenthèses il me semble, sinon la notation va vraiment s'alourdir
Fichier fsw_misc.c : lignes 374
Fichier fsw_processing.c : lignes 549, 556
Fichier fsw_spacewire.c : lignes 162, 167, 267
Fichier tc_acceptance.c : lignes 223, 274
Fichier tc_handler.c : lignes 382, 970, 1037
Fichier tc_load_dump_parameters.c : lignes 867, 885
Fichier wf_handler.c : lignes 113, 1266, 1277

Actions #2

Updated by paul leroy about 7 years ago

  • Priority changed from Normal to Low
Actions #3

Updated by William Recart about 7 years ago

Effectivement pour les cas mentionnés, j'ai vérifié, du même opérateur utilisé dans les lignes mentionnées.
De plus, lorsque le même opérateur est utilisé sur des lignes longues, un césure pour augmentée la lisibilité est utilisée.

On peut tenter une demande de dérogation.

Actions #4

Updated by William Recart about 7 years ago

Vérification effectuée sur le tag 322 (c0603702c8c8) , il reste en erreur :

fsw_misc.c : lignes 454, 796, 909
fsw_processing.c : lignes 558, 565, 716, 798
fsw_spacewire.c : lignes 169, 175, 277
tc_acceptance.c : lignes 226, 279
tc_handler.c : lignes 393, 981, 1048
tc_load_dump_parameters.c : lignes 882, 902, 1077
wf_handler.c : lignes 113, 1258, 1295, 1306

Après vérification, il convient de corriger :
fsw_misc.c : lignes 796, 909
fsw_processing.c : lignes 558, 565, 798

Les lignes non mentionnées ici devront faire l'objet d'une RFD pour que l'exception de la règle soit étendue à tous les opérateurs lorsqu'ils sont identiques (et pas uniquement au + et au *).
La justification est que lorsqu'un même signe est utilisé dans une expression, l'ajout de parenthèse alourdit et complexifie la lecture et la compréhension du code.

(/) OK pour toutes les lignes proposées hormis 558 et 565 de fsw_processing.c, ce sont deux cas d'utilisation du même opérateur associatif (si mes souvenirs de collège sont exact).

Actions #5

Updated by bruno katra almost 7 years ago

  • Assignee changed from paul leroy to William Recart
Actions #6

Updated by William Recart almost 7 years ago

Satus on FSW V3.2.0.15 : One open issue on tc_handler.c line 1400
- avf0_prc0.c: line 93 => RFD
- avf1_prc1.c: line 94 => RFD
- fsw_misc.c: lines 367, 495 => RFD
- fsw_processing.c: lines 558, 565, 716, 727 => RFD
- fsw_spacewire.c: lines 169, 175, 277 => RFD
- tc_acceptance.c: lines 226, 279 => RFD
- tc_handler.c: lines 403, 991, 1058, 1400 => RFD and line 1400 : error, parenthesis missing on + (syntax explicit but paranthesis missing)
- tc_load_dump_parameters.c: lines 925, 945, 1303 => RFD
- wf_handler.c: lines 113, 1258, 1295, 1306 => RFD

A RFD to be raised so that the exception of the rule (omit parenthesis) can be extended to all the operators when identical (and not only to + and *).
The justification is that when the same operator is used in an expression, the addition of parenthesis weighs and complexifies the reading and understanding of the code.

Actions #7

Updated by William Recart almost 7 years ago

  • Status changed from In Progress to Resolved

RFW submitted : RPW-MEB-LFR-RFW-00257-LPP

Actions #8

Updated by bruno katra over 5 years ago

  • Status changed from Resolved to Closed

RFW signée et livrée en sept 2017 dans DP R3++ updated

Actions #9

Updated by William Recart over 5 years ago

Satus on FSW V3.2.0.21: (RPW-MEB-LFR-RFW-00257-LPP accepted in DP R3++)
- avf0_prc0.c: line 117
- avf1_prc1.c: line 118
- fsw_misc.c: lines 367, 495 => RFD
- fsw_processing.c: lines 405, 538, 816
- fsw_spacewire.c: lines 1193, 199, 301
- tc_acceptance.c: lines 249, 302
- tc_handler.c: lines 426, 1014, 1081, 1423
- tc_load_dump_parameters.c: lines 945, 965, 1323
- wf_handler.c: lines 137, 1280, 1317, 1328

A RFD to be raised so that the exception of the rule (omit parenthesis) can be extended to all the operators when identical (and not only to + and *).
The justification is that when the same operator is used in an expression, the addition of parenthesis weighs and complexifies the reading and understanding of the code.

Actions

Also available in: Atom PDF