Re: Code guidelines

Liste des GroupesRevenir à l c 
Sujet : Re: Code guidelines
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.c
Date : 04. Sep 2024, 09:22:45
Autres entêtes
Organisation : None to speak of
Message-ID : <87y147zxve.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6 7
User-Agent : Gnus/5.13 (Gnus v5.13)
David Brown <david.brown@hesbynett.no> writes:
[...]
Before you put any check in code, think about the circumstances in
which it could fail.  If there are no circumstances, it is redundant
and counter-productive.
[...]

One thing to consider is that if a check can never actually fail the
recovery code *cannot be tested* (and you can't get 100% code coverage).

    p = NULL; // assume p is not volatile
    if (p != NULL) {
        do_something(); // can never execute this
    }

Of course not all such cases are so easily detectible (

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */

Date Sujet#  Auteur
3 Sep 24 * Code guidelines22Thiago Adams
3 Sep 24 +* Re: Code guidelines19David Brown
3 Sep 24 i`* Re: Code guidelines18Thiago Adams
3 Sep 24 i +* Re: Code guidelines4David Brown
3 Sep 24 i i`* Re: Code guidelines3Thiago Adams
3 Sep 24 i i +- Re: Code guidelines1David Brown
3 Sep 24 i i `- Re: Code guidelines1Chris M. Thomasson
3 Sep 24 i `* Re: Code guidelines13Thiago Adams
3 Sep 24 i  `* Re: Code guidelines12David Brown
3 Sep 24 i   `* Re: Code guidelines11Thiago Adams
3 Sep 24 i    +* Re: Code guidelines5Thiago Adams
4 Sep 24 i    i`* Re: Code guidelines4David Brown
4 Sep 24 i    i `* Re: Code guidelines3Thiago Adams
4 Sep 24 i    i  +- Re: Code guidelines1Thiago Adams
4 Sep 24 i    i  `- Re: Code guidelines1David Brown
4 Sep 24 i    +* Re: Code guidelines3David Brown
4 Sep 24 i    i`* Re: Code guidelines2Keith Thompson
4 Sep 24 i    i `- Re: Code guidelines1David Brown
4 Sep 24 i    `* Re: Code guidelines2Kaz Kylheku
4 Sep 24 i     `- Re: Code guidelines1David Brown
3 Sep 24 +- Re: Code guidelines1Kaz Kylheku
3 Sep 24 `- Re: Code guidelines1Blue-Maned_Hawk

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal