Commit Graph
84 Commits
Author SHA1 Message Date
Daan De Meyer 686bbf1e7f Introduce forward.h header with forward declarations
In preparation for adopting forward declarations to reduce unnecessary
transitive includes across the tree, let's introduce a forward.h header
with forward declarations for all libc, libsystemd, basic and shared types.

Additionally, this header exports all basic integer types and errno constants,
as well as all macros including assertions macros. These header files contain
types often used in headers and are always included in every source file one
way or another anyway.

To avoid having to include memory-util.h and alloc-util.h in forward.h, we
split off the parts we need from both into cleanup-util.h and only include
cleanup-util.h in forward.h.

To keep this commit self-contained, we include cleanup-fundamental.h and
cleanup-util.h from the headers that originally contained the same macros.
We'll remove these again in a later commit that optimizes the includes in
src/basic and src/fundamental.

Split out of #37364
2025-05-14 15:44:17 +02:00
Daan De Meyer 352fee103b docs: Add note to keep header files as lean as possible to CODING_STYLE.md 2025-04-19 11:52:58 +02:00
Daan De Meyer c7e42c2705 docs: Add paragraph about circular includes to CODING_STYLE.md 2025-04-19 11:51:07 +02:00
Mike Yuan 9cd064aa9f meson: bump C std to gnu17
GCC 8.4 (our baseline) defaults to gnu17 already.
2025-01-17 19:46:37 +00:00
Lennart Poettering c9b477415a man: document preference for secure_getenv() in coding style 2024-10-14 12:31:37 +01:00
Mike Yuan 4b7249111a docs/CODING_STYLE: document that we nowadays prefer (const char*) for func ret type
Addresses https://github.com/systemd/systemd/pull/33567#discussion_r1662818225
2024-07-02 23:35:58 +02:00
Lennart Poettering 7811864b08 CODING_STYLE: document "reterr_" return parameters
In some recent PRs (e.g. #32628) I started to systematically name return
parameters that shall only be initialized on failure (because they carry
additional error meta information, such as the line/column number of
parse failures or so). Let's make this official in the coding style.
2024-06-13 09:51:35 +02:00
Zbigniew Jędrzejewski-Szmek 9f74901a1e Merge pull request #31648 from neighbourhoodie/review-content
I did the merge manually to resolve a trivial conflict.
2024-04-17 17:41:07 +02:00
Daan De Meyer 5c041971eb docs: Add Tests section to coding style doc 2024-04-10 18:24:29 +02:00
hulkoba f757c5a4bf docs/CODING_STYLE: remove whitespace 2024-03-27 06:49:16 +01:00
Mike Yuan 3d3c42773d docs/CODING_STYLE: fix typo (CLONE_VORK -> VFORK) 2024-02-24 13:26:19 +08:00
Zbigniew Jędrzejewski-Szmek 8e3fee33af Revert "docs: use collections to structure the data"
This reverts commit 5e8ff010a1.

This broke all the URLs, we can't have that. (And actually, we probably don't
_want_ to make the change either. It's nicer to have all the pages in one
directory, so one doesn't have to figure out to which collection the page
belongs.)
2024-02-23 09:48:47 +01:00
hulkoba 5e8ff010a1 docs: use collections to structure the data 2024-02-22 10:11:54 +01:00
Lennart Poettering ce4801c42b doc: readd vanished ```
This disappeared in 1e8f5f79e1, let's
restore it.
2023-10-11 11:41:56 +02:00
Yu Watanabe ec88da9146 docs: fix typo 2023-08-01 15:53:32 +09:00
Zbigniew Jędrzejewski-Szmek da89046643 tree-wide: "<n>bit" → "<n>-bit"
In some places, "<n> bits" is used when more appropriate.
2023-07-02 11:10:12 +01:00
Lennart Poettering 2499d32022 docs: document threading situation in coding style 2023-06-23 10:05:16 +02:00
Lennart Poettering 4d26b2277a doc: say in CODING_STYLE that AT_EMPTY_PATH should be implied on openat() style APIs (and NULL path is OK)
As discussed here:

https://github.com/systemd/systemd/pull/27397#issuecomment-1521630044
2023-04-25 14:05:08 +02:00
Dmitry V. Levin ba1ca5ef26 CODING_STYLE: note that 'unsigned' form is preferred over 'unsigned int' 2023-03-08 21:17:23 +00:00
Zbigniew Jędrzejewski-Szmek 1e8f5f79e1 docs/CODING_STYLE: add sentence about redirection operators 2023-02-06 09:19:04 +01:00
Dmitry V. Levin 5c7a4f21dd docs, man: consistently use comma after "For example" 2023-01-23 22:52:34 +00:00
Dmitry V. Levin e347d53ace docs: fix grammar a bit 2023-01-23 22:52:34 +00:00
Dmitry V. Levin d8b67e05fb docs: fix a few typos 2023-01-23 22:52:34 +00:00
Lennart Poettering f591cf66f0 doc: document how we expect empty lines to be used 2023-01-17 21:26:13 +01:00
Sam James 4e11b54b31 CODING_STYLE: fix 'better' typo 2023-01-06 14:03:19 +01:00
Lennart Poettering bbb71e5c98 CODING_STYLE: fix header level 2022-09-08 16:13:07 +02:00
Lennart Poettering e8a587dca2 docs: Some CODING_STYLE additions 2022-09-07 10:05:46 +02:00
Lennart Poettering e109541fe6 docs: suggests people use path_extract_filename() + path_extract_directory() 2022-08-23 15:10:15 +02:00
Yu Watanabe 74223cbe14 tree-wide: fix typo 2022-06-10 08:26:08 +09:00
Zbigniew Jędrzejewski-Szmek a5b28b7721 CODING_STYLE: say that inet_ntop() is a no no 2022-06-06 09:52:52 +02:00
Lennart Poettering e28770e367 docs: document how we usually define enums 2022-03-14 19:10:11 +00:00
Lennart Poettering 40f55f6998 docs: document we use C11 with GNU extensions now
Follow-up for: #22711
2022-03-14 18:43:49 +00:00
bearhoney d0515a289a Update CODING_STYLE.md
Fixed typo.
2022-02-07 10:46:22 +00:00
Erik Sjölund f223fd6add docs: fix typos and improve language
Fix typos and improve the language by
adding a few commas and a missing word.
2022-01-26 22:35:33 +00:00
Lennart Poettering 947796eac3 docs: mention RET_NERRNO() in CODING_STYLE.md 2021-11-16 08:04:09 +01:00
Emily Gonyer be7148ebed Change gendered terms to be gender-neutral (#21325)
Some typos are also fixed.
2021-11-12 16:09:56 +01:00
Zbigniew Jędrzejewski-Szmek 9214f2999b CODING_STYLE: allow joined variable declarations and function calls
… but only for a single variable.

The guidelines already allowed declaring variables at the point of
initialization. But not making a function call to do that. Let's allow that
now.  The existing style of declaring and initializing seperate is still
allowed, and whatever makes most sense should be used.
2021-11-03 10:30:36 +01:00
Lennart Poettering e3bde91293 doc: document that alloca_safe() and friends are the APIs to use 2021-10-14 15:57:52 +02:00
Zbigniew Jędrzejewski-Szmek 0aff7b7584 docs: add spdx tags to all .md files
I have no idea if this is going to cause rendering problems, and it is fairly
hard to check. So let's just merge this, and if it github markdown processor
doesn't like it, revert.
2021-09-27 09:19:02 +02:00
Anders Wenhaug 4dbad977ff docs: add coding style example
Add example of how to structure else-blocks following a multiline block.
2021-06-24 10:06:40 +09:00
Zbigniew Jędrzejewski-Szmek 756755d0fc docs: update coding style a bit
Say that r should be declared at the top of the function.

Don't say that fixed buffers result in truncation, right after saying that they
must only be used if size is known.

Adjust order of examples to be consistent.
2021-06-11 18:45:31 +01:00
Štěpán Němec 6ae11e1220 docs/CODING_STYLE: fix some typos 2021-06-10 15:29:28 +01:00
Luca Boccassi 2ecce1f1a8 docs: add ARCHITECTURE.md with code map
Initial and coarse version of a code map, useful for people getting
started and looking at the repository for the first time.
2021-06-03 22:14:19 +02:00
Zbigniew Jędrzejewski-Szmek bcef0f33cc docs: more markup 2021-03-11 14:43:16 +01:00
Lennart Poettering b775b1828d docs: document not to use FILENAME_MAX in our codebase
It's a weird thing. Let's explain why.
2021-03-08 22:47:44 +01:00
Anita Zhang 800d0802e4 docs: update coding style for return (void) func(...)
Seems that people think it's useful for brevity so make it explicit in
the CODING_STYLE.
2020-10-27 00:20:17 -07:00
Lennart Poettering cf33b70765 docs: some coding style updates
Primarily:

1. Mention that we prefer if return parameters carry "ret_" as prefix in
   their name

2. Clarify that debug-level logging is always OK, and irrelevant to when
   deciding whether a function is logging or non-logging.
2020-10-19 15:30:11 +02:00
Luca Boccassi 7489ccc350 coding style: document how to break a function declaration 2020-08-20 13:19:28 +02:00
Joerg Behrmann c90b6abc91 docs: spelling fixes 2020-08-04 12:39:03 +02:00
Tomer Shechner c1495f8e9d fix typo
I was thoroughly reading your nice coding style page and found out that you guys missed an 's'.

😁
2020-07-07 10:50:36 +09:00