summaryrefslogtreecommitdiffstats
path: root/src/basic/format-util.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* basic: add a size check to format timex members properlyMike Gilbert2021-12-201-2/+4
| | | | | | | As of glibc-2.34, the size of members in struct timex varies depending on the _TIME_BITS macro. Fixes: https://github.com/systemd/systemd/issues/21826
* tree-wide: make format_ifname() or friends return negative errno on failureYu Watanabe2021-09-281-3/+16
| | | | | | | | Also, - drop unnecessary +1 from buffer size, as IF_NAMESIZE or IFNAMSIZ includes the nul at the end. - format_ifname() does not update buffer on failure, - introduces format_ifname_alloc(), FORMAT_IFNAME(), and their friends.
* basic/{time,format}-util: warn when format result is unusedZbigniew Jędrzejewski-Szmek2021-07-091-1/+2
| | | | | Now that anonymous buffers are used in almost all cases, code which does not use the return value is usually broken.
* Replace format_bytes_cgroup_protection with FORMAT_BYTES_CGROUP_PROTECTIONZbigniew Jędrzejewski-Szmek2021-07-091-7/+1
|
* tree-wide: add FORMAT_BYTES_FULL()Zbigniew Jędrzejewski-Szmek2021-07-091-0/+1
|
* tree-wide: add FORMAT_BYTES()Zbigniew Jędrzejewski-Szmek2021-07-091-0/+5
|
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* util: make size macros unsignedLennart Poettering2020-10-201-1/+4
| | | | | | | | | By making them unsigned comparing them with other sizes is less likely to trigger compiler warnings regarding signed/unsigned comparisons. After all sizes (i.e. size_t) are generally assumed to be unsigned, so these should be too. Prompted-by: https://github.com/systemd/systemd/pull/17345#issuecomment-709402332
* cgroup: systemctl: Don't display NULL if protection was set to maxChris Down2020-02-051-1/+9
| | | | | | | | | | | | | | | | | | | | | | | Inside format_bytes, we return NULL if the value is UINT64_MAX. This makes some kind of sense where this has some other semantic meaning than being a value, but in this case the value is both a.) not the default (so we definitely want to display it), and b.) means "infinity" (or "max" in cgroup terminology). This patch adds a small wrapper around format_bytes that can be used for these cases, to avoid the following situation: [root@tangsanjiao ~]# cat /sys/fs/cgroup/workload.slice/memory.low max [root@tangsanjiao ~]# systemctl show workload.slice -p MemoryLow MemoryLow=infinity [root@tangsanjiao ~]# systemctl status workload.slice | grep low: Memory: 14.9G (low: (null)) After the patch: [root@tangsanjiao ~]# systemctl status workload.slice | grep low: Memory: 15.1G (low: infinity)
* util: uid_t, gid_t, and pid_t must be 32bitYu Watanabe2020-02-021-21/+8
| | | | | We already have assert_cc(sizeof(uid_t) == sizeof(uint32_t)) or friends at various places.
* format-util: introduce format_ifname_full()Yu Watanabe2019-10-241-1/+9
|
* util: introduce format_bytes_full()Yu Watanabe2019-06-191-0/+13
| | | | And move it into format-util.c.
* util: introduce format_ifname()Yu Watanabe2019-05-291-0/+3
|
* tree-wide: drop double newlineYu Watanabe2018-06-291-1/+0
|
* tree-wide: drop copyright headers from frequent contributorsZbigniew Jędrzejewski-Szmek2018-06-201-3/+0
| | | | | | | | Fixes #9320. for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms' done
* tree-wide: beautify remaining copyright statementsLennart Poettering2018-06-141-1/+1
| | | | | | Let's unify an beautify our remaining copyright statements, with a unicode ©. This means our copyright statements are now always formatted the same way. Yay.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | 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.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | 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.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* timesync/timesyncd-manager: fix format-specifier issuesMatija Skala2017-05-191-0/+6
| | | | | | | | | | timex::time::tv_usec and timex::freq can have different sizes depending on the host architecture. On x32 in particular, it is 8 bytes long while the long int type is only 4 bytes long. Hence, using li as a format specifier will trigger a format error. Thus, introduce a new format specifier PRI_TIMEX which is defined as PRIi64 on x32 and li everywhere else.
* Rename formats-util.h to format-util.hZbigniew Jędrzejewski-Szmek2016-11-071-0/+79
We don't have plural in the name of any other -util files and this inconsistency trips me up every time I try to type this file name from memory. "formats-util" is even hard to pronounce.