Sujet : Re: Fixing a sample from K&R book using cake static analyser
De : anton.txt (at) *nospam* gmail.moc (Anton Shepelev)
Groupes : comp.lang.cDate : 23. Jun 2024, 23:40:40
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240624014040.c7a4b34e68ce734ff837868d@gmail.moc>
References : 1 2 3
User-Agent : Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
Kaz Kylheku:
What scatter-brained drivel. Watch and learn:
>
struct nlist *install(char *name, char *defn)
{
struct nlist *existing = lookup(name);
>
if (existing) {
return existing;
} else {
When the if-branch ends with a return, the else-branch is
redundant, and its body shall be written bare, removing one
(useless) level of nesting and indentation. This is how
goto's and multiple return's (which are but a special case
of goto) help tidy up code.
-- () ascii ribbon campaign -- against html e-mail/\ www.asciiribbon.org -- against proprietary attachments