Linux Coding and Submitting

本文档详细介绍了如何遵循Linux内核项目的规范提交补丁,包括代码风格、提交检查清单、补丁序列化、提交变更文件的方法、撰写提交消息的最佳实践及如何应用补丁等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Coding style

The best way to get acquainted with  what we will be looking for in kernel patches is to

start with the kernel's own documentation:

Documentation/CodingStyle 

Documentation/SubmitChecklist


Checkpatch

Running the kernel's checkpatch tool on all patches submitted to kernel baselines.

Assuming you have already committed your changes locally and your current directory

is the root of the kernel source tree, you can use the following command to run checkpatch locally:
"git format -patch HEAD~1 --stdout | ./scripts/checkpatch.pl "


Patch Serialization

patches are regularly broken up into smaller pieces and submitted in sequence.
to separate logical changes into single patches. Beyond the obvious of not submitting bug fixes and
new work in a single patch.

Also note that to submit changes to defconfig or device tree files as a separate as well.

Commit Messages


In the extended part of the commit message provide as many details as are relevant. 
If the reason why a change is being made is not obvious, use the commit message to
provide some background and reasoning. When writing commit message try to think of
the information you would want to know if you were looking back at the change several
months down the road.

Commit message often includes a prefix that can be used to quickly identify 
which kernel subsystem is being modified . e.g. arm, config, dts, platform ...

Using "git commit -s" to generate one Signed-off-by: Line .

A good guide for writing git commit messages can be found at :


Good_commit_messages
AngularJS Git Commit Message Conventions
5 Useful Tips For A Better Commit Message
thoughtbot git message

 one thing one commit
 1. easy to read
 2. easy to cherry-pick
 3. easy to code review

Applying Patches

If the code is supplied as git formatter patch, please use
git am to apply the patch so that the original commit metadata (author, data, commit message, etc.) is preserved. 
If the code is available in a third party git tree, you can pull the remote tree into your locally checked out tree and use git cherry‐pick to pick up the patch with the original commit metadata.

Git usage

See Wiki Git
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值