History log of /systemd/CODING_STYLE
Revision Date Author Comments Expand
1c4e4227faa77026eeb633e2e575bedf1897daa3 25-Jan-2016 Lennart Poettering <lennart@poettering.net>

CODING_STYLE: make sure line break recommendation matches edit configuration In the .vimrc and .dir-locals.el we suggest a line width of 119. We should recommend the same in CODING_STYLE.

fa195fa775e548a15c0cc21d4c8611fd0286245a 10-Nov-2015 Lennart Poettering <lennart@poettering.net>

CODING_STYLE: elaborate on usage of C99 fixed size integer types

ec566e4c7cee67ec2c39475ef08f18a9f1b80efd 19-Oct-2015 Lennart Poettering <lennart@poettering.net>

update CODING_STYLE

041f793b6b1e4b86edc909b4b2867463b3ef3efd 08-Oct-2015 Lennart Poettering <lennart@poettering.net>

update CODING_STYLE

c7ddad5148de6e41445f62a80fb6846dce1a6856 06-Oct-2015 Lennart Poettering <lennart@poettering.net>

update CODING_STYLE

8ac5aaa9fa47622e480391886c34f052f5ff909d 01-Oct-2015 Lennart Poettering <lennart@poettering.net>

update CODING_STYLE with various additions

59f448cf15f94bc5ebfd5b254de6f2441d02fbec 10-Sep-2015 Lennart Poettering <lennart@poettering.net>

tree-wide: never use the off_t unless glibc makes us use it off_t is a really weird type as it is usually 64bit these days (at least in sane programs), but could theoretically be 32bit. We don't support off_t as 32bit builds though, but still constantly deal with safely converting from off_t to other types and back for no point. Hence, never use the type anymore. Always use uint64_t instead. This has various benefits, including that we can expose these values directly as D-Bus properties, and also that the values parse the same in all cases.

54c1f2d761b506132a709a7e8573c7b54d048cf0 05-Sep-2015 David Herrmann <dh.herrmann@gmail.com>

CODING_STYLE: mandate alphabetical include order systemd-internal headers must not rely on include order. That means, they either must contain forward-declarations of used types/functions, or they must include all dependencies on their own. Therefore, there is no reason to mandate an include order on the call-side. However, global includes should always be ordered first. We don't want local definitions to leak into global includes, possible changing their behavior. Apparently, namespacing is a complex problem that people are incapable of implementing properly.. Apart from "global before local", there is no reason to mandate a random include order (which we happen to do right now). Instead, mandate alphabetical ordering. The current rules do not have any benefit at all. They neither reduce include-complexity, nor allow easy auditing of include files. But with alphabetical ordering, we get duplicate-detection for free, it gets *much much* easier to figure out whether a header is already included, and it is trivial to add new headers.

cad6982291a0e3cae4b8b1fad140ffd512e2835c 31-Jul-2015 Lennart Poettering <lennart@poettering.net>

CODING_STYLE: say that "for (;;)" is better than "while (1)"

11c9f1e48a683fb2e78ee531016099d567baa19a 17-Jun-2015 Simon McVittie <simon.mcvittie@collabora.co.uk>

Stop talking about the "XDG" version of basename() XDG refers to X Desktop Group, a former name for freedesktop.org. This group is responsible for specifications like basedirs, .desktop files and icon naming, but as far as I know, it has never tried to redefine basename(). I think these references were meant to say XPG (X/Open Portability Guide), a precursor of POSIX. POSIX is better-known and less easily confused with XDG, and is how the basename(3) man page describes the libgen.h version of basename(). The other version of basename() is glibc-specific and is described in basename(3) as "the GNU version"; specifically mention that version, to disambiguate.

1811232c4cc5d93cb02d93ed448a712e88e30868 29-May-2015 Lennart Poettering <lennart@poettering.net>

CODING_STYLE: document order in which to #include headers

8cb1cc8dc339be9f96cd290882d775cccfc4d7e7 18-May-2015 Lennart Poettering <lennart@poettering.net>

CODING_STYLE: document that we should avoid kernel types like u32

0fef704c6fbb07cb0289eadc405f49286aa70e53 15-May-2015 Lennart Poettering <lennart@poettering.net>

CODING_STYLE: document that EXIT_FAILURE and EXIT_SUCCESS should be used

