perf tools: Enhance the matching of sub-commands abbreviations
[linux-2.6-microblaze.git] / tools / perf / builtin-kvm.c
index b23a1f3..2fa687f 100644 (file)
@@ -24,6 +24,7 @@
 #include "util/ordered-events.h"
 #include "util/kvm-stat.h"
 #include "ui/ui.h"
+#include "util/string2.h"
 
 #include <sys/prctl.h>
 #ifdef HAVE_TIMERFD_SUPPORT
@@ -1500,10 +1501,10 @@ static int kvm_cmd_stat(const char *file_name, int argc, const char **argv)
                goto perf_stat;
        }
 
-       if (!strncmp(argv[1], "rec", 3))
+       if (strlen(argv[1]) > 2 && strstarts("record", argv[1]))
                return kvm_events_record(&kvm, argc - 1, argv + 1);
 
-       if (!strncmp(argv[1], "rep", 3))
+       if (strlen(argv[1]) > 2 && strstarts("report", argv[1]))
                return kvm_events_report(&kvm, argc - 1 , argv + 1);
 
 #ifdef HAVE_TIMERFD_SUPPORT
@@ -1631,9 +1632,9 @@ int cmd_kvm(int argc, const char **argv)
                }
        }
 
-       if (!strncmp(argv[0], "rec", 3))
+       if (strlen(argv[0]) > 2 && strstarts("record", argv[0]))
                return __cmd_record(file_name, argc, argv);
-       else if (!strncmp(argv[0], "rep", 3))
+       else if (strlen(argv[0]) > 2 && strstarts("report", argv[0]))
                return __cmd_report(file_name, argc, argv);
        else if (!strncmp(argv[0], "diff", 4))
                return cmd_diff(argc, argv);