Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the General Tips page to kernel linux labs #258

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Documentation/teaching/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,5 @@ tools/labs/docs/Dockerfile for dependencies):
info/vm.rst
info/extra-vm.rst
info/contributing.rst
info/general-tips.rst

42 changes: 42 additions & 0 deletions Documentation/teaching/info/general-tips.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
============
General Tips
============

Your code must not only "work", but also meet certain standards.
Below are some tips for assignments, along with related penalties for non-compliance:

- 0.2: compilation warnings
- 0.1: 10-20 lines longer than 80 characters;
- 0.2: more than 20 lines longer than 80 characters;
- 0.1: duplicated code;
- 0.1: magic numbers, not symbolic constants;
- 0.1: identation where tabs are mixed with spaces;
- 0.1: mixed line endings;
- 0.1: trailing whitespace; do not leave spaces or tabs at the end of lines;
- 0.1: long functions(> 150 de lines);
- 0.2: very long functions (> 300 de lines);
- 0.1: commented code; for debugging we recommend using a macro;
- 0.1: inappropriate comments; we recommend briefly browsing the :command:`Documentation/kernel-doc-nano-HOWTO.txt` file for infomation about comment format;
- 0.1: functions and variables used only locally that are not static;
- 0.2: no `copy_ {to, from} _user` functions are used where needed;
- 0.2: the return values of the functions are not checked;
- 0.1: no relevant error codes are returned;
- 0.2/-0.3: synchronization problems (-0.2 partial synchronizations, -0.3 synchronization mechanisms are missing or incorrect);
- 0.1: inclusion of binary or irrelevant files in the archive;
- 0.2: memory leaks;
- 0.3: use of blocking operations in atomic context;

You can check most style comments using
`scripts/checkpatch.pl <git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/scripts/checkpatch.pl>`__,
found in any Linux tree. For specific situations where you break the rules,
argue with a comment or specification in the README file.

Usage
-----

.. code-block:: console

$ scripts/checkpatch.pl --no-tree --terse -f my-homework.c

For more information on coding style,
you can read the file `Coding Style <https://elixir.bootlin.com/linux/v4.19.19/source/Documentation/process/coding-style.rst>`__.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use version 5.14 here