]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: stream: Reduce duplication in `stream_generate_unique_id()`
authorTim Duesterhus <tim@bastelstu.be>
Fri, 3 Apr 2026 21:28:59 +0000 (23:28 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 13 Apr 2026 12:02:29 +0000 (14:02 +0200)
The return value of the `if()` and `else` branch is identical. We can just move
it out of conditional paths.

Reviewed-by: Volker Dusch <github@wallbash.com>
src/stream.c

index 0afa3059f5f3e348a30901e6218d85cc05beb9d6..eb13cf277605dbdb2c437d245344cc39d2c91a1c 100644 (file)
@@ -3093,10 +3093,7 @@ INITCALL0(STG_INIT, init_stream);
  */
 struct ist stream_generate_unique_id(struct stream *strm, struct lf_expr *format)
 {
-       if (isttest(strm->unique_id)) {
-               return strm->unique_id;
-       }
-       else {
+       if (!isttest(strm->unique_id)) {
                char *unique_id;
 
                if ((unique_id = pool_alloc(pool_head_uniqueid)) == NULL)
@@ -3107,9 +3104,9 @@ struct ist stream_generate_unique_id(struct stream *strm, struct lf_expr *format
                 */
                strm->unique_id = ist2(unique_id, 0);
                strm->unique_id.len = build_logline(strm, unique_id, UNIQUEID_LEN, format);
-
-               return strm->unique_id;
        }
+
+       return strm->unique_id;
 }
 
 /************************************************************************/