Commit graph

22 commits

Author SHA1 Message Date
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Kamil Dudka 4191b3282a _sd-common.h: avoid parsing errors with Coverity
The commit 1070d271fa which was supposed
too fix this does not seem to take effect any more.  We get again 34%
compilation success rate while scanning systemd itself.  Moreover, the
installed header file breaks compilation of programs that include it:

"/usr/include/systemd/_sd-common.h", line 23: error #35: #error directive: "Do
          not include _sd-common.h directly; it is a private header."
  #  error "Do not include _sd-common.h directly; it is a private header."
     ^
2020-08-06 16:26:57 +02:00
Lennart Poettering 68312977db journal: properly mark two definitions that are deprecated with GCC attributes for that 2020-01-31 15:02:00 +01:00
Zbigniew Jędrzejewski-Szmek 4199f6896a Use c99 static array size declarations in exported functions too
It seems quite useful to provide this additional information in public exported
functions.

This is a c99 feature, not supported in C++. Without the check in _sd-common.h:
FAILED: test-bus-vtable-cc@exe/src_libsystemd_sd-bus_test-bus-vtable-cc.cc.o
...
In file included from ../src/libsystemd/sd-bus/test-bus-vtable-cc.cc:9:
In file included from ../src/systemd/sd-bus-vtable.h:26:
In file included from ../src/systemd/sd-bus.h:26:
../src/systemd/sd-id128.h:38:47: error: static array size is a C99 feature, not permitted in C++
char *sd_id128_to_string(sd_id128_t id, char s[static SD_ID128_STRING_MAX]);
                                              ^

