Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <vb6v1t$3b5mb$1@dont-email.me>
Deutsch   English   Français   Italiano  
<vb6v1t$3b5mb$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Thiago Adams <thiago.adams@gmail.com>
Newsgroups: comp.lang.c
Subject: Code guidelines
Date: Tue, 3 Sep 2024 09:22:20 -0300
Organization: A noiseless patient Spider
Lines: 73
Message-ID: <vb6v1t$3b5mb$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 03 Sep 2024 14:22:21 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="15b67f073a3e4783414ee664431ab3cb";
	logging-data="3512011"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19nsp4rF7kVUMAelWz1t3Gz8kuEZbsy1Sg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:BeAnoiZ852ISZ5500Lv5LAUtk9Q=
Content-Language: en-US

Witch style (F1, F2 ..) better represents the guidelines of your code?


//The function f never returns nullptr
int * f();

void F1() {
    int* p = f();

    if (p == nullptr) {
       assert(false);
       return;
    }
    // using *p ...
}

void F2()
{
    int* p = f();
    assert(p != nullptr);
    // using *p ...
}

void F3()
{
    int* p = f();
    // using *p ...
}

void F4()
{
    int* p = f();
    if (p) {
     // using *p ...
    }
}



The same question but for struct members



struct user {

   //Name is required, cannot be null.
   char * name;
};

void F1(struct user* user) {

    if (user->name == nullptr) {
       assert(false);
       return;
    }
    // using user->name ...
}

void F2(struct user* user) {
    assert(user->name != nullptr);
    // using user->name ...
}

void F3(struct user* user) {
    // using user->name ...
}

void F4(struct user* user) {
    if (user->name) {
      // using user->name ...
    }
}