]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
perf string: Simplify ltrim() implementation
authorArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 7 Apr 2017 15:19:38 +0000 (12:19 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 11 Apr 2017 18:23:39 +0000 (15:23 -0300)
commitecbe5e10d4ad12dd3da5d9fccd153c529c8c8ce1
treeb24dd13689e734daf441ea219efeb742bf8c73c4
parentbdd97ca63faa374c98314d53c0bcaedb473c5a33
perf string: Simplify ltrim() implementation

We don't need to use strlen(), a var, or check for the end explicitely,
isspace('\0') is false:

  [acme@jouet c]$ cat ltrim.c
  #include <ctype.h>
  #include <stdio.h>

  static char *ltrim(char *s)
  {
  while (isspace(*s))
  ++s;
  return s;
  }

  int main(void)
  {
  printf("ltrim(\"\")='%s'\n", ltrim(""));
  return 0;
  }
  [acme@jouet c]$ ./ltrim
  ltrim("")=''
  [acme@jouet c]$

Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Taeung Song <treeze.taeung@gmail.com>
Link: http://lkml.kernel.org/n/tip-w3nk0x3pai2vojk2ab6kdvaw@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/string.c