mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-27 00:22:22 +00:00
e69e015634
glibc 2.10+ (5+ years old) enables all the desired features: _XOPEN_SOURCE 700, __XOPEN2K8, POSIX_C_SOURCE, DEFAULT_SOURCE; with a single _GNU_SOURCE define in the makefile alone. For portability to other libc implementations (e.g. dietlibc) _XOPEN_SOURCE=700 is also defined. This also resolves Debian bug report filed by Michael Tautschnig - "Inconsistent use of _XOPEN_SOURCE results in conflicting declarations". Whilst I was not able to reproduce the results, the reported fact is that _XOPEN_SOURCE set to 500 in one set of files (e.g. cmds-filesystem.c) generates/defines different struct stat from other files (cmds-replace.c). This patch thus cleans up all feature defines, and sets them at a consistent level. Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=747969 Signed-off-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com> Signed-off-by: David Sterba <dsterba@suse.cz>
41 lines
911 B
C
41 lines
911 B
C
#include "kerncompat.h"
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include <limits.h>
|
|
|
|
#if BTRFS_FLAT_INCLUDES
|
|
#else
|
|
#endif /* BTRFS_FLAT_INCLUDES */
|
|
|
|
/*
|
|
* This function should be only used when parsing command arg, it won't return
|
|
* error to its caller and rather exit directly just like usage().
|
|
*/
|
|
u64 arg_strtou64(const char *str)
|
|
{
|
|
u64 value;
|
|
char *ptr_parse_end = NULL;
|
|
|
|
value = strtoull(str, &ptr_parse_end, 0);
|
|
if (ptr_parse_end && *ptr_parse_end != '\0') {
|
|
fprintf(stderr, "ERROR: %s is not a valid numeric value.\n",
|
|
str);
|
|
exit(1);
|
|
}
|
|
|
|
/*
|
|
* if we pass a negative number to strtoull, it will return an
|
|
* unexpected number to us, so let's do the check ourselves.
|
|
*/
|
|
if (str[0] == '-') {
|
|
fprintf(stderr, "ERROR: %s: negative value is invalid.\n",
|
|
str);
|
|
exit(1);
|
|
}
|
|
if (value == ULLONG_MAX) {
|
|
fprintf(stderr, "ERROR: %s is too large.\n", str);
|
|
exit(1);
|
|
}
|
|
return value;
|
|
}
|