summaryrefslogtreecommitdiff
path: root/src/basic/macro.h
Commit message (Collapse)AuthorAge
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-08-24
| | | | | | | | | | | 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.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-08-24
| | | | | | | | | | | | | | | | 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.
* Add macro for checking if some flags are setZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | This way we don't need to repeat the argument twice. I didn't replace all instances. I think it's better to leave out: - asserts - comparisons like x & y == x, which are mathematically equivalent, but here we aren't checking if flags are set, but if the argument fits in the flags.
* macro: don't rely on C's downgrade-to-bool feature for numeric comparisonsLennart Poettering2018-08-24
|
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* fuzz-unit-file: add __has_feature(memory_sanitizer) when skipping ListenNetlink=Zbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | | https://clang.llvm.org/docs/MemorySanitizer.html#id5 documents this check as the way to detect MemorySanitizer at compilation time. We only need to skip the test if MemorySanitizer is used. Also, use this condition in cg_slice_to_path(). There, the code that is conditionalized is not harmful in any way (it's just unnecessary), so remove the FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION condition. Fixes #8482.
* Prep v238: Mask cg_trim() call in manager_shutdown_cgroup() as elogind is ↵Sven Eden2018-06-28
| | | | not init.
* basic/macros: rename noreturn into _noreturn_ (#8456)Franck Bui2018-06-28
| | | | | | | | | | | | | | | "noreturn" is reserved and can be used in other header files we include: [ 16s] In file included from /usr/include/gcrypt.h:30:0, [ 16s] from ../src/journal/journal-file.h:26, [ 16s] from ../src/journal/journal-vacuum.c:31: [ 16s] /usr/include/gpg-error.h:1544:46: error: expected ‘,’ or ‘;’ before ‘)’ token [ 16s] void gpgrt_log_bug (const char *fmt, ...) GPGRT_ATTR_NR_PRINTF(1,2); Here we include grcrypt.h (which in turns include gpg-error.h) *after* we "noreturn" was defined in macro.h. (cherry picked from commit 848e863acc51ecfb0f3955c498874588201d9130)
* coverity: don't use (void)0 under coverityZbigniew Jędrzejewski-Szmek2018-05-30
| | | | | | | | | | I'm not sure why this is needed, but apparrently coverity doesn't like (void)0. With this change, coverity can (almost) build systemd: CFLAGS='-D_Float128="long double"' meson cov-build -Dman=false && \ CCACHE_DISABLE=1 COVERITY_UNSUPPORTED=1 cov-build --dir cov-int ninja -C cov-build Patch originially by Marek Cermak <macermak@redhat.com>.
* Prep v236 : Add missing SPDX-License-Identifier (2/9) src/basicSven Eden2018-03-26
|
* basic/macros: add STRLEN() to get length of string literal as constant ↵Thomas Haller2017-12-13
| | | | | | | | | | | | | | | | | | expression While the compiler likely optimizes strlen(x) for string literals, it is not a constant expression. Hence, char buffer[strlen("OPTION_000") + 1]; declares a variable-length array. STRLEN() can be used instead when a constant espression is needed. It's not entirely identical to strlen(), as STRLEN("a\0") counts 2. Also, it only works with string literals and the macro enforces that the argument is a literal.
* __attribute__((fallthrough)) only when -Wimplicit-fallthrough (#7448)Shawn Landden2017-11-24
| | | | | | | | | | | | | That is version 7 or greater https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/ Fix regression of https://github.com/elogind/elogind/pull/7389 82a27ba8217d09e4fef4c9550f8b733d174c5705 on older gccs bumping to re-run CI upstream FAIL timed out boot-smoke FAIL non-zero exit status 1
* tree-wide: adjust fall through comments so that gcc is happyShawn Landden2017-11-19
| | | | | | | | Distcc removes comments, making the comment silencing not work. I know there was a decision against a macro in commit ec251fe7d5bc24b5d38b0853bc5969f3a0ba06e2
* tree-wide: drop assert.h includesZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | We provide an independent reimplementation in macro.h, and that's the one we want to use. Including the system header is unnecessary and confusing.
* networkd: add support to configure VLAN on bridge portsTobias Jungel2017-06-16
|
* basic/macros: clang 3.5 doesn't support alloc_sizeZbigniew Jędrzejewski-Szmek2017-06-16
| | | | | | The attribute was removed in commit c047507 in the clang repository as it was never properly implemented anyway. Avoid using the attribute with clang because it generates a ton of annoying warnings.
* include sys/sysmacros.h in more placesMike Frysinger2017-06-16
| | | | | | Since glibc is moving away from implicitly including sys/sysmacros.h all the time via sys/types.h, include the header directly in more places. This seems to cover most makedev/major/minor usage.
* tree-wide: minor formatting inconsistency cleanupsVito Caputo2017-06-16
|
* resolved: fix notification iteration logic when transactions are completedLennart Poettering2017-06-16
| | | | | | | | | | | | | | | | | | When a transaction is complete, and we notify its owners, make sure we deal correctly with the requesters removing themselves from the list of owners while we continue iterating. This was previously already dealt with with transactions that require other transactions for DNSSEC purposes, fix this for other possibly transaction owners too now. Since iterating through "Set" objects is not safe regarding removal of entries from it, rework the logic to use two Sets, and move each entry we notified from one set to the other set before we dispatch the notification. This move operation requires no additional memory, and enables us to ensure that we don't notify any object twice. Fixes: #2676
* tree-wide: remove Emacs lines from all filesDaniel Mack2017-05-17
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* macro.h: provide a switch-case statement generator for IN_SETDaniel Mack2017-05-17
| | | | | | | | | | | | Rather than walking a list of valid values one-by-one, generate a switch-case statement for the IN_SET() macro. This allows the compiler to further optimize its code output, possibly by generating jump tables. This effectively decreases the binary size slightly. The implementation is based on macro overloading depending on the number of arguments. h/t to the following post: https://stackoverflow.com/questions/11761703/overloading-macro-on-number-of-arguments
* Prep v228: Add remaining updates from upstream (2/3)Sven Eden2017-04-26
| | | | | Apply remaining fixes and the performed move of utility functions into their own foo-util.[hc] files on libbasic.
* [1/5] Apply missing fixes from upstreamSven Eden2017-03-29
|
* basic: make sure argument of ELEMENTSOF is an arrayMichal Schmidt2017-03-29
| | | | Using ELEMENTSOF on a pointer will result in a compilation error.
* basic: nicer assert messagesMichal Schmidt2017-03-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make sure the assert expression is not macro-expanded before stringification. This makes several assertion failure messages more readable. As an example: assert(streq("foo", "bar")); I'd rather see this: Assertion 'streq("foo", "bar")' failed at foo.c:5, function main(). Aborting. ...than this, though awesome, incomprehensible truncated mess: Assertion '(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (( "foo")) && __builtin_constant_p (("bar")) && (__s1_len = strlen (("foo")), __s2_ len = strlen (("bar")), (!((size_t)(const void *)((("foo")) + 1) - (size_t)(cons t void *)(("foo")) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((("bar") ) + 1) - (size_t)(const void *)(("bar")) == 1) || __s2_len >= 4)) ? __builtin_st rcmp (("foo"), ("bar")) : (__builtin_constant_p (("foo")) && ((size_t)(const voi d *)((("foo")) + 1) - (size_t)(const void *)(("foo")) == 1) && (__s1_len = strle n (("foo")), __s1_len < 4) ? (__builtin_constant_p (("bar")) && ((size_t)(const void *)((("bar")) + 1) - (size_t)(const void *)(("bar")) == 1) ? __builtin_strcm p (("foo"), ("bar")) : (__extension__ ({ const unsigned char *__s2 = (const unsi gned char *) (const char *) (("bar")); int __result = (((const unsigned char *) (const char *) (("foo")))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __ result = (((const unsigned char *) (const char *) (("foo")))[1] - __s2[1]); if ( __s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const cha r *) (("foo")))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = ((( const unsigned char *) (const char *) (("foo")))[3] - __s2[3]); } } __result; }) )) : (__builtin_constant_p (("bar")) && ((size_t)(const void *)((("bar")) + 1) - (size_t)(const void *)(("bar")) == 1) && (__s2_len = strlen (("bar")), __s2_len < 4) ? (__builtin_constant_p (("foo")) && ((size_t)(const void *)((("foo")) + 1 ) - (size_t)(const void *)(("foo")) == 1) ? __builtin_strcmp (("foo"), ("bar")) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (cons t char *) (("foo")); int __result = (((const unsigned char *) (const char *) ((" bar")))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (("bar")))[1] - __s2[1]); if (__s2_len > 1 && __ result == 0) { __result = (((const unsigned char *) (const char *) (("bar")))[2] - __s2[2]); if (__s2_len > 2 && __result == 0)
* include sys/sysmacros.h in more placesMike Frysinger2016-03-14
| | | | | | Since glibc is moving away from implicitly including sys/sysmacros.h all the time via sys/types.h, include the header directly in more places. This seems to cover most makedev/major/minor usage.
* Prep v226: Apply missing fixes and changes to src/basicSven Eden2017-03-14
|
* Prep v225: Applying various fixes and changes to src/basic that got lost ↵Sven Eden2017-03-14
| | | | during git am transfer.
* Prep v221: Update and clean up build system to sync with upstreamSven Eden2017-03-14
This commit replays the moving around of source files that have been done between systemd-219 and systemd-221. Further the Makefile.am is synchronized with the upstream version and then "re-cleaned". A lot of functions, that are not used anywhere in elogind have been coated into #if 0/#endif directives to further shorten the list of dependencies. All unneeded files have been removed.