From nobody Mon Feb 9 19:30:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1637247454; cv=none; d=zohomail.com; s=zohoarc; b=XHHqeH0aCKBGyGquc2eRmUL+UxQ/oZ92DUXOUrhrzFWD1IAYgwp7cTlS8wHOSM4K6s1s38qjXkaqs/EF0D9Y9x2dX2pIv6re1qtkUVEUfKLnh6jeQpr+KbE3SwEggrV0LNWcrdX8PvNG6/wEOOffRDGJmwOJ+VvaoO2AUjl3sGQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637247454; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=6DiSDv3PdVbuzBwVbsPBRsE403y5aRBjXVqhRXtzZwI=; b=PEjr/NiSFkNmW+j2kJxZ0tBc6Iy9Oiiy1LGrL/Y7aEXweCIUHc/ilhKL5JtIMPwRnfvIt/cK1fc4DkIiRzwli6t7aLaSQ480UT7waOgZcusCcTlaWd6QyaXP1LNSKxPejuIGVjOEcOtfReUI2HwPaJVoZ6mb2OsZhjHXcwQIsFE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1637247454286792.1612565099216; Thu, 18 Nov 2021 06:57:34 -0800 (PST) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-569-TtCbMAx-N8y2vKLnkMmDwg-1; Thu, 18 Nov 2021 09:57:32 -0500 Received: by mail-wm1-f71.google.com with SMTP id 144-20020a1c0496000000b003305ac0e03aso4446436wme.8 for ; Thu, 18 Nov 2021 06:57:31 -0800 (PST) Return-Path: Return-Path: Received: from x1w.. (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id b10sm81077wrt.36.2021.11.18.06.57.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:57:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637247453; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6DiSDv3PdVbuzBwVbsPBRsE403y5aRBjXVqhRXtzZwI=; b=CL1xe1rtwsDeCo3UIbKDgVZWXjX1VhB1cCeZIbdouJr2BUq6XguXaMGeZU8U4U+qpgAZ3r dkqi2Jd19GjfgG8QkOyUB8fqrczHamlbHiAh1vkRfGoZMl0AuaX+kZLYyLBRL+CMAvQQNv AsdYnr6oNNd/luux5gMxaSV55yXQhBs= X-MC-Unique: TtCbMAx-N8y2vKLnkMmDwg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6DiSDv3PdVbuzBwVbsPBRsE403y5aRBjXVqhRXtzZwI=; b=3UsH26K7oHJgdYFZSWuL7EWhdU9rTmxNkdc6uX73z9Pns/CM/bXZWbRv1gBE790eBz z4vYnY9Fo8pGorQZak0dO/x6ZCVCerMrq8ZS0jWnj9cLtfFAIEMTylrIEw/znhfMz/uB uuzNqCzi6zEU39GSrS6LEE3MaWy5R6p5HtP6u9rCwfKJMN0759Rp10TgZNve9KL/jMUg iq2mMPebZHQrX8A14yVwZEtSfzpvT+SeuYtyXBuJd/jZCIRwHkYFAGwbDG/kavrjZJo6 gzRYzHSShwfL4xrg/TVKrEWsajW5/35NYw1W20kkceuo0uVVN/bvRszFpwwQy231reJO Mg4w== X-Gm-Message-State: AOAM533UGdWIH501dUhboVK/7cvYJ5tqOfkU6BiUWqzbU8PSq4bX5VFW rEwRySxIiAWPWSr/G3GTuiF8FSDwkQ/vn+hhyEpt3y9TsaSh00YWp9a4YSZIzs5OeV9eK0gVGz1 5sOG87E9z26vefQ== X-Received: by 2002:a1c:a715:: with SMTP id q21mr10926048wme.23.1637247450896; Thu, 18 Nov 2021 06:57:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFehAPCodWGX22DYzque1Ork/YjeZDpJjpMHY+Bq8h0Rt0bxqYzveTzZqKA3MfHMEK+z02Mg== X-Received: by 2002:a1c:a715:: with SMTP id q21mr10926028wme.23.1637247450721; Thu, 18 Nov 2021 06:57:30 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , Peter Maydell , Darren Kenny , "Daniel P . Berrange" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH-for-6.2? v2 3/5] docs/devel/style: Improve string format rST rendering Date: Thu, 18 Nov 2021 15:57:14 +0100 Message-Id: <20211118145716.4116731-4-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211118145716.4116731-1-philmd@redhat.com> References: <20211118145716.4116731-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1637247455819100001 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e --- docs/devel/style.rst | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/docs/devel/style.rst b/docs/devel/style.rst index 1a23021bc3e..a7487d867e6 100644 --- a/docs/devel/style.rst +++ b/docs/devel/style.rst @@ -471,11 +471,11 @@ instead of plain strdup/strndup. Printf-style functions =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 -Whenever you add a new printf-style function, i.e., one with a format -string argument and following "..." in its prototype, be sure to use -gcc's printf attribute directive in the prototype. +Whenever you add a new ``printf()``-style function, i.e., one with a format +string argument and following '``...``' in its prototype, be sure to use +gcc's ``printf()`` attribute directive in the prototype. =20 -This makes it so gcc's -Wformat and -Wformat-security options can do +This makes it so gcc's ``-Wformat`` and ``-Wformat-security`` options can = do their jobs and cross-check format strings with the number and types of arguments. =20 @@ -659,10 +659,10 @@ Note that ``&error_fatal`` is just another way to ``e= xit(1)``, and trace-events style =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 -0x prefix ---------- +``0x`` prefix +------------- =20 -In trace-events files, use a '0x' prefix to specify hex numbers, as in: +In trace-events files, use a '``0x``' prefix to specify hex numbers, as in: =20 .. code-block:: c =20 @@ -676,27 +676,28 @@ PCI bus id): =20 another_trace(int cssid, int ssid, int dev_num) "bus id: %x.%x.%04x" =20 -However, you can use '0x' for such groups if you want. Anyway, be sure that +However, you can use '``0x``' for such groups if you want. Anyway, be sure= that it is obvious that numbers are in hex, ex.: =20 .. code-block:: c =20 data_dump(uint8_t c1, uint8_t c2, uint8_t c3) "bytes (in hex): %02x %0= 2x %02x" =20 -Rationale: hex numbers are hard to read in logs when there is no 0x prefix, -especially when (occasionally) the representation doesn't contain any lett= ers -and especially in one line with other decimal numbers. Number groups are a= llowed -to not use '0x' because for some things notations like %x.%x.%x are used n= ot -only in QEMU. Also dumping raw data bytes with '0x' is less readable. +Rationale: hex numbers are hard to read in logs when there is no '``0x``' +prefix, especially when (occasionally) the representation doesn't contain = any +letters and especially in one line with other decimal numbers. Number grou= ps +are allowed to not use '``0x``' because for some things notations like +'``%x.%x.%x``' are used not only in QEMU. Also dumping raw data bytes with +'``0x``' is less readable. =20 -'#' printf flag ---------------- +'``#``' printf flag +------------------- =20 -Do not use printf flag '#', like '%#x'. +Do not use printf flag '``#``', like '``%#x``'. =20 -Rationale: there are two ways to add a '0x' prefix to printed number: '0x%= ...' -and '%#...'. For consistency the only one way should be used. Arguments for -'0x%' are: +Rationale: there are two ways to add a '``0x``' prefix to printed number: +'``0x%...``' and '``%#...``'. For consistency the only one way should be u= sed. +Arguments for '``0x%``' are: =20 * it is more popular -* '%#' omits the 0x for the value 0 which makes output inconsistent +* '``%#``' omits the ``0x`` for the value ``0`` which makes output inconsi= stent --=20 2.31.1