diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-13 05:28:42 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-13 05:28:42 -0400 |
commit | 77c688ac87183537ed0fb84ec2cb8fa8ec97c458 (patch) | |
tree | d18e117e05c0d71463823536165ddd9ad75b6bc5 /tools/perf | |
parent | 5e40d331bd72447197f26525f21711c4a265b6a6 (diff) | |
parent | a457606a6f81cfddfc9da1ef2a8bf2c65a8eb35e (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs updates from Al Viro:
"The big thing in this pile is Eric's unmount-on-rmdir series; we
finally have everything we need for that. The final piece of prereqs
is delayed mntput() - now filesystem shutdown always happens on
shallow stack.
Other than that, we have several new primitives for iov_iter (Matt
Wilcox, culled from his XIP-related series) pushing the conversion to
->read_iter()/ ->write_iter() a bit more, a bunch of fs/dcache.c
cleanups and fixes (including the external name refcounting, which
gives consistent behaviour of d_move() wrt procfs symlinks for long
and short names alike) and assorted cleanups and fixes all over the
place.
This is just the first pile; there's a lot of stuff from various
people that ought to go in this window. Starting with
unionmount/overlayfs mess... ;-/"
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (60 commits)
fs/file_table.c: Update alloc_file() comment
vfs: Deduplicate code shared by xattr system calls operating on paths
reiserfs: remove pointless forward declaration of struct nameidata
don't need that forward declaration of struct nameidata in dcache.h anymore
take dname_external() into fs/dcache.c
let path_init() failures treated the same way as subsequent link_path_walk()
fix misuses of f_count() in ppp and netlink
ncpfs: use list_for_each_entry() for d_subdirs walk
vfs: move getname() from callers to do_mount()
gfs2_atomic_open(): skip lookups on hashed dentry
[infiniband] remove pointless assignments
gadgetfs: saner API for gadgetfs_create_file()
f_fs: saner API for ffs_sb_create_file()
jfs: don't hash direct inode
[s390] remove pointless assignment of ->f_op in vmlogrdr ->open()
ecryptfs: ->f_op is never NULL
android: ->f_op is never NULL
nouveau: __iomem misannotations
missing annotation in fs/file.c
fs: namespace: suppress 'may be used uninitialized' warnings
...
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/util/string.c | 90 |
1 files changed, 30 insertions, 60 deletions
diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c index 2553e5b55b89..d87767f76903 100644 --- a/tools/perf/util/string.c +++ b/tools/perf/util/string.c | |||
@@ -9,78 +9,48 @@ | |||
9 | */ | 9 | */ |
10 | s64 perf_atoll(const char *str) | 10 | s64 perf_atoll(const char *str) |
11 | { | 11 | { |
12 | unsigned int i; | 12 | s64 length; |
13 | s64 length = -1, unit = 1; | 13 | char *p; |
14 | char c; | ||
14 | 15 | ||
15 | if (!isdigit(str[0])) | 16 | if (!isdigit(str[0])) |
16 | goto out_err; | 17 | goto out_err; |
17 | 18 | ||
18 | for (i = 1; i < strlen(str); i++) { | 19 | length = strtoll(str, &p, 10); |
19 | switch (str[i]) { | 20 | switch (c = *p++) { |
20 | case 'B': | 21 | case 'b': case 'B': |
21 | case 'b': | 22 | if (*p) |
22 | break; | ||
23 | case 'K': | ||
24 | if (str[i + 1] != 'B') | ||
25 | goto out_err; | ||
26 | else | ||
27 | goto kilo; | ||
28 | case 'k': | ||
29 | if (str[i + 1] != 'b') | ||
30 | goto out_err; | ||
31 | kilo: | ||
32 | unit = K; | ||
33 | break; | ||
34 | case 'M': | ||
35 | if (str[i + 1] != 'B') | ||
36 | goto out_err; | ||
37 | else | ||
38 | goto mega; | ||
39 | case 'm': | ||
40 | if (str[i + 1] != 'b') | ||
41 | goto out_err; | 23 | goto out_err; |
42 | mega: | 24 | case '\0': |
43 | unit = K * K; | 25 | return length; |
26 | default: | ||
27 | goto out_err; | ||
28 | /* two-letter suffices */ | ||
29 | case 'k': case 'K': | ||
30 | length <<= 10; | ||
44 | break; | 31 | break; |
45 | case 'G': | 32 | case 'm': case 'M': |
46 | if (str[i + 1] != 'B') | 33 | length <<= 20; |
47 | goto out_err; | ||
48 | else | ||
49 | goto giga; | ||
50 | case 'g': | ||
51 | if (str[i + 1] != 'b') | ||
52 | goto out_err; | ||
53 | giga: | ||
54 | unit = K * K * K; | ||
55 | break; | 34 | break; |
56 | case 'T': | 35 | case 'g': case 'G': |
57 | if (str[i + 1] != 'B') | 36 | length <<= 30; |
58 | goto out_err; | ||
59 | else | ||
60 | goto tera; | ||
61 | case 't': | ||
62 | if (str[i + 1] != 'b') | ||
63 | goto out_err; | ||
64 | tera: | ||
65 | unit = K * K * K * K; | ||
66 | break; | 37 | break; |
67 | case '\0': /* only specified figures */ | 38 | case 't': case 'T': |
68 | unit = 1; | 39 | length <<= 40; |
69 | break; | 40 | break; |
70 | default: | ||
71 | if (!isdigit(str[i])) | ||
72 | goto out_err; | ||
73 | break; | ||
74 | } | ||
75 | } | 41 | } |
76 | 42 | /* we want the cases to match */ | |
77 | length = atoll(str) * unit; | 43 | if (islower(c)) { |
78 | goto out; | 44 | if (strcmp(p, "b") != 0) |
45 | goto out_err; | ||
46 | } else { | ||
47 | if (strcmp(p, "B") != 0) | ||
48 | goto out_err; | ||
49 | } | ||
50 | return length; | ||
79 | 51 | ||
80 | out_err: | 52 | out_err: |
81 | length = -1; | 53 | return -1; |
82 | out: | ||
83 | return length; | ||
84 | } | 54 | } |
85 | 55 | ||
86 | /* | 56 | /* |