Documentation/translations/it_IT/process/coding-style.rst
Source file repositories/reference/linux-study-clean/Documentation/translations/it_IT/process/coding-style.rst
File Facts
- System
- Linux kernel
- Corpus path
Documentation/translations/it_IT/process/coding-style.rst- Extension
.rst- Size
- 46144 bytes
- Lines
- 1231
- Domain
- Support Tooling And Documentation
- Bucket
- Documentation
- Inferred role
- Support Tooling And Documentation: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function tabulazionefunction functionfunction testofunction funfunction funexport system_is_up
Annotated Snippet
if (condition1) {
while (loop1) {
...
}
result = 1;
goto out_free_buffer;
}
...
out_free_buffer:
kfree(buffer);
return result;
}
Un baco abbastanza comune di cui bisogna prendere nota è il ``one err bugs``
che assomiglia a questo:
.. code-block:: c
err:
kfree(foo->bar);
kfree(foo);
return ret;
Il baco in questo codice è che in alcuni punti d'uscita la variabile ``foo`` è
NULL. Normalmente si corregge questo baco dividendo la gestione dell'errore in
due parti ``err_free_bar:`` e ``err_free_foo:``:
.. code-block:: c
err_free_bar:
kfree(foo->bar);
err_free_foo:
kfree(foo);
return ret;
Idealmente, dovreste simulare condizioni d'errore per verificare i vostri
percorsi d'uscita.
8) Commenti
-----------
I commenti sono una buona cosa, ma c'è anche il rischio di esagerare. MAI
spiegare COME funziona il vostro codice in un commento: è molto meglio
scrivere il codice di modo che il suo funzionamento sia ovvio, inoltre
spiegare codice scritto male è una perdita di tempo.
Solitamente, i commenti devono dire COSA fa il codice, e non COME lo fa.
Inoltre, cercate di evitare i commenti nel corpo della funzione: se la
funzione è così complessa che dovete commentarla a pezzi, allora dovreste
tornare al punto 6 per un momento. Potete mettere dei piccoli commenti per
annotare o avvisare il lettore circa un qualcosa di particolarmente arguto
(o brutto), ma cercate di non esagerare. Invece, mettete i commenti in
testa alla funzione spiegando alle persone cosa fa, e possibilmente anche
il PERCHÉ.
Per favore, quando commentate una funzione dell'API del kernel usate il
formato kernel-doc. Per maggiori dettagli, leggete i file in
:ref::ref:`Documentation/translations/it_IT/doc-guide/ <it_doc_guide>` e in
``script/kernel-doc``.
Lo stile preferito per i commenti più lunghi (multi-riga) è:
.. code-block:: c
/*
* This is the preferred style for multi-line
* comments in the Linux kernel source code.
* Please use it consistently.
*
Annotation
- Detected declarations: `function tabulazione`, `function function`, `function testo`, `function fun`, `function fun`, `export system_is_up`.
- Atlas domain: Support Tooling And Documentation / Documentation.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.