Looks like those specifiers haven't been used since 6c9ab254ae
(where sscanf was removed) was merged. This should help to get
util-linux to compile with MSan. Currently it's failing with
```
...
configure: error: libmount selected, but required scanf string alloc modifier not available
...
configure:20240: ./conftest
==116617==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x496fd6 in main /home/vagrant/util-linux/conftest.c:171:6
#1 0x7f5eb85ea1a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
#2 0x41c2cd in _start (/home/vagrant/util-linux/conftest+0x41c2cd)
SUMMARY: MemorySanitizer: use-of-uninitialized-value /home/vagrant/util-linux/conftest.c:171:6 in main
Exiting
configure:20240: $? = 77
...
configure:20265: $? = 0
configure:20265: ./conftest
MemorySanitizer: bad pointer 0x000000496e60
==116627==MemorySanitizer CHECK failed: /builddir/build/BUILD/compiler-rt-9.0.1.src/lib/msan/../sanitizer_common/sanitizer_allocator_secondary.h:177 "((IsAligned(reinterpret_cast<uptr>(p), page_size_))) != (0)" (0x0, 0x0)
#0 0x41d1d8 in MsanCheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/home/vagrant/util-linux/conftest+0x41d1d8)
#1 0x484e1e in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/home/vagrant/util-linux/conftest+0x484e1e)
#2 0x42066c in __msan::MsanDeallocate(__sanitizer::StackTrace*, void*) (/home/vagrant/util-linux/conftest+0x42066c)
#3 0x424bc9 in free (/home/vagrant/util-linux/conftest+0x424bc9)
#4 0x496fae in main /home/vagrant/util-linux/conftest.c:173:2
#5 0x7f2245f311a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
#6 0x41c2cd in _start (/home/vagrant/util-linux/conftest+0x41c2cd)
configure:20265: $? = 77
configure: program exited with status 77
...
| }
configure:22568: result: no
configure:22926: error: libmount selected, but required scanf string alloc modifier not available
```
Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
Let's add "Arguments:" section to the --help output and describe
{K,M,G...}iB suffixes there.
Addresses: https://github.com/karelzak/util-linux/pull/917
Co-Author: ed <ed@s5h.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
It's mostly wrappers for compatibility and another trivial stuff etc.
Let's keep it as public domain to make it more portable to LGPL, GPL
and BSD code.
Signed-off-by: Karel Zak <kzak@redhat.com>
CC: Sami Kerola <kerolasa@iki.fi>
CC: Ruediger Meier <ruediger.meier@ga-group.nl>
The __has macros are more portable (supported by gcc as well as
clang).
The old __GNUC_PREREQ is deprecated and it should be removed in
future. (Well, the __has macros are supported since gcc 5, so we
should be patient as some old stable distros (e.g. RHEL 7) use gcc
4.x).
This patch helps clang to correctly analyze our xalloc.h stuff.
Signed-off-by: Karel Zak <kzak@redhat.com>
This reverts parts of commit eb06d5d4, which seems to be based on
Linux kernel commit c7acec71. Unlike the original kernel patch we did
not add that even stronger type checking by using macro BUILD_BUG_ON_MSG.
So basically we removed a useful warning when compiling such
broken code:
struct st {
int a;
char b;
};
struct st t = { .a = 1, .b = 2 };
struct st *x = container_of(&t.a, struct st, b);
printf("%p %p\n", (void *)&t, (void *)x);
Moreover we also introduced a new compiler warning for intel/icc:
"arithmetic on pointer to void or function type"
Let's just revert the update of container_of() because adding a
kernel-like BUILD_BUG_ON_MSG would be too much noise and also
problematic (see kernel commit c03567a8). Also note that the original
problem addressed by the kernel commit seems to be only reproducible
with gcc 4.9, not with any later gcc nor clang,icc. Moreover, currently
we have no such use-case in the UL sources anyways.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Let the compiler optimize based on the knowledge that the return value will
never be null.
Reference: https://patchwork.ozlabs.org/patch/281112/#631159
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The new errexec() macro consolidate and unify the way how util-linux
tools react to failed exec()-like functions:
* exit code 126 when program located, but not usable
* exit code 127 when could not find program to exec
The exit codes are compatible with coreutils.
Note that all the change is located in c.h; the file exitcodes.h
contains API specific (mkfs, fsck, ...) codes only.
Addresses: https://github.com/karelzak/util-linux/pull/311
Signed-off-by: Karel Zak <kzak@redhat.com>
changed in include/c.h and applied via sed:
sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c")
sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c")
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
We change
-h, --help display this help and exit
-V, --version output version information and exit
to
-h, --help display this help
-V, --version print version
Some thoughts about this:
* use "display" for --help because it matches better if we
would add pager support (like git --help)
* "print" for --version to be different
* "this" for --help is important to make clear that running
--help would not give you any better information than the
one you see already
* remove "information and exit" because it's bloat for the
short-help, everybody knows what it does if it exists
In the manpages we should use the old, longer but more correct
descriptions, inclusive a reminder if --help/--version are only
working when used as the only option. Note the term "version
information" indicates that we don't only print a single version
number.
CC: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Consolidate --help and --version descriptions. We are
now able to align them to the other options.
We changed include/c.h. The rest of this patch was
generated by sed, plus manually setting the right
alignment numbers. We do not change anything but
white spaces in the --help output.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
This reverts the include/c.h part of cc7cb070.
As discussed on ml. Our current strings are imported from
coreutils and not too bad. Also the old strings are still
hardcoded at many places.
So let's revert the change, then consolidate these strings
really everywhere and then think again whether and how we
should change them.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* '170622' of github.com:jwpi/util-linux:
Docs: move option naming to howto-contribute.txt
Docs: update howto-usage-function.txt
Docs: add a comment for constants to boilerplate.c
include/c.h: add USAGE_COMMANDS and USAGE_COLUMNS
Nowadays all our regular commands have --help options.
test_uuidd does not use translations anyways.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Make a functions heading, similar to the existing options heading.
* include/c.h: define USAGE_FUNCTIONS
* Documentation/boilerplate.c: add USAGE_FUNCTIONS
* sys-utils/hwclock.c add functions header to usage()
Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: J William Piggott <elseifthen@gmx.com>
The current agetty uses TIOCSTI ioctl to return already read chars
from login name back to the terminal (without read() before
tcsetattr() we will lost data already written by user). The ioctl
based solution is fragile due to race -- we can return chars when
terminal already contains another new chars. The result is reordered
chars in login name.
The solution is to use extra buffer for already read data.
Reported-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
The file is no portable (#ifdef HAVE_SYS_SYSMACROS_H is necessary),
but needed on many places. It seems better to keep it in c.h.
Signed-off-by: Karel Zak <kzak@redhat.com>
sysconf(_SC_GETPW_R_SIZE_MAX) returns initial suggested size for pwd
buffer (see getpwnam_r man page or POSIX). This is not large enough in
some cases.
Yes, this sysconf option is misnamed (should be _SC_GETPW_R_SIZE_MIN).
Signed-off-by: Karel Zak <kzak@redhat.com>
The kernel of FreeBSD version 10 and higher supports this fcntl command,
but the system libc, in this case glibc, might not yet know about it.
Signed-off-by: Guillem Jover <guillem@hadrons.org>
The problem is how fdisk_partition_cmp_start() compare numbers, the
function returns result from "a->start - b->start", unfortunately the
numbers are uint64, but function returns "int".
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1170191
Signed-off-by: Karel Zak <kzak@redhat.com>
This change has motivation to make -Wall -pedantic compiler options to
spit a little bit less noise, which with luck will increase change to
notice real issues.
Multiple of these:
warning: ISO C forbids braced-groups within expressions [-Wpedantic]
And nearly 300 times reported:
include/c.h:75:41: warning: struct has no named members [-Wpedantic]
#define UL_BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Let's use nanosleep() although if usleep() exists. The nanosleep
function does no interact with signals and other timers.
The patch introduces xusleep() as replacement to libc (or our fallback)
usleep(). Yes, we don't want to use struct timespec + nanosleep()
everywhere in code as nano-time resolution is useless for us.
The patch also enlarges delays in some busy wait loops. It seems
enough to try read/write 4x per second.
Signed-off-by: Karel Zak <kzak@redhat.com>