a5ecb0cec25befafdee1e32c6f24cda8e29f89af 15-May-2015 Lennart Poettering <lennart@poettering.net>

CODING_STYLE: document best practices when initializing structs

42706f47c918b035dee82f4bad15bf6499592d1c 15-May-2015 Lennart Poettering <lennart@poettering.net>

CODING_STYLE: document alloca() DONTS

2708526c4ade0473b95f6c93d21f6d516b89a924 22-Apr-2015 Lennart Poettering <lennart@poettering.net>

CODING_STYLE: document that we prefer /* comments */ over // comments

ba780c116fc919c58fad07f45f4e800a062af63e 21-Apr-2015 Lennart Poettering <lennart@poettering.net>

CODING_STYLE: document how destructors should work

9ff3e22aa93fe461f8971f2468c65dc928fadc9e 03-Apr-2015 Lennart Poettering <lennart@poettering.net>

CODING_STYLE: mention that dup() should not be used

3dbafa39b08025350e7b17f4874a343c789ff9b3 02-Apr-2015 Lennart Poettering <lennart@poettering.net>

CODING_STYLE: clarify that exit() is never OK to call

918315e457ca36cab94ff3b6060e143968c99ace 10-Mar-2015 Lennart Poettering <lennart@poettering.net>

CODING_STYLE: mention casting of function invocations to (void)

ddb64d82708da0cdd0a88fa433260d2e60bffb64 28-Feb-2015 Lennart Poettering <lennart@poettering.net>

update TODO

eef46c372f64f40dd75415b2c504c73138719c8d 11-Feb-2015 Lennart Poettering <lennart@poettering.net>

tree-wide: whenever we include libgen.h, immediately undefine basename() Also, document in adjacent comments and in CODING_STYLE why we do that.

699eee62d1b1ad8af1ca944a1b500b6c3096de0d 10-Feb-2015 Lennart Poettering <lennart@poettering.net>

CODING_STYLE: elaborate on O_CLOEXEC a bit

798d3a524ea57aaf40cb53858aaa45ec702f012d 04-Feb-2015 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>

Reindent man pages to 2ch

