Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #388124

Re: Code guidelines

Path csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups comp.lang.c
Subject Re: Code guidelines
Date Wed, 04 Sep 2024 00:22:45 -0700
Organization None to speak of
Lines 20
Message-ID <87y147zxve.fsf@nosuchdomain.example.com> (permalink)
References <vb6v1t$3b5mb$1@dont-email.me> <vb726n$3b4rq$1@dont-email.me> <vb736j$3b5mb$2@dont-email.me> <vb75g9$3bntp$1@dont-email.me> <vb77tn$3bu07$3@dont-email.me> <vb7d6l$3d5mv$1@dont-email.me> <vb8vcf$3nlvn$1@dont-email.me>
MIME-Version 1.0
Content-Type text/plain
Injection-Date Wed, 04 Sep 2024 09:22:45 +0200 (CEST)
Injection-Info dont-email.me; posting-host="0c8cc2609bc8d9fbbbb3d106ce45f413"; logging-data="3939040"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+dTLFiW9aNo33YpNeG6W7J"
User-Agent Gnus/5.13 (Gnus v5.13)
Cancel-Lock sha1:cpgRISpv1nmpxCsFJ1HGVkWrXMQ= sha1:Dvh3dU6dw3AqZ3kbwY6zdlpcKDk=
Xref csiph.com comp.lang.c:388124

Show key headers only | View raw


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 */

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Code guidelines Thiago Adams <thiago.adams@gmail.com> - 2024-09-03 09:22 -0300
  Re: Code guidelines David Brown <david.brown@hesbynett.no> - 2024-09-03 15:16 +0200
    Re: Code guidelines Thiago Adams <thiago.adams@gmail.com> - 2024-09-03 10:33 -0300
      Re: Code guidelines David Brown <david.brown@hesbynett.no> - 2024-09-03 16:10 +0200
        Re: Code guidelines Thiago Adams <thiago.adams@gmail.com> - 2024-09-03 11:37 -0300
          Re: Code guidelines David Brown <david.brown@hesbynett.no> - 2024-09-03 16:49 +0200
          Re: Code guidelines "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-09-03 14:39 -0700
          Re: Code guidelines Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-09-22 02:08 +0000
      Re: Code guidelines Thiago Adams <thiago.adams@gmail.com> - 2024-09-03 11:12 -0300
        Re: Code guidelines David Brown <david.brown@hesbynett.no> - 2024-09-03 16:53 +0200
          Re: Code guidelines Thiago Adams <thiago.adams@gmail.com> - 2024-09-03 13:23 -0300
            Re: Code guidelines Thiago Adams <thiago.adams@gmail.com> - 2024-09-03 13:37 -0300
              Re: Code guidelines David Brown <david.brown@hesbynett.no> - 2024-09-04 08:45 +0200
                Re: Code guidelines Thiago Adams <thiago.adams@gmail.com> - 2024-09-04 08:52 -0300
                Re: Code guidelines Thiago Adams <thiago.adams@gmail.com> - 2024-09-04 09:06 -0300
                Re: Code guidelines David Brown <david.brown@hesbynett.no> - 2024-09-04 20:14 +0200
            Re: Code guidelines David Brown <david.brown@hesbynett.no> - 2024-09-04 08:40 +0200
              Re: Code guidelines Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-09-04 00:22 -0700
                Re: Code guidelines David Brown <david.brown@hesbynett.no> - 2024-09-04 12:47 +0200
            Re: Code guidelines Kaz Kylheku <643-408-1753@kylheku.com> - 2024-09-04 14:02 +0000
              Re: Code guidelines David Brown <david.brown@hesbynett.no> - 2024-09-04 20:20 +0200
            Re: Code guidelines Vir Campestris <vir.campestris@invalid.invalid> - 2024-10-01 11:41 +0100
              Re: Code guidelines Kaz Kylheku <643-408-1753@kylheku.com> - 2024-10-01 21:39 +0000
  Re: Code guidelines Kaz Kylheku <643-408-1753@kylheku.com> - 2024-09-03 15:10 +0000
  Re: Code guidelines Blue-Maned_Hawk <bluemanedhawk@invalid.invalid> - 2024-09-03 21:01 +0000

csiph-web