From nobody Mon Feb 9 10:51:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557398640; cv=none; d=zoho.com; s=zohoarc; b=hH+yFMn/lowR29ta1c7Vt0+apS7rIIxjnr+ZFxTxcmhMssgWY+B1l9Qt2dnPNDraOtpDgXAKJi41U2rzCnNr2oVIzWOq6mnPHoAHBXQ7Eh1I2pSprfKTIWi2w1p/8dOK0WQE40t2kVTjkdpavBGp9sFNZuN2KVajO/dxFJ+XzjU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557398640; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ndjDXFwNGRELrnpZT2qYGa7MbrA9Wrc2f4Lj0xqmPws=; b=a5NMZWeOHF1ixe4vVu3+EfDEFkDGnBrou6Yt3nPgeA0aAeDpyE6uOdaEvfexS6myWzaabQrvQiFpdFbzgpkZ7/7w9pcVWTIk8/df7l78Ii8Sh6/zYiZu8hCzbVzP+xcqRKJXWPpP/SEo1Pi1roG7PUw7fK3YgTs21en0njzVV74= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1557398640469344.3114353645333; Thu, 9 May 2019 03:44:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DE2E0306E5FB; Thu, 9 May 2019 10:43:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B8CEF1001E81; Thu, 9 May 2019 10:43:58 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7E40418089CB; Thu, 9 May 2019 10:43:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x49Ahe3m029934 for ; Thu, 9 May 2019 06:43:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5BA2063C31; Thu, 9 May 2019 10:43:40 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA96461786 for ; Thu, 9 May 2019 10:43:39 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 9 May 2019 12:43:34 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/3] docs: hacking: Discourage use of the ternary operator and ban it's abuse X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 09 May 2019 10:43:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Forbid breaking lines inside the two branches of the ternary operator and nesting them. Using it in these instances does not help readability. Signed-off-by: Peter Krempa --- docs/hacking.html.in | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/hacking.html.in b/docs/hacking.html.in index a2800853ef..fc4adae354 100644 --- a/docs/hacking.html.in +++ b/docs/hacking.html.in @@ -847,6 +847,17 @@ BAD: if (!nfoos) if (foos) +

New code should avoid the ternary operator as much as possible. + Specifically it must never span more than one line or nest: +

+
+BAD:
+    char *foo =3D baz ?
+                virDoSomethingReallyComplex(driver, vm, something, baz->fo=
o) :
+                NULL;
+
+    char *foo =3D bar ? bar->baz ? bar->baz->foo : "nobaz" : "nobar";
+

Preprocessor

--=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list