CODING_STYLE man/binfmt.d.xml man/bootchart.conf.xml man/bootctl.xml man/bootup.xml man/coredumpctl.xml man/crypttab.xml man/daemon.xml man/file-hierarchy.xml man/halt.xml man/hostname.xml man/hostnamectl.xml man/journald.conf.xml man/kernel-command-line.xml man/locale.conf.xml man/localectl.xml man/localtime.xml man/loginctl.xml man/logind.conf.xml man/machine-id.xml man/machine-info.xml man/machinectl.xml man/modules-load.d.xml man/nss-myhostname.xml man/nss-mymachines.xml man/os-release.xml man/pam_systemd.xml man/resolved.conf.xml man/runlevel.xml man/sd-daemon.xml man/sd-id128.xml man/sd-journal.xml man/sd-login.xml man/sd_booted.xml man/sd_bus_message_get_cookie.xml man/sd_bus_message_get_monotonic_usec.xml man/sd_bus_request_name.xml man/sd_get_seats.xml man/sd_id128_get_machine.xml man/sd_id128_randomize.xml man/sd_id128_to_string.xml man/sd_is_fifo.xml man/sd_journal_add_match.xml man/sd_journal_get_catalog.xml man/sd_journal_get_cursor.xml man/sd_journal_get_cutoff_realtime_usec.xml man/sd_journal_get_data.xml man/sd_journal_get_fd.xml man/sd_journal_get_realtime_usec.xml man/sd_journal_get_usage.xml man/sd_journal_next.xml man/sd_journal_open.xml man/sd_journal_print.xml man/sd_journal_query_unique.xml man/sd_journal_seek_head.xml man/sd_journal_stream_fd.xml man/sd_listen_fds.xml man/sd_login_monitor_new.xml man/sd_machine_get_class.xml man/sd_notify.xml man/sd_pid_get_session.xml man/sd_seat_get_active.xml man/sd_session_is_active.xml man/sd_uid_get_state.xml man/sd_watchdog_enabled.xml man/shutdown.xml man/sysctl.d.xml man/systemd-analyze.xml man/systemd-ask-password-console.service.xml man/systemd-ask-password.xml man/systemd-backlight@.service.xml man/systemd-binfmt.service.xml man/systemd-bootchart.xml man/systemd-cat.xml man/systemd-cgls.xml man/systemd-cgtop.xml man/systemd-cryptsetup-generator.xml man/systemd-cryptsetup@.service.xml man/systemd-debug-generator.xml man/systemd-delta.xml man/systemd-detect-virt.xml man/systemd-efi-boot-generator.xml man/systemd-escape.xml man/systemd-firstboot.xml man/systemd-fsck@.service.xml man/systemd-fstab-generator.xml man/systemd-getty-generator.xml man/systemd-gpt-auto-generator.xml man/systemd-halt.service.xml man/systemd-hibernate-resume-generator.xml man/systemd-hibernate-resume@.service.xml man/systemd-hostnamed.service.xml man/systemd-inhibit.xml man/systemd-initctl.service.xml man/systemd-journald.service.xml man/systemd-localed.service.xml man/systemd-logind.service.xml man/systemd-machine-id-commit.service.xml man/systemd-machine-id-commit.xml man/systemd-machine-id-setup.xml man/systemd-machined.service.xml man/systemd-modules-load.service.xml man/systemd-networkd-wait-online.service.xml man/systemd-networkd.service.xml man/systemd-notify.xml man/systemd-nspawn.xml man/systemd-path.xml man/systemd-quotacheck.service.xml man/systemd-random-seed.service.xml man/systemd-remount-fs.service.xml man/systemd-resolved.service.xml man/systemd-rfkill@.service.xml man/systemd-shutdownd.service.xml man/systemd-socket-proxyd.xml man/systemd-suspend.service.xml man/systemd-sysctl.service.xml man/systemd-system-update-generator.xml man/systemd-system.conf.xml man/systemd-sysusers.xml man/systemd-timedated.service.xml man/systemd-timesyncd.service.xml man/systemd-tmpfiles.xml man/systemd-tty-ask-password-agent.xml man/systemd-update-done.service.xml man/systemd-update-utmp.service.xml man/systemd-user-sessions.service.xml man/systemd-vconsole-setup.service.xml man/systemd.automount.xml man/systemd.device.xml man/systemd.exec.xml man/systemd.journal-fields.xml man/systemd.kill.xml man/systemd.link.xml man/systemd.mount.xml man/systemd.netdev.xml man/systemd.network.xml man/systemd.path.xml man/systemd.preset.xml man/systemd.service.xml man/systemd.snapshot.xml man/systemd.socket.xml man/systemd.special.xml man/systemd.swap.xml man/systemd.target.xml man/systemd.time.xml man/systemd.timer.xml man/systemd.unit.xml man/systemd.xml man/sysusers.d.xml man/telinit.xml man/timedatectl.xml man/timesyncd.conf.xml man/vconsole.conf.xml
dd4540da0e1f983540d862cc657df7161a3bdd06 30-Oct-2014 Lennart Poettering <lennart@poettering.net>

CODING_STYLE: clarify that we really should use O_CLOEXEC everywhere

7f8bf08f9036de419ad14c55b61eda74c6659d3a 27-Oct-2014 Lennart Poettering <lennart@poettering.net>

CODING_STYLE: don't clobber arguments on failure

61f33134fc9231e07e1b9519b140d68139e9fad0 22-Oct-2014 Lennart Poettering <lennart@poettering.net>

CODING_STYLE: clarify that single-line if blocks should not be enclosed in {}

06b643e7f5a3b79005dd57497897ab7255fe3659 30-Aug-2014 Ruben Kerkhof <ruben@rubenkerkhof.com>

Fix a few more typos

3fdbc8205885f117b7dea289b44217310663e731 21-Aug-2014 Lennart Poettering <lennart@poettering.net>

CODING_STYLE: document that we don't break lines at 80ch

601185b43da638b1c74153deae01dbd518680889 04-Aug-2014 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>

Unify parse_argv style getopt is usually good at printing out a nice error message when commandline options are invalid. It distinguishes between an unknown option and a known option with a missing arg. It is better to let it do its job and not use opterr=0 unless we actually want to suppress messages. So remove opterr=0 in the few places where it wasn't really useful. When an error in options is encountered, we should not print a lengthy help() and overwhelm the user, when we know precisely what is wrong with the commandline. In addition, since help() prints to stdout, it should not be used except when requested with -h or --help. Also, simplify things here and there.

