Commit Graph

52 Commits

Author SHA1 Message Date
Lennart Poettering e28c7cd066 tree-wide: set SA_RESTART for signal handlers we install
We already set it in most cases, but make sure to set it in all others too, and
document that that's a good idea.
2016-12-01 12:41:17 +01:00
Lennart Poettering 9d372fe9af CODING_STYLE fixes (#3804)
As noted by @evverx:

0b81133fac (r72126018)
0b81133fac (r72126432)
2016-07-25 22:34:42 +03:00
Lennart Poettering 0b81133fac CODING_STYLE: document src/shared ←→ src/basic split
Addresses: https://github.com/systemd/systemd/pull/3580#issuecomment-227931168

While we are at it, also document that we focus on glibc, not any other libcs.
2016-07-25 20:54:34 +02:00
Lennart Poettering 8e38570ebe tree-wide: htonl() is weird, let's use htobe32() instead (#3538)
Super-important change, yeah!
2016-06-15 01:26:01 +02:00
Lennart Poettering d5af8eeab8 Two CODING_STYLE additions 2016-06-06 19:02:33 +02:00
Lennart Poettering 10c6258e32 minor CODING_STYLE clarification 2016-05-02 11:17:07 +02:00
Lennart Poettering 7f8a0d7b41 update CODING_STYLE a bit 2016-04-12 13:43:31 +02:00
Torstein Husebø 96d4901149 treewide: fix typos and then/that use 2016-02-24 11:56:11 +01:00
Lennart Poettering 1c4e4227fa 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.
2016-01-25 17:19:19 +01:00
Lennart Poettering fa195fa775 CODING_STYLE: elaborate on usage of C99 fixed size integer types 2015-11-10 17:31:30 +01:00
Lennart Poettering ec566e4c7c update CODING_STYLE 2015-10-19 22:31:58 +02:00
Lennart Poettering 041f793b6b update CODING_STYLE 2015-10-08 12:49:59 +02:00
Lennart Poettering c7ddad5148 update CODING_STYLE 2015-10-06 15:52:03 +02:00
Lennart Poettering 8ac5aaa9fa update CODING_STYLE with various additions 2015-10-01 21:10:55 +02:00
Lennart Poettering 59f448cf15 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.
2015-09-10 18:16:18 +02:00
David Herrmann 54c1f2d761 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.
2015-09-05 18:24:26 +02:00
Lennart Poettering cad6982291 CODING_STYLE: say that "for (;;)" is better than "while (1)" 2015-07-31 20:00:07 +02:00
Simon McVittie 11c9f1e48a 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.
2015-06-17 11:23:46 +01:00
Lennart Poettering 1811232c4c CODING_STYLE: document order in which to #include headers 2015-05-29 20:12:17 +02:00
Lennart Poettering 8cb1cc8dc3 CODING_STYLE: document that we should avoid kernel types like u32 2015-05-18 18:47:52 +02:00
Lennart Poettering 0fef704c6f CODING_STYLE: document that EXIT_FAILURE and EXIT_SUCCESS should be used 2015-05-15 21:34:14 +02:00
Lennart Poettering a5ecb0cec2 CODING_STYLE: document best practices when initializing structs 2015-05-15 21:06:40 +02:00
Lennart Poettering 42706f47c9 CODING_STYLE: document alloca() DONTS 2015-05-15 15:47:37 +02:00
Lennart Poettering 2708526c4a CODING_STYLE: document that we prefer /* comments */ over // comments 2015-04-22 22:56:24 +02:00
Lennart Poettering ba780c116f CODING_STYLE: document how destructors should work 2015-04-21 00:58:56 +02:00
Lennart Poettering 9ff3e22aa9 CODING_STYLE: mention that dup() should not be used 2015-04-03 14:26:22 +02:00
Lennart Poettering 3dbafa39b0 CODING_STYLE: clarify that exit() is never OK to call 2015-04-02 12:17:41 +02:00
Lennart Poettering 918315e457 CODING_STYLE: mention casting of function invocations to (void) 2015-03-10 17:39:42 +01:00
Lennart Poettering ddb64d8270 update TODO 2015-02-28 17:38:38 +01:00
Lennart Poettering eef46c372f tree-wide: whenever we include libgen.h, immediately undefine basename()
Also, document in adjacent comments and in CODING_STYLE why we do that.
2015-02-11 18:50:38 +01:00
Lennart Poettering 699eee62d1 CODING_STYLE: elaborate on O_CLOEXEC a bit 2015-02-10 21:25:38 +01:00
Zbigniew Jędrzejewski-Szmek 798d3a524e Reindent man pages to 2ch 2015-02-03 23:11:35 -05:00
Lennart Poettering dd4540da0e CODING_STYLE: clarify that we really should use O_CLOEXEC everywhere 2014-10-30 17:05:25 +01:00
Lennart Poettering 7f8bf08f90 CODING_STYLE: don't clobber arguments on failure 2014-10-27 18:09:26 +01:00
Lennart Poettering 61f33134fc CODING_STYLE: clarify that single-line if blocks should not be enclosed in {} 2014-10-22 11:45:12 +02:00
Ruben Kerkhof 06b643e7f5 Fix a few more typos 2014-08-30 13:46:07 -04:00
Lennart Poettering 3fdbc82058 CODING_STYLE: document that we don't break lines at 80ch 2014-08-21 17:24:21 +02:00
Zbigniew Jędrzejewski-Szmek 601185b43d 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.
2014-08-03 21:46:07 -04:00
Jan Engelhardt 8e5edf8d42 doc: use expanded forms for written style 2014-06-28 00:06:31 -04:00
Jan Engelhardt 45df8656eb doc: typographical improvements and choice of words 2014-06-28 00:06:31 -04:00
Jan Engelhardt 8d0e0ddda6 doc: grammatical corrections 2014-06-28 00:06:30 -04:00
Jonathan Boulle 865cc19a34 Fix several small typos 2014-05-24 19:01:03 -04:00
Lennart Poettering d3a485135a extend CODING_STYLE document a bit 2013-12-09 23:04:05 +01:00
Thomas Hindoe Paaboel Andersen f168c27313 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()
    {
    }
2013-12-03 22:27:45 +01:00
Lennart Poettering c170f3a41b 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
2013-03-08 18:58:08 +01:00
Tollef Fog Heen 01233fc712 Clarify sentence 2013-01-29 17:57:16 +01:00
Tollef Fog Heen ee7326a636 Minor typo 2012-10-01 21:48:15 +02:00
Tollef Fog Heen f49f49ba13 Be consistent about "." vs no "." at the end of lines" 2012-10-01 21:40:58 +02:00
Harald Hoyer 35b8ca3aaf Spelling Corrections
Just some lame spelling corrections with no functionality.
2011-02-28 22:47:38 +01:00
Lennart Poettering debf93a4d6 CODING_STYLE: minor updates 2010-02-14 22:44:51 +01:00