/[gentoo-x86]/sys-fs/btrfs-progs/files/btrfs-progs-3.14.1-arg_strtou64.patch
Gentoo

Contents of /sys-fs/btrfs-progs/files/btrfs-progs-3.14.1-arg_strtou64.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Tue May 20 14:47:03 2014 UTC (4 years, 4 months ago) by floppym
Branch: MAIN
CVS Tags: HEAD
Backport patch to fix linking failures with libbtrfs, reported by dlan.

(Portage version: 2.2.10/cvs/Linux x86_64, signed Manifest commit with key 0BBEEA1FEA4843A4)

1 From: David Sterba <dsterba@suse.cz>
2 To: linux-btrfs@vger.kernel.org
3 Subject: [PATCH v2] btrfs-progs: move arg_strtou64 to a separate file for library
4 Date: Tue, 22 Apr 2014 17:49:01 +0200
5
6 Linking with libbtrfs fails because arg_strtou64 is not defined and we
7 cannot just add utils.o to library objects because it's not
8 library-clean.
9
10 Reported-by: Arvin Schnell <aschnell@suse.com>
11 Reported-by: Anton Farygin <rider@altlinux.org>
12 Signed-off-by: David Sterba <dsterba@suse.cz>
13 ---
14
15 v2: (thanks to Hugo)
16 - added missing line from comment
17 - fixed typo
18 - reformated comment paragraphs
19
20 Makefile | 5 +++--
21 utils-lib.c | 42 ++++++++++++++++++++++++++++++++++++++++++
22 utils.c | 33 ---------------------------------
23 3 files changed, 45 insertions(+), 35 deletions(-)
24 create mode 100644 utils-lib.c
25
26 diff --git a/Makefile b/Makefile
27 index 51d53fadf5af..76565e8b2307 100644
28 --- a/Makefile
29 +++ b/Makefile
30 @@ -9,14 +9,15 @@ CFLAGS = -g -O1 -fno-strict-aliasing
31 objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \
32 root-tree.o dir-item.o file-item.o inode-item.o inode-map.o \
33 extent-cache.o extent_io.o volumes.o utils.o repair.o \
34 - qgroup.o raid6.o free-space-cache.o list_sort.o props.o
35 + qgroup.o raid6.o free-space-cache.o list_sort.o props.o \
36 + utils-lib.o
37 cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \
38 cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \
39 cmds-quota.o cmds-qgroup.o cmds-replace.o cmds-check.o \
40 cmds-restore.o cmds-rescue.o chunk-recover.o super-recover.o \
41 cmds-property.o
42 libbtrfs_objects = send-stream.o send-utils.o rbtree.o btrfs-list.o crc32c.o \
43 - uuid-tree.o
44 + uuid-tree.o utils-lib.o
45 libbtrfs_headers = send-stream.h send-utils.h send.h rbtree.h btrfs-list.h \
46 crc32c.h list.h kerncompat.h radix-tree.h extent-cache.h \
47 extent_io.h ioctl.h ctree.h btrfsck.h
48 diff --git a/utils-lib.c b/utils-lib.c
49 new file mode 100644
50 index 000000000000..9d53c6e5c710
51 --- /dev/null
52 +++ b/utils-lib.c
53 @@ -0,0 +1,42 @@
54 +#define _GNU_SOURCE
55 +
56 +#include "kerncompat.h"
57 +#include <unistd.h>
58 +#include <stdlib.h>
59 +#include <limits.h>
60 +
61 +#if BTRFS_FLAT_INCLUDES
62 +#else
63 +#endif /* BTRFS_FLAT_INCLUDES */
64 +
65 +/*
66 + * This function should be only used when parsing command arg, it won't return
67 + * error to its caller and rather exit directly just like usage().
68 + */
69 +u64 arg_strtou64(const char *str)
70 +{
71 + u64 value;
72 + char *ptr_parse_end = NULL;
73 +
74 + value = strtoull(str, &ptr_parse_end, 0);
75 + if (ptr_parse_end && *ptr_parse_end != '\0') {
76 + fprintf(stderr, "ERROR: %s is not a valid numeric value.\n",
77 + str);
78 + exit(1);
79 + }
80 +
81 + /*
82 + * if we pass a negative number to strtoull, it will return an
83 + * unexpected number to us, so let's do the check ourselves.
84 + */
85 + if (str[0] == '-') {
86 + fprintf(stderr, "ERROR: %s: negative value is invalid.\n",
87 + str);
88 + exit(1);
89 + }
90 + if (value == ULLONG_MAX) {
91 + fprintf(stderr, "ERROR: %s is too large.\n", str);
92 + exit(1);
93 + }
94 + return value;
95 +}
96 diff --git a/utils.c b/utils.c
97 index 29953d9dd2a9..e130849c7bb5 100644
98 --- a/utils.c
99 +++ b/utils.c
100 @@ -1538,39 +1538,6 @@ scan_again:
101 return 0;
102 }
103
104 -/*
105 - * This function should be only used when parsing
106 - * command arg, it won't return error to it's
107 - * caller and rather exit directly just like usage().
108 - */
109 -u64 arg_strtou64(const char *str)
110 -{
111 - u64 value;
112 - char *ptr_parse_end = NULL;
113 -
114 - value = strtoull(str, &ptr_parse_end, 0);
115 - if (ptr_parse_end && *ptr_parse_end != '\0') {
116 - fprintf(stderr, "ERROR: %s is not a valid numeric value.\n",
117 - str);
118 - exit(1);
119 - }
120 - /*
121 - * if we pass a negative number to strtoull,
122 - * it will return an unexpected number to us,
123 - * so let's do the check ourselves.
124 - */
125 - if (str[0] == '-') {
126 - fprintf(stderr, "ERROR: %s: negative value is invalid.\n",
127 - str);
128 - exit(1);
129 - }
130 - if (value == ULLONG_MAX) {
131 - fprintf(stderr, "ERROR: %s is too large.\n", str);
132 - exit(1);
133 - }
134 - return value;
135 -}
136 -
137 u64 parse_size(char *s)
138 {
139 int i;
140 --
141 1.9.0
142
143 --
144 To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
145 the body of a message to majordomo@vger.kernel.org
146 More majordomo info at http://vger.kernel.org/majordomo-info.html

  ViewVC Help
Powered by ViewVC 1.1.20