diff options
author | Namhyung Kim <namhyung.kim@lge.com> | 2012-05-07 01:09:01 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-05-07 15:46:48 -0400 |
commit | dfe78adaaca90417ece98edbd3eb1c9661334406 (patch) | |
tree | 537576730ce54f2ddee4d6266aad7c8f72258a45 /tools/perf/util/usage.c | |
parent | 60bbddaaa33865633efa2800702e3b02495a0e94 (diff) |
perf target: Introduce perf_target__parse_uid()
Add and use the modern perf_target__parse_uid() and get rid of the old
parse_target_uid().
Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1336367344-28071-5-git-send-email-namhyung.kim@lge.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/usage.c')
-rw-r--r-- | tools/perf/util/usage.c | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/tools/perf/util/usage.c b/tools/perf/util/usage.c index e851abc22ccc..4007aca8e0ca 100644 --- a/tools/perf/util/usage.c +++ b/tools/perf/util/usage.c | |||
@@ -82,34 +82,3 @@ void warning(const char *warn, ...) | |||
82 | warn_routine(warn, params); | 82 | warn_routine(warn, params); |
83 | va_end(params); | 83 | va_end(params); |
84 | } | 84 | } |
85 | |||
86 | uid_t parse_target_uid(const char *str) | ||
87 | { | ||
88 | struct passwd pwd, *result; | ||
89 | char buf[1024]; | ||
90 | |||
91 | if (str == NULL) | ||
92 | return UINT_MAX; | ||
93 | |||
94 | getpwnam_r(str, &pwd, buf, sizeof(buf), &result); | ||
95 | |||
96 | if (result == NULL) { | ||
97 | char *endptr; | ||
98 | int uid = strtol(str, &endptr, 10); | ||
99 | |||
100 | if (*endptr != '\0') { | ||
101 | ui__error("Invalid user %s\n", str); | ||
102 | return UINT_MAX - 1; | ||
103 | } | ||
104 | |||
105 | getpwuid_r(uid, &pwd, buf, sizeof(buf), &result); | ||
106 | |||
107 | if (result == NULL) { | ||
108 | ui__error("Problems obtaining information for user %s\n", | ||
109 | str); | ||
110 | return UINT_MAX - 1; | ||
111 | } | ||
112 | } | ||
113 | |||
114 | return result->pw_uid; | ||
115 | } | ||