Willy,

Am 27.02.20 um 03:49 schrieb Willy Tarreau:
>> +int stream_generate_unique_id(struct stream *strm, struct list *format) {
> 
> Please put the function's opening brace on its own line. The reason for
> this is when you have many arguments and variables, it easily becomes a
> mess where you cannot always visually tell which ones belong to what.

That happens when working with different projects. My usual code style
is the opening brace on the same line.

>> +    if (strm->unique_id != NULL) {
>> +            return strlen(strm->unique_id);
>> +    }
>> +
>> +    if ((strm->unique_id = pool_alloc(pool_head_uniqueid)) == NULL)
>> +            return -1;
> 
> Please avoid assignments in "if" conditions. There are two reasons for
> this, both related to debugging:
>    - if you want to quickly disable the error check or put a lock
>      around or whatever, you cannot without splitting the line in
>      two ;
> 
>    - you often cannot single-step through it in a debugger or put a
>      breakpoint after the pool_alloc() call.

Sure, adjusted. In this case I just "copied" the existing code / control
flow.

Will send the updated series when I had a look at the other mail.

Best regards
Tim Düsterhus

Reply via email to