From nobody Fri Dec 26 07:25:09 2025 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E2CC52F61 for ; Mon, 8 Jan 2024 16:16:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=posteo.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=posteo.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=posteo.net header.i=@posteo.net header.b="oAR6Gwaj" Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 87889240101 for ; Mon, 8 Jan 2024 17:16:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1704730564; bh=X3VtHd5GjlJi8/Twrh4yAaOYDgw5xWt6nucsz68JnqU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=oAR6GwajS3y8dsWT0cTJzZ++cMYORHI0OiZFlheCvbx9Bz2WOu21/mJCYSGtxDwz4 h6k3yv1V0fWP2Fvp2A3WLR/Mskuz806PGtjJxfdhQO5XwjPOaZMtPIQcYnTrQfXZP1 /I1E6cdiqypmkVIDZb60H7W/6n1eyBNDcQTg9L447vqXWyPc7Tg8xYGYs+7UE8b/Gf GsLpP9ijgW8lf4vSUdF6tG8puOM3ifhROSGQj823ibDvoI0VR3NLUIn1XOZCeyPnmc rQy51/3RE6opGSEbI/kqmwQzt7vt6cl2TGREoSDpibLb9smIP5PihqRP3GLRCT5AJU pflgMcO7yXtbw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4T7zh03SCsz9rxB; Mon, 8 Jan 2024 17:16:00 +0100 (CET) From: Yueh-Shun Li To: Jonathan Corbet Cc: Yueh-Shun Li , Randy Dunlap , Hu Haowen , Alex Shi , Yanteng Si , workflows@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] coding-style: recommend split headers instead of kernel.h Date: Mon, 8 Jan 2024 16:03:22 +0000 Message-ID: <20240108160746.177421-2-shamrocklee@posteo.net> In-Reply-To: <20240108160746.177421-1-shamrocklee@posteo.net> References: <107b6b5e-ca14-4b2b-ba2e-38ecd74c0ad3@infradead.org> <20240108160746.177421-1-shamrocklee@posteo.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In section "18) Don't re-invent the kernel macros" in "Linux kernel coding style": Recommend reusing macros from headers inside include/linux, instead of the obsolete include/linux/kernel.h Change wording - "The header file contains macros" -> "the header files provide macros" Some macros are intended to use inside the header file only, or are considered the implementation detail of other facilities. Developers are expected to determine if a macro is meant to be used outside the header file. Signed-off-by: Yueh-Shun Li --- Documentation/process/coding-style.rst | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Documentation/process/coding-style.rst b/Documentation/process= /coding-style.rst index 6db37a46d305..2504cb00a961 100644 --- a/Documentation/process/coding-style.rst +++ b/Documentation/process/coding-style.rst @@ -1048,27 +1048,30 @@ readable alternative if the call-sites have naked t= rue/false constants. Otherwise limited use of bool in structures and arguments can improve readability. =20 + 18) Don't re-invent the kernel macros ------------------------------------- =20 -The header file include/linux/kernel.h contains a number of macros that -you should use, rather than explicitly coding some variant of them yoursel= f. +The header files in the ``include/linux`` directory provide a number of ma= cros +that you should use, rather than explicitly coding some variant of them +yourself. + For example, if you need to calculate the length of an array, take advanta= ge -of the macro +of the macro ``ARRAY_SIZE()`` from ``include/linux/array_size.h`` by =20 .. code-block:: c =20 - #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + #include + ARRAY_SIZE(x) // The size of array x =20 Similarly, if you need to calculate the size of some structure member, use +``sizeof_field()`` from ``include/linux/stddef.h``. =20 -.. code-block:: c - - #define sizeof_field(t, f) (sizeof(((t*)0)->f)) +There are also ``min()`` and ``max()`` macros in ``include/linux/minmax.h`` +that do strict type checking if you need them. =20 -There are also min() and max() macros that do strict type checking if you -need them. Feel free to peruse that header file to see what else is alrea= dy -defined that you shouldn't reproduce in your code. +Feel free to search across and peruse the header files to see what else is +already defined that you shouldn't reproduce in your code. =20 =20 19) Editor modelines and other cruft --=20 2.42.0 From nobody Fri Dec 26 07:25:09 2025 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76E5B5380D for ; Mon, 8 Jan 2024 16:16:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=posteo.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=posteo.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=posteo.net header.i=@posteo.net header.b="HzQVztjN" Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id DBCD8240029 for ; Mon, 8 Jan 2024 17:16:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1704730590; bh=VhNI/VyHttpB6Dc+nOmQ0eI7dT/saNfHep5H24iJdO8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=HzQVztjNExNwWDrBuHzEvHtkFFb6vD0OXysV/RE2YSQAQeRZRM4R2KPi1eqBI1IE0 BSv2xCrBjDcgcfMHIjpUhv7F7AXvuX8XRuiUkCupg5ER15Ex18/IoSvHTPiCypErA9 870DCFFhsdxf6Ku/I5Bdn4tyn4/jWmgW0j+pNBTZ19BpBQFy9thMKIBdX+Xy1LGjKn ktiSoGhu0cJbFOuiyqcWbCl5Iv5BRsQl12Bl6+IAmoxmpSpOAEKunG3bM33lUuyF6b w7VL9S2/9IFb4670o/kT67shDy+0J9nn2ZRyR2cEJqPySYA83y8pVs3zf3EgzSV+PD zV6Uyu0OElw7A== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4T7zhV4n4Wz9rxN; Mon, 8 Jan 2024 17:16:26 +0100 (CET) From: Yueh-Shun Li To: Jonathan Corbet Cc: Yueh-Shun Li , Hu Haowen , Alex Shi , Yanteng Si , Randy Dunlap , workflows@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] coding-style: show how reusing macros prevents naming collisions Date: Mon, 8 Jan 2024 16:03:23 +0000 Message-ID: <20240108160746.177421-3-shamrocklee@posteo.net> In-Reply-To: <20240108160746.177421-1-shamrocklee@posteo.net> References: <107b6b5e-ca14-4b2b-ba2e-38ecd74c0ad3@infradead.org> <20240108160746.177421-1-shamrocklee@posteo.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In section "18) Don't re-invent the kernel macros" in "Linux kernel coding style": Show how reusing macros from shared headers prevents naming collisions using "stringify", the one of the most widely reinvented macro, as an example. This patch aims to provide a stronger reason to reuse shared macros, by showing the risk of improvised macro variants. Signed-off-by: Yueh-Shun Li --- Documentation/process/coding-style.rst | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Documentation/process/coding-style.rst b/Documentation/process= /coding-style.rst index 2504cb00a961..1e79aba4b346 100644 --- a/Documentation/process/coding-style.rst +++ b/Documentation/process/coding-style.rst @@ -1070,6 +1070,28 @@ Similarly, if you need to calculate the size of some= structure member, use There are also ``min()`` and ``max()`` macros in ``include/linux/minmax.h`` that do strict type checking if you need them. =20 +Using existing macros provided by the shared headers also prevents naming +collisions. For example, if one developer define in ``foo.h`` + +.. code-block:: c + + #define __stringify(x) __stringify_1(x) + #define __stringify_1(x) #x + +and another define in ``bar.h`` + +.. code-block:: c + + #define stringify(x) __stringify(x) + #define __stringify(x) #x + +When both headers are ``#include``-d into the same file, the facilities pr= ovided +by ``foo.h`` might be broken by ``bar.h``. + +If both ``foo.h`` and ``bar.h`` use the macro ``__stringify()`` provided = by +``include/linux/stringify.h``, they wouldn't have stepped onto each other's +toes. + Feel free to search across and peruse the header files to see what else is already defined that you shouldn't reproduce in your code. =20 --=20 2.42.0 From nobody Fri Dec 26 07:25:09 2025 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3460A5465D for ; Mon, 8 Jan 2024 16:16:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=posteo.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=posteo.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=posteo.net header.i=@posteo.net header.b="hfeYGviL" Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 69C9D24002A for ; Mon, 8 Jan 2024 17:16:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1704730603; bh=i725bwQMCd01Orv6abs3xlOUBm43RkTh68m2tAj/kj8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=hfeYGviLiV5nx/uAlkvRGMTGX57uSbquPKBtr/ZgxfNC4h/zg3HehsAI9u89pKG7v 2m8Gap1ZTW3DHpYKKanAAOk8BCerOUsNwYgLp9BEcBr2yHAbOg4WLhOxhuo4jcdTm7 mFWIvq11IYy0J8INb8s97LsTaVredjltf0cchw8ibyHWtwnFktpb+TXLyI7hUe1qn2 jUaXYDFraMUJgdfkuN4WtEkXh7YFDwR1Z77jgs14GEt31F5+8/6WrPND16+wt0Ibky HmjB0WJhab6OPDyMymuIv33BcKpkXMvrq/xf7TgoIgclpd6YB3qo1dB3l+68hDuF3F xEYRvGAt1p3og== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4T7zhn114nz9rxS; Mon, 8 Jan 2024 17:16:40 +0100 (CET) From: Yueh-Shun Li To: Hu Haowen Cc: Yueh-Shun Li , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] doc/zh_TW: coding-style: update content for section 18 Date: Mon, 8 Jan 2024 16:03:24 +0000 Message-ID: <20240108160746.177421-4-shamrocklee@posteo.net> In-Reply-To: <20240108160746.177421-1-shamrocklee@posteo.net> References: <107b6b5e-ca14-4b2b-ba2e-38ecd74c0ad3@infradead.org> <20240108160746.177421-1-shamrocklee@posteo.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Update the content of the zh_TW translation of "Linux kernel coding style" section 18, following the change proposed in the first 2 patches in these patch series. From the diff of between the zh_TW and zh_CN translation of the file coding-style.rst, it seems that the zh_TW files are direct character-by-character translation of the zh_CN files, without any phrase localization. This results in wording unfamilliar to zh_TW speakers. This patch reuses existing terms inside coding-style.rst (e.g. =E5=AE=8F for "macros" and =E9=A0=AD=E6=96=87=E4=BB=B6 for "header files"), while localiz= ing terms introduced in this file the first time (e.g. =E6=90=9C=E5=B0=8B instead of = =E6=90=9C=E7=B4=A2 for "search"). The localization of Chinese dialects could be performed programmatically with the help of OpenCC[1] with custom configuration based on the upstream s2twp.json (zh_CN to zh_TW with Taiwanese idiom), but that is beyond the scope of this patch. [1]: https://github.com/BYVoid/OpenCC Signed-off-by: Yueh-Shun Li --- .../zh_TW/process/coding-style.rst | 39 +++++++++++++++---- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/Documentation/translations/zh_TW/process/coding-style.rst b/Do= cumentation/translations/zh_TW/process/coding-style.rst index 5749363de421..0197405cfec8 100644 --- a/Documentation/translations/zh_TW/process/coding-style.rst +++ b/Documentation/translations/zh_TW/process/coding-style.rst @@ -922,25 +922,48 @@ Linux=E5=85=A7=E6=A0=B8=E5=B8=83=E7=88=BE=EF=BC=88boo= l=EF=BC=89=E9=A1=9E=E5=9E=8B=E6=98=AFC99 _Bool=E9=A1=9E=E5=9E=8B=E7=9A=84= =E5=88=A5=E5=90=8D=E3=80=82=E5=B8=83=E7=88=BE=E5=80=BC=E5=8F=AA=E8=83=BD =20 =E7=B8=BD=E4=B9=8B=EF=BC=8C=E5=9C=A8=E7=B5=90=E6=A7=8B=E9=AB=94=E5=92=8C= =E5=8F=83=E6=95=B8=E4=B8=AD=E6=9C=89=E9=99=90=E5=9C=B0=E4=BD=BF=E7=94=A8=E5= =B8=83=E7=88=BE=E5=8F=AF=E4=BB=A5=E6=8F=90=E9=AB=98=E5=8F=AF=E8=AE=80=E6=80= =A7=E3=80=82 =20 + 18) =E4=B8=8D=E8=A6=81=E9=87=8D=E6=96=B0=E7=99=BC=E6=98=8E=E5=85=A7=E6=A0= =B8=E5=AE=8F ---------------------- =20 -=E9=A0=AD=E6=96=87=E4=BB=B6 include/linux/kernel.h =E5=8C=85=E5=90=AB=E4= =BA=86=E4=B8=80=E4=BA=9B=E5=AE=8F=EF=BC=8C=E4=BD=A0=E6=87=89=E8=A9=B2=E4=BD= =BF=E7=94=A8=E5=AE=83=E5=80=91=EF=BC=8C=E8=80=8C=E4=B8=8D=E8=A6=81=E8=87=AA= =E5=B7=B1=E5=AF=AB=E4=B8=80=E4=BA=9B -=E5=AE=83=E5=80=91=E7=9A=84=E8=AE=8A=E7=A8=AE=E3=80=82=E6=AF=94=E5=A6=82= =EF=BC=8C=E5=A6=82=E6=9E=9C=E4=BD=A0=E9=9C=80=E8=A6=81=E8=A8=88=E7=AE=97=E4= =B8=80=E5=80=8B=E6=95=B8=E7=B5=84=E7=9A=84=E9=95=B7=E5=BA=A6=EF=BC=8C=E4=BD= =BF=E7=94=A8=E9=80=99=E5=80=8B=E5=AE=8F +``include/linux`` =E7=9B=AE=E9=8C=84=E4=B8=8B=E7=9A=84=E9=A0=AD=E6=96=87= =E4=BB=B6=E6=8F=90=E4=BE=9B=E4=BA=86=E4=B8=80=E4=BA=9B=E5=AE=8F=EF=BC=8C=E4= =BD=A0=E6=87=89=E8=A9=B2=E4=BD=BF=E7=94=A8=E5=AE=83=E5=80=91=EF=BC=8C=E8=80= =8C=E4=B8=8D=E8=A6=81=E8=87=AA=E5=B7=B1=E5=AF=AB +=E4=B8=80=E4=BA=9B=E5=AE=83=E5=80=91=E7=9A=84=E8=AE=8A=E7=A8=AE=E3=80=82= =E6=AF=94=E5=A6=82=EF=BC=8C=E5=A6=82=E6=9E=9C=E4=BD=A0=E9=9C=80=E8=A6=81=E8= =A8=88=E7=AE=97=E4=B8=80=E5=80=8B=E6=95=B8=E7=B5=84=E7=9A=84=E9=95=B7=E5=BA= =A6=EF=BC=8C=E4=BD=BF=E7=94=A8 +``include/linux/array_size.h`` =E6=8F=90=E4=BE=9B=E7=9A=84 ``ARRAY_SIZE()`= ` =E5=AE=8F =20 .. code-block:: c =20 - #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + #include + ARRAY_SIZE(x) // The size of array x + +=E9=A1=9E=E4=BC=BC=E7=9A=84=EF=BC=8C=E5=A6=82=E6=9E=9C=E4=BD=A0=E8=A6=81= =E8=A8=88=E7=AE=97=E6=9F=90=E7=B5=90=E6=A7=8B=E9=AB=94=E6=88=90=E5=93=A1=E7= =9A=84=E5=A4=A7=E5=B0=8F=EF=BC=8C=E4=BD=BF=E7=94=A8 ``include/linux/stddef.= h`` =E7=95=B6 +=E4=B8=AD=E7=9A=84 ``sizeof_field()`` =E5=AE=8F=E3=80=82 + +=E9=82=84=E6=9C=89 ``include/linux/minmax.h`` =E6=8F=90=E4=BE=9B=E8=83=BD= =E5=81=9A=E5=9A=B4=E6=A0=BC=E7=9A=84=E9=A1=9E=E5=9E=8B=E6=AA=A2=E6=9F=A5=E7= =9A=84 ``min()`` =E5=92=8C +``max()`` =E5=AE=8F=EF=BC=8C=E5=A6=82=E6=9E=9C=E4=BD=A0=E9=9C=80=E8=A6=81= =E5=8F=AF=E4=BB=A5=E4=BD=BF=E7=94=A8=E5=AE=83=E5=80=91=E3=80=82 =20 -=E9=A1=9E=E4=BC=BC=E7=9A=84=EF=BC=8C=E5=A6=82=E6=9E=9C=E4=BD=A0=E8=A6=81= =E8=A8=88=E7=AE=97=E6=9F=90=E7=B5=90=E6=A7=8B=E9=AB=94=E6=88=90=E5=93=A1=E7= =9A=84=E5=A4=A7=E5=B0=8F=EF=BC=8C=E4=BD=BF=E7=94=A8 +=E4=BD=BF=E7=94=A8=E5=85=B1=E7=94=A8=E9=A0=AD=E6=96=87=E4=BB=B6=E6=89=80= =E6=8F=90=E4=BE=9B=E7=9A=84=E5=AE=8F=E4=B9=9F=E8=83=BD=E9=81=BF=E5=85=8D=E5= =91=BD=E5=90=8D=E8=A1=9D=E7=AA=81=E3=80=82=E6=AF=94=E5=A6=82=E8=AA=AA=EF=BC= =8C=E5=A6=82=E6=9E=9C=E6=9C=89=E5=80=8B=E9=96=8B=E7=99=BC=E8=80=85=E5=9C=A8= =E9=A0=AD=E6=96=87=E4=BB=B6 +``foo.h`` =E4=B8=AD=E5=AE=9A=E7=BE=A9=E4=BA=86 =20 .. code-block:: c =20 - #define sizeof_field(t, f) (sizeof(((t*)0)->f)) + #define __stringify(x) __stringify_1(x) + #define __stringify_1(x) #x + +=E4=BD=86=E5=8F=A6=E4=B8=80=E5=80=8B=E9=96=8B=E7=99=BC=E8=80=85=E5=9C=A8= =E9=A0=AD=E6=96=87=E4=BB=B6 ``bar.h`` =E4=B8=AD=E5=AE=9A=E7=BE=A9=E4=BA=86 + +.. code-block:: c + + #define stringify(x) __stringify(x) + #define __stringify(x) #x + +=E7=95=B6=E5=85=A9=E5=80=8B=E9=A0=AD=E6=96=87=E4=BB=B6=E9=83=BD=E8=A2=AB `= `#include`` =E9=80=B2=E5=90=8C=E4=B8=80=E4=BB=BD=E6=96=87=E4=BB=B6=EF=BC=8C= ``foo.h`` =E6=8F=90=E4=BE=9B=E7=9A=84=E5=B7=A5=E5=85=B7=E5=8F=AF=E8=83=BD= =E6=9C=83=E8=A2=AB +``bar.h`` =E7=A0=B4=E5=A3=9E=E3=80=82 + +=E5=A6=82=E6=9E=9C=E5=85=A9=E5=80=8B=E9=A0=AD=E6=96=87=E4=BB=B6=E9=83=BD= =E4=BD=BF=E7=94=A8 ``include/linux/stringify.h`` =E6=8F=90=E4=BE=9B=E7=9A= =84 ``__stringify()`` +=E5=AE=8F=EF=BC=8C=E5=B0=B1=E4=B8=8D=E6=9C=83=E4=BA=92=E7=9B=B8=E5=B9=B2= =E6=93=BE=E4=BA=86=E3=80=82 =20 -=E9=82=84=E6=9C=89=E5=8F=AF=E4=BB=A5=E5=81=9A=E5=9A=B4=E6=A0=BC=E7=9A=84= =E9=A1=9E=E5=9E=8B=E6=AA=A2=E6=9F=A5=E7=9A=84 min() =E5=92=8C max() =E5=AE= =8F=EF=BC=8C=E5=A6=82=E6=9E=9C=E4=BD=A0=E9=9C=80=E8=A6=81=E5=8F=AF=E4=BB=A5= =E4=BD=BF=E7=94=A8=E5=AE=83=E5=80=91=E3=80=82=E4=BD=A0=E5=8F=AF=E4=BB=A5 -=E8=87=AA=E5=B7=B1=E7=9C=8B=E7=9C=8B=E9=82=A3=E5=80=8B=E9=A0=AD=E6=96=87= =E4=BB=B6=E8=A3=8F=E9=82=84=E5=AE=9A=E7=BE=A9=E4=BA=86=E4=BB=80=E9=BA=BC=E4= =BD=A0=E5=8F=AF=E4=BB=A5=E6=8B=BF=E4=BE=86=E7=94=A8=E7=9A=84=E6=9D=B1=E8=A5= =BF=EF=BC=8C=E5=A6=82=E6=9E=9C=E6=9C=89=E5=AE=9A=E7=BE=A9=E7=9A=84=E8=A9=B1= =EF=BC=8C=E4=BD=A0=E5=B0=B1=E4=B8=8D=E6=87=89 -=E5=9C=A8=E4=BD=A0=E7=9A=84=E4=BB=A3=E7=A2=BC=E8=A3=8F=E8=87=AA=E5=B7=B1= =E9=87=8D=E6=96=B0=E5=AE=9A=E7=BE=A9=E3=80=82 +=E4=BD=A0=E5=8F=AF=E4=BB=A5=E8=87=AA=E5=B7=B1=E6=90=9C=E5=B0=8B=E3=80=81= =E7=9C=8B=E7=9C=8B=E9=82=A3=E4=BA=9B=E9=A0=AD=E6=96=87=E4=BB=B6=E8=A3=8F=E9= =82=84=E5=AE=9A=E7=BE=A9=E4=BA=86=E4=BB=80=E9=BA=BC=E4=BD=A0=E5=8F=AF=E4=BB= =A5=E6=8B=BF=E4=BE=86=E7=94=A8=E7=9A=84=E6=9D=B1=E8=A5=BF=EF=BC=8C=E5=A6=82= =E6=9E=9C=E6=9C=89=E5=AE=9A=E7=BE=A9=E7=9A=84 +=E8=A9=B1=EF=BC=8C=E4=BD=A0=E5=B0=B1=E4=B8=8D=E6=87=89=E5=9C=A8=E4=BD=A0= =E7=9A=84=E4=BB=A3=E7=A2=BC=E8=A3=8F=E8=87=AA=E5=B7=B1=E9=87=8D=E6=96=B0=E5= =AE=9A=E7=BE=A9=E3=80=82 =20 =20 19) =E7=B7=A8=E8=BC=AF=E5=99=A8=E6=A8=A1=E5=BC=8F=E8=A1=8C=E5=92=8C=E5=85= =B6=E4=BB=96=E9=9C=80=E8=A6=81=E7=BE=85=E5=97=A6=E7=9A=84=E4=BA=8B=E6=83=85 --=20 2.42.0 From nobody Fri Dec 26 07:25:09 2025 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1DC954736 for ; Mon, 8 Jan 2024 16:16:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=posteo.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=posteo.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=posteo.net header.i=@posteo.net header.b="CAaevBH3" Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 41B6A240028 for ; Mon, 8 Jan 2024 17:16:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1704730612; bh=FSKcWsQ5mtlwkCpoTpXGMOT6OsAb8LvcvEc/sUGr2VU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=CAaevBH3V6YyG0d8ShmWsQfffeLzQeCzOuqDjG3fTJ5UP16tN/extBLKsb1kyHN8E RWjsOvPT1fIHR5kRDbF8LwgpoZXSyH0yCVjlfDEVr4Co83FsQ/evQqMbhEQBvSqpz3 wK5/PxtRlDUdYby8ytb0+7CR1KUYzyIXXspo6EQbTNjzl2/nXjGqQGm0hSnNHG8Sae WykSkkO1Cv967G7diIZ4d9/KD8JzlbZkIAmPl4UlRGyTUlboTVY1SuWQLZzFSNVlJJ KV5NuCegkufYWrRfbz+Gm0qDekkpjx1QTTBw3rqC1kc/PUKNuro/Ta0Eg/FgGWWD8K 9+Uddbnyj3enw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4T7zhx4HD5z9rxF; Mon, 8 Jan 2024 17:16:49 +0100 (CET) From: Yueh-Shun Li To: Alex Shi , Yanteng Si Cc: Yueh-Shun Li , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] doc/zh_CN: coding-style: update content of section 18 Date: Mon, 8 Jan 2024 16:03:25 +0000 Message-ID: <20240108160746.177421-5-shamrocklee@posteo.net> In-Reply-To: <20240108160746.177421-1-shamrocklee@posteo.net> References: <107b6b5e-ca14-4b2b-ba2e-38ecd74c0ad3@infradead.org> <20240108160746.177421-1-shamrocklee@posteo.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Update the content of the zh_CN translation of "Linux kernel coding style" section 18, following the change proposed in the first 2 patches in these patch series. As a zh_TW speaker, I tried my best to compare and proofread the content generated with OpenCC[1] with tw2s and tw2sp configurations, and existing translation in the same file. Please kindly point out anything I should fix. [1]: https://github.com/BYVoid/OpenCC Signed-off-by: Yueh-Shun Li --- .../zh_CN/process/coding-style.rst | 39 +++++++++++++++---- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/Documentation/translations/zh_CN/process/coding-style.rst b/Do= cumentation/translations/zh_CN/process/coding-style.rst index fa28ef0a7fee..14ff3cdc2d0d 100644 --- a/Documentation/translations/zh_CN/process/coding-style.rst +++ b/Documentation/translations/zh_CN/process/coding-style.rst @@ -919,25 +919,48 @@ Linux=E5=86=85=E6=A0=B8=E5=B8=83=E5=B0=94=EF=BC=88boo= l=EF=BC=89=E7=B1=BB=E5=9E=8B=E6=98=AFC99 _Bool=E7=B1=BB=E5=9E=8B=E7=9A=84= =E5=88=AB=E5=90=8D=E3=80=82=E5=B8=83=E5=B0=94=E5=80=BC=E5=8F=AA=E8=83=BD =20 =E6=80=BB=E4=B9=8B=EF=BC=8C=E5=9C=A8=E7=BB=93=E6=9E=84=E4=BD=93=E5=92=8C= =E5=8F=82=E6=95=B0=E4=B8=AD=E6=9C=89=E9=99=90=E5=9C=B0=E4=BD=BF=E7=94=A8=E5= =B8=83=E5=B0=94=E5=8F=AF=E4=BB=A5=E6=8F=90=E9=AB=98=E5=8F=AF=E8=AF=BB=E6=80= =A7=E3=80=82 =20 + 18) =E4=B8=8D=E8=A6=81=E9=87=8D=E6=96=B0=E5=8F=91=E6=98=8E=E5=86=85=E6=A0= =B8=E5=AE=8F ---------------------- =20 -=E5=A4=B4=E6=96=87=E4=BB=B6 include/linux/kernel.h =E5=8C=85=E5=90=AB=E4= =BA=86=E4=B8=80=E4=BA=9B=E5=AE=8F=EF=BC=8C=E4=BD=A0=E5=BA=94=E8=AF=A5=E4=BD= =BF=E7=94=A8=E5=AE=83=E4=BB=AC=EF=BC=8C=E8=80=8C=E4=B8=8D=E8=A6=81=E8=87=AA= =E5=B7=B1=E5=86=99=E4=B8=80=E4=BA=9B -=E5=AE=83=E4=BB=AC=E7=9A=84=E5=8F=98=E7=A7=8D=E3=80=82=E6=AF=94=E5=A6=82= =EF=BC=8C=E5=A6=82=E6=9E=9C=E4=BD=A0=E9=9C=80=E8=A6=81=E8=AE=A1=E7=AE=97=E4= =B8=80=E4=B8=AA=E6=95=B0=E7=BB=84=E7=9A=84=E9=95=BF=E5=BA=A6=EF=BC=8C=E4=BD= =BF=E7=94=A8=E8=BF=99=E4=B8=AA=E5=AE=8F +``include/linux`` =E7=9B=AE=E5=BD=95=E4=B8=8B=E7=9A=84=E5=A4=B4=E6=96=87= =E4=BB=B6=E6=8F=90=E4=BE=9B=E4=BA=86=E4=B8=80=E4=BA=9B=E5=AE=8F=EF=BC=8C=E4= =BD=A0=E5=BA=94=E8=AF=A5=E4=BD=BF=E7=94=A8=E5=AE=83=E4=BB=AC=EF=BC=8C=E8=80= =8C=E4=B8=8D=E8=A6=81=E8=87=AA=E5=B7=B1=E5=86=99 +=E4=B8=80=E4=BA=9B=E5=AE=83=E4=BB=AC=E7=9A=84=E5=8F=98=E7=A7=8D=E3=80=82= =E6=AF=94=E5=A6=82=EF=BC=8C=E5=A6=82=E6=9E=9C=E4=BD=A0=E9=9C=80=E8=A6=81=E8= =AE=A1=E7=AE=97=E4=B8=80=E4=B8=AA=E6=95=B0=E7=BB=84=E7=9A=84=E9=95=BF=E5=BA= =A6=EF=BC=8C=E4=BD=BF=E7=94=A8 +``include/linux/array_size.h`` =E6=8F=90=E4=BE=9B=E7=9A=84 ``ARRAY_SIZE()`= ` =E5=AE=8F =20 .. code-block:: c =20 - #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + #include + ARRAY_SIZE(x) // The size of array x + +=E7=B1=BB=E4=BC=BC=E7=9A=84=EF=BC=8C=E5=A6=82=E6=9E=9C=E4=BD=A0=E8=A6=81= =E8=AE=A1=E7=AE=97=E6=9F=90=E7=BB=93=E6=9E=84=E4=BD=93=E6=88=90=E5=91=98=E7= =9A=84=E5=A4=A7=E5=B0=8F=EF=BC=8C=E4=BD=BF=E7=94=A8 ``include/linux/stddef.= h`` =E5=BD=93 +=E4=B8=AD=E7=9A=84 ``sizeof_field()`` =E5=AE=8F=E3=80=82 + +=E8=BF=98=E6=9C=89 ``include/linux/minmax.h`` =E6=8F=90=E4=BE=9B=E8=83=BD= =E5=81=9A=E4=B8=A5=E6=A0=BC=E7=9A=84=E7=B1=BB=E5=9E=8B=E6=A3=80=E6=9F=A5=E7= =9A=84 ``min()`` =E5=92=8C +``max()`` =E5=AE=8F=EF=BC=8C=E5=A6=82=E6=9E=9C=E4=BD=A0=E9=9C=80=E8=A6=81= =E5=8F=AF=E4=BB=A5=E4=BD=BF=E7=94=A8=E5=AE=83=E4=BB=AC=E3=80=82 =20 -=E7=B1=BB=E4=BC=BC=E7=9A=84=EF=BC=8C=E5=A6=82=E6=9E=9C=E4=BD=A0=E8=A6=81= =E8=AE=A1=E7=AE=97=E6=9F=90=E7=BB=93=E6=9E=84=E4=BD=93=E6=88=90=E5=91=98=E7= =9A=84=E5=A4=A7=E5=B0=8F=EF=BC=8C=E4=BD=BF=E7=94=A8 +=E4=BD=BF=E7=94=A8=E5=85=B1=E7=94=A8=E5=A4=B4=E6=96=87=E4=BB=B6=E6=89=80= =E6=8F=90=E4=BE=9B=E7=9A=84=E5=AE=8F=E4=B9=9F=E8=83=BD=E9=81=BF=E5=85=8D=E5= =91=BD=E5=90=8D=E5=86=B2=E7=AA=81=E3=80=82=E6=AF=94=E5=A6=82=E8=AF=B4=EF=BC= =8C=E5=A6=82=E6=9E=9C=E6=9C=89=E4=B8=AA=E5=BC=80=E5=8F=91=E8=80=85=E5=9C=A8= =E5=A4=B4=E6=96=87=E4=BB=B6 +``foo.h`` =E4=B8=AD=E5=AE=9A=E4=B9=89=E4=BA=86 =20 .. code-block:: c =20 - #define sizeof_field(t, f) (sizeof(((t*)0)->f)) + #define __stringify(x) __stringify_1(x) + #define __stringify_1(x) #x + +=E4=BD=86=E5=8F=A6=E4=B8=80=E4=B8=AA=E5=BC=80=E5=8F=91=E8=80=85=E5=9C=A8= =E5=A4=B4=E6=96=87=E4=BB=B6 ``bar.h`` =E4=B8=AD=E5=AE=9A=E4=B9=89=E4=BA=86 + +.. code-block:: c + + #define stringify(x) __stringify(x) + #define __stringify(x) #x + +=E5=BD=93=E4=B8=A4=E4=B8=AA=E5=A4=B4=E6=96=87=E4=BB=B6=E9=83=BD=E8=A2=AB `= `#include`` =E8=BF=9B=E5=90=8C=E4=B8=80=E4=BB=BD=E6=96=87=E4=BB=B6=EF=BC=8C= ``foo.h`` =E6=8F=90=E4=BE=9B=E7=9A=84=E5=B7=A5=E5=85=B7=E5=8F=AF=E8=83=BD= =E4=BC=9A=E8=A2=AB +``bar.h`` =E7=A0=B4=E5=9D=8F=E3=80=82 + +=E5=A6=82=E6=9E=9C=E4=B8=A4=E4=B8=AA=E5=A4=B4=E6=96=87=E4=BB=B6=E9=83=BD= =E4=BD=BF=E7=94=A8 ``include/linux/stringify.h`` =E6=8F=90=E4=BE=9B=E7=9A= =84 ``__stringify()`` +=E5=AE=8F=EF=BC=8C=E5=B0=B1=E4=B8=8D=E4=BC=9A=E4=BA=92=E7=9B=B8=E5=B9=B2= =E6=89=B0=E4=BA=86=E3=80=82 =20 -=E8=BF=98=E6=9C=89=E5=8F=AF=E4=BB=A5=E5=81=9A=E4=B8=A5=E6=A0=BC=E7=9A=84= =E7=B1=BB=E5=9E=8B=E6=A3=80=E6=9F=A5=E7=9A=84 min() =E5=92=8C max() =E5=AE= =8F=EF=BC=8C=E5=A6=82=E6=9E=9C=E4=BD=A0=E9=9C=80=E8=A6=81=E5=8F=AF=E4=BB=A5= =E4=BD=BF=E7=94=A8=E5=AE=83=E4=BB=AC=E3=80=82=E4=BD=A0=E5=8F=AF=E4=BB=A5 -=E8=87=AA=E5=B7=B1=E7=9C=8B=E7=9C=8B=E9=82=A3=E4=B8=AA=E5=A4=B4=E6=96=87= =E4=BB=B6=E9=87=8C=E8=BF=98=E5=AE=9A=E4=B9=89=E4=BA=86=E4=BB=80=E4=B9=88=E4= =BD=A0=E5=8F=AF=E4=BB=A5=E6=8B=BF=E6=9D=A5=E7=94=A8=E7=9A=84=E4=B8=9C=E8=A5= =BF=EF=BC=8C=E5=A6=82=E6=9E=9C=E6=9C=89=E5=AE=9A=E4=B9=89=E7=9A=84=E8=AF=9D= =EF=BC=8C=E4=BD=A0=E5=B0=B1=E4=B8=8D=E5=BA=94 -=E5=9C=A8=E4=BD=A0=E7=9A=84=E4=BB=A3=E7=A0=81=E9=87=8C=E8=87=AA=E5=B7=B1= =E9=87=8D=E6=96=B0=E5=AE=9A=E4=B9=89=E3=80=82 +=E4=BD=A0=E5=8F=AF=E4=BB=A5=E8=87=AA=E5=B7=B1=E6=90=9C=E7=B4=A2=E3=80=81= =E7=9C=8B=E7=9C=8B=E9=82=A3=E4=BA=9B=E5=A4=B4=E6=96=87=E4=BB=B6=E9=87=8C=E8= =BF=98=E5=AE=9A=E4=B9=89=E4=BA=86=E4=BB=80=E4=B9=88=E4=BD=A0=E5=8F=AF=E4=BB= =A5=E6=8B=BF=E6=9D=A5=E7=94=A8=E7=9A=84=E4=B8=9C=E8=A5=BF=EF=BC=8C=E5=A6=82= =E6=9E=9C=E6=9C=89=E5=AE=9A=E4=B9=89=E7=9A=84 +=E8=AF=9D=EF=BC=8C=E4=BD=A0=E5=B0=B1=E4=B8=8D=E5=BA=94=E5=9C=A8=E4=BD=A0= =E7=9A=84=E4=BB=A3=E7=A0=81=E9=87=8C=E8=87=AA=E5=B7=B1=E9=87=8D=E6=96=B0=E5= =AE=9A=E4=B9=89=E3=80=82 =20 =20 19) =E7=BC=96=E8=BE=91=E5=99=A8=E6=A8=A1=E5=BC=8F=E8=A1=8C=E5=92=8C=E5=85= =B6=E4=BB=96=E9=9C=80=E8=A6=81=E7=BD=97=E5=97=A6=E7=9A=84=E4=BA=8B=E6=83=85 --=20 2.42.0