In .c files, I opted to use the define for consistency, even though we don't support
compilation with a C++ compiler, so the unconditional keyword would work too.
2019-01-04 12:37:25 +01:00
Lennart Poettering 63e688cc3b
Merge pull request #11031 from poettering/gcc-attr-cleanup
various gcc attribute clean-ups
2018-12-03 21:59:00 +01:00
Lennart Poettering 2ee1c55d6c tree-wide: drop redundant space between __attribute__ and ((
We follow no general rule, but in most cases we do not place a space
outside of macro.h. Hence let's stick to that, and adapt macro.h too,
and follow the rule systematically that there shall not be a space
between __attribute__ and ((...

Yes, this does not matter at all, and is purely OCD cosmetics. But then
again, the uses of __attribute__ are very local only, hence the changes
cleaning this up are small and are unlikely to have to be repeated too
often...
2018-12-03 13:28:26 +01:00
Yu Watanabe deae09ccc5 libsystemd: introduce _sd_destroy_t 2018-12-02 06:21:11 +01:00
Lennart Poettering 012c2f761b tree-wide: use __ prefixed gcc attributes (#10843)
As suggest here:

https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html#Attribute-Syntax

    "You may optionally specify attribute names with ‘__’ preceding and
    following the name. This allows you to use them in header files without
    being concerned about a possible macro of the same name. For example,
    you may use the attribute name __noreturn__ instead of noreturn. "
2018-11-20 12:34:08 +09:00
Yu Watanabe 1e089bf805 tree-wide: drop empty lines in the begining of comments 2018-06-29 10:50:23 +09:00
Lennart Poettering 0c69794138 tree-wide: remove Lennart's copyright lines
These lines are generally out-of-date, incomplete and unnecessary. With
SPDX and git repository much more accurate and fine grained information
about licensing and authorship is available, hence let's drop the
per-file copyright notice. Of course, removing copyright lines of others
is problematic, hence this commit only removes my own lines and leaves
all others untouched. It might be nicer if sooner or later those could
go away too, making git the only and accurate source of authorship
information.
2018-06-14 10:20:20 +02:00
Lennart Poettering 818bf54632 tree-wide: drop 'This file is part of systemd' blurb
This part of the copyright blurb stems from the GPL use recommendations:

https://www.gnu.org/licenses/gpl-howto.en.html

The concept appears to originate in times where version control was per
file, instead of per tree, and was a way to glue the files together.
Ultimately, we nowadays don't live in that world anymore, and this
information is entirely useless anyway, as people are very welcome to
copy these files into any projects they like, and they shouldn't have to
change bits that are part of our copyright header for that.

hence, let's just get rid of this old cruft, and shorten our codebase a
bit.
2018-06-14 10:20:20 +02:00
Zbigniew Jędrzejewski-Szmek 53e1b68390 Add SPDX license identifiers to source files under the LGPL
This follows what the kernel is doing, c.f.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
2017-11-19 19:08:15 +01:00
Zbigniew Jędrzejewski-Szmek 1070d271fa headers: check that __INCLUDE_LEVEL__ is defined before using it (#5575)
That macro is a gcc extension, and while widely supported, not ubiquitous.
In particular the coverity scanner is having trouble with it.
2017-03-13 08:11:24 +01:00
Zbigniew Jędrzejewski-Szmek 0cb27225e9 headers: use __inline__ instead of inline
https://gcc.gnu.org/onlinedocs/gcc-5.3.0/gcc/Alternate-Keywords.html#Alternate-Keywords
recommends __inline__ over inline in ANSI C compatible headers.
Tested with gcc-5.3 and clang-3.7.

https://bugzilla.redhat.com/show_bug.cgi?id=1316964
2016-03-11 13:41:49 -05:00
Daniel Mack b26fa1a2fb tree-wide: remove Emacs lines from all files
This should be handled fine now by .dir-locals.el, so need to carry that
stuff in every file.
2016-02-10 13:41:57 +01:00
Lennart Poettering 20ba6c2ebe libsystemd: make sure we prefix even the dirty secrets in our API with "_sd_"
This renames __useless_struct_to_allow_trailing_semicolon__ everywhere
to _sd_useless_struct_to_allow_trailing_semicolon_, to follow our usual
rule of prefixing stuff from public headers that should be considered
internal with "_sd_".

While we are at it, also to be safe: when the struct is used in the C++
protector macros make sure to use two different names depending on
whether it appears in the C++ or C side of things. After all, there
might be compilers that don't consider C++ and C structs the same.

See https://github.com/systemd/systemd/pull/2052#discussion_r46067059
2015-11-27 20:33:04 +01:00
Lennart Poettering 4afd3348c7 tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easy
GLIB has recently started to officially support the gcc cleanup
attribute in its public API, hence let's do the same for our APIs.

With this patch we'll define an xyz_unrefp() call for each public
xyz_unref() call, to make it easy to use inside a
__attribute__((cleanup())) expression. Then, all code is ported over to
make use of this.

The new calls are also documented in the man pages, with examples how to
use them (well, I only added docs where the _unref() call itself already
had docs, and the examples, only cover sd_bus_unrefp() and
sd_event_unrefp()).

This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we
tend to call our destructors these days.

Note that this defines no public macro that wraps gcc's attribute and
makes it easier to use. While I think it's our duty in the library to
make our stuff easy to use, I figure it's not our duty to make gcc's own
features easy to use on its own. Most likely, client code which wants to
make use of this should define its own:

       #define _cleanup_(function) __attribute__((cleanup(function)))

Or similar, to make the gcc feature easier to use.

Making this logic public has the benefit that we can remove three header
files whose only purpose was to define these functions internally.

See #2008.
2015-11-27 19:19:36 +01:00
Jason St. John 10b17992ee src/systemd: fix grammar and spelling errors in comments 2014-03-25 20:23:33 +01:00
Lennart Poettering fd1b903adb include: make direct includion of _sd-common.h harder 2013-11-20 19:36:14 +01:00
Lennart Poettering 98f91566cc bus: export utf8 validator calls as pure functions 2013-11-12 00:12:44 +01:00
Lennart Poettering 0095c45415 api: replace manual C++ guards by macros 2013-11-07 16:53:26 +01:00
Lennart Poettering aacf3b483b api: unify some common bits used by public systemd APIs 2013-10-16 17:01:26 +02:00