CODING_STYLE src/activate/activate.c src/analyze/analyze.c src/ask-password/ask-password.c src/binfmt/binfmt.c src/boot/bootctl.c src/bootchart/bootchart.c src/bus-proxyd/bus-proxyd.c src/cgls/cgls.c src/cgtop/cgtop.c src/core/main.c src/core/shutdown.c src/delta/delta.c src/detect-virt/detect-virt.c src/escape/escape.c src/firstboot/firstboot.c src/hostname/hostnamectl.c src/journal-remote/journal-gatewayd.c src/journal-remote/journal-remote.c src/journal/cat.c src/journal/coredumpctl.c src/journal/journalctl.c src/libsystemd/sd-bus/busctl.c src/locale/localectl.c src/login/inhibit.c src/login/loginctl.c src/machine-id-setup/machine-id-setup-main.c src/machine/machinectl.c src/modules-load/modules-load.c src/network/networkd-wait-online.c src/notify/notify.c src/nspawn/nspawn.c src/path/path.c src/readahead/readahead.c src/resolve-host/resolve-host.c src/run/run.c src/sleep/sleep.c src/socket-proxy/socket-proxyd.c src/sysctl/sysctl.c src/systemctl/systemctl.c src/sysusers/sysusers.c src/test/test-libudev.c src/timedate/timedatectl.c src/tmpfiles/tmpfiles.c src/tty-ask-password-agent/tty-ask-password-agent.c src/udev/udevadm.c
8e5edf8d42d3c441e4b09aa1dbbaf2cb605c1328 28-Jun-2014 Jan Engelhardt <jengelh@inai.de>

doc: use expanded forms for written style

45df8656ebb1b0559a75993d1508fc61c2d39829 28-Jun-2014 Jan Engelhardt <jengelh@inai.de>

doc: typographical improvements and choice of words

8d0e0ddda6501479eb69164687c83c1a7667b33a 28-Jun-2014 Jan Engelhardt <jengelh@inai.de>

doc: grammatical corrections

865cc19a34cd9a3ff98a7b3754747f4904f56faa 25-May-2014 Jonathan Boulle <jonathanboulle@gmail.com>

Fix several small typos

d3a485135a98184cba28992752834a1bb4769003 09-Dec-2013 Lennart Poettering <lennart@poettering.net>

extend CODING_STYLE document a bit

f168c27313e4d7b0aabee037dc9c78a5799f0597 03-Dec-2013 Thomas Hindoe Paaboel Andersen <phomes@gmail.com>

trivial coding style clean ups - Add space between if/for and the opening parentheses - Place the opening brace on same line as the function (not for udev) From the CODING_STYLE Try to use this: void foo() { } instead of this: void foo() { }

c170f3a41bc69ad1eab2dba40cede865f2532bbc 08-Mar-2013 Lennart Poettering <lennart@poettering.net>

analyze: various cleanups Update systemd-analyze to follow the coding style of the other tools more closely. Also, update the CODING_STYLE to document this for future additions. Changes: - Always use usec_t for time units, so that we always use the same types everywhere, and format times the same way as everywhere else. - Add "static" to global variables - Make sure we can always distuingish OOM and other errors: ensure we always return useful error codes from all functions. - Always free unit_times array

01233fc71296bc78c2de14b755236ced752500f7 29-Jan-2013 Tollef Fog Heen <tfheen@err.no>

Clarify sentence

ee7326a636ae11747fa1d281d1131952a60a0903 01-Oct-2012 Tollef Fog Heen <tfheen@err.no>

Minor typo

f49f49ba133daf18c7690c733755eeaad075b858 01-Oct-2012 Tollef Fog Heen <tfheen@err.no>

Be consistent about "." vs no "." at the end of lines"

35b8ca3aaf8cb044ad76675dfcad89e000dd4a5c 28-Feb-2011 Harald Hoyer <harald@redhat.com>

Spelling Corrections Just some lame spelling corrections with no functionality.

debf93a4d6d691d8904e7f485ac6579844abadf4 14-Feb-2010 Lennart Poettering <lennart@poettering.net>

CODING_STYLE: minor updates

e1cc7a01bb4663b4aea307cf22368bb5568a9e46 18-Nov-2009 Lennart Poettering <lennart@poettering.net>

CODING_STYLE: add missing -

6091827530d6dd43479d6709fb6e9f745c11e900 18-Nov-2009 Lennart Poettering <lennart@poettering.net>

initial commit