@@ -1175,6 +1175,8 @@ int cmd_report(int argc, const char **argv)
11751175 .annotation_opts = annotation__default_options ,
11761176 .skip_empty = true,
11771177 };
1178+ char * sort_order_help = sort_help ("sort by key(s):" );
1179+ char * field_order_help = sort_help ("output field(s): overhead period sample " );
11781180 const struct option options [] = {
11791181 OPT_STRING ('i' , "input" , & input_name , "file" ,
11801182 "input file name" ),
@@ -1209,9 +1211,9 @@ int cmd_report(int argc, const char **argv)
12091211 OPT_BOOLEAN (0 , "header-only" , & report .header_only ,
12101212 "Show only data header." ),
12111213 OPT_STRING ('s' , "sort" , & sort_order , "key[,key2...]" ,
1212- sort_help ( "sort by key(s):" ) ),
1214+ sort_order_help ),
12131215 OPT_STRING ('F' , "fields" , & field_order , "key[,keys...]" ,
1214- sort_help ( "output field(s): overhead period sample " ) ),
1216+ field_order_help ),
12151217 OPT_BOOLEAN (0 , "show-cpu-utilization" , & symbol_conf .show_cpu_utilization ,
12161218 "Show sample percentage for different cpu modes" ),
12171219 OPT_BOOLEAN_FLAG (0 , "showcpuutilization" , & symbol_conf .show_cpu_utilization ,
@@ -1344,11 +1346,11 @@ int cmd_report(int argc, const char **argv)
13441346 char sort_tmp [128 ];
13451347
13461348 if (ret < 0 )
1347- return ret ;
1349+ goto exit ;
13481350
13491351 ret = perf_config (report__config , & report );
13501352 if (ret )
1351- return ret ;
1353+ goto exit ;
13521354
13531355 argc = parse_options (argc , argv , options , report_usage , 0 );
13541356 if (argc ) {
@@ -1362,8 +1364,10 @@ int cmd_report(int argc, const char **argv)
13621364 report .symbol_filter_str = argv [0 ];
13631365 }
13641366
1365- if (annotate_check_args (& report .annotation_opts ) < 0 )
1366- return - EINVAL ;
1367+ if (annotate_check_args (& report .annotation_opts ) < 0 ) {
1368+ ret = - EINVAL ;
1369+ goto exit ;
1370+ }
13671371
13681372 if (report .mmaps_mode )
13691373 report .tasks_mode = true;
@@ -1377,12 +1381,14 @@ int cmd_report(int argc, const char **argv)
13771381 if (symbol_conf .vmlinux_name &&
13781382 access (symbol_conf .vmlinux_name , R_OK )) {
13791383 pr_err ("Invalid file: %s\n" , symbol_conf .vmlinux_name );
1380- return - EINVAL ;
1384+ ret = - EINVAL ;
1385+ goto exit ;
13811386 }
13821387 if (symbol_conf .kallsyms_name &&
13831388 access (symbol_conf .kallsyms_name , R_OK )) {
13841389 pr_err ("Invalid file: %s\n" , symbol_conf .kallsyms_name );
1385- return - EINVAL ;
1390+ ret = - EINVAL ;
1391+ goto exit ;
13861392 }
13871393
13881394 if (report .inverted_callchain )
@@ -1406,12 +1412,14 @@ int cmd_report(int argc, const char **argv)
14061412
14071413repeat :
14081414 session = perf_session__new (& data , false, & report .tool );
1409- if (IS_ERR (session ))
1410- return PTR_ERR (session );
1415+ if (IS_ERR (session )) {
1416+ ret = PTR_ERR (session );
1417+ goto exit ;
1418+ }
14111419
14121420 ret = evswitch__init (& report .evswitch , session -> evlist , stderr );
14131421 if (ret )
1414- return ret ;
1422+ goto exit ;
14151423
14161424 if (zstd_init (& (session -> zstd_data ), 0 ) < 0 )
14171425 pr_warning ("Decompression initialization failed. Reported data may be incomplete.\n" );
@@ -1646,5 +1654,8 @@ int cmd_report(int argc, const char **argv)
16461654
16471655 zstd_fini (& (session -> zstd_data ));
16481656 perf_session__delete (session );
1657+ exit :
1658+ free (sort_order_help );
1659+ free (field_order_help );
16491660 return ret ;
16501661}
0 commit comments