perf target: str_error_r() always returns the buffer it receives
authorArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 29 Jul 2016 14:54:35 +0000 (11:54 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 29 Jul 2016 14:54:35 +0000 (11:54 -0300)
So no need for checking if it uses the strerror_r() GNU variant error
reporting mechanism, i.e. if it returns a pointer to a immutable string
internal to glibc.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Fixes: c8b5f2c96d1b ("tools: Introduce str_error_r()")
Link: http://lkml.kernel.org/n/tip-xr83cd4y4r3cn6tq6w4f59jb@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/target.c

index 8cdcf46..21c4d9b 100644 (file)
@@ -122,11 +122,7 @@ int target__strerror(struct target *target, int errnum,
        BUG_ON(buflen == 0);
 
        if (errnum >= 0) {
-               const char *err = str_error_r(errnum, buf, buflen);
-
-               if (err != buf)
-                       scnprintf(buf, buflen, "%s", err);
-
+               str_error_r(errnum, buf, buflen);
                return 0;
        }