@@ -896,33 +896,10 @@ static __maybe_unused void annotated_source__delete(struct annotated_source *src
896
896
}
897
897
898
898
static int annotated_source__alloc_histograms (struct annotated_source * src ,
899
- size_t size , int nr_hists )
899
+ int nr_hists )
900
900
{
901
- size_t sizeof_sym_hist ;
902
-
903
- /*
904
- * Add buffer of one element for zero length symbol.
905
- * When sample is taken from first instruction of
906
- * zero length symbol, perf still resolves it and
907
- * shows symbol name in perf report and allows to
908
- * annotate it.
909
- */
910
- if (size == 0 )
911
- size = 1 ;
912
-
913
- /* Check for overflow when calculating sizeof_sym_hist */
914
- if (size > (SIZE_MAX - sizeof (struct sym_hist )) / sizeof (struct sym_hist_entry ))
915
- return -1 ;
916
-
917
- sizeof_sym_hist = (sizeof (struct sym_hist ) + size * sizeof (struct sym_hist_entry ));
918
-
919
- /* Check for overflow in zalloc argument */
920
- if (sizeof_sym_hist > SIZE_MAX / nr_hists )
921
- return -1 ;
922
-
923
- src -> sizeof_sym_hist = sizeof_sym_hist ;
924
901
src -> nr_histograms = nr_hists ;
925
- src -> histograms = calloc (nr_hists , sizeof_sym_hist ) ;
902
+ src -> histograms = calloc (nr_hists , sizeof ( * src -> histograms )) ;
926
903
927
904
if (src -> histograms == NULL )
928
905
return -1 ;
@@ -941,7 +918,7 @@ void symbol__annotate_zero_histograms(struct symbol *sym)
941
918
annotation__lock (notes );
942
919
if (notes -> src != NULL ) {
943
920
memset (notes -> src -> histograms , 0 ,
944
- notes -> src -> nr_histograms * notes -> src -> sizeof_sym_hist );
921
+ notes -> src -> nr_histograms * sizeof ( * notes -> src -> histograms ) );
945
922
hashmap__clear (notes -> src -> samples );
946
923
}
947
924
if (notes -> branch && notes -> branch -> cycles_hist ) {
@@ -1039,9 +1016,7 @@ static int __symbol__inc_addr_samples(struct map_symbol *ms,
1039
1016
}
1040
1017
1041
1018
h -> nr_samples ++ ;
1042
- h -> addr [offset ].nr_samples ++ ;
1043
1019
h -> period += sample -> period ;
1044
- h -> addr [offset ].period += sample -> period ;
1045
1020
entry -> nr_samples ++ ;
1046
1021
entry -> period += sample -> period ;
1047
1022
@@ -1094,8 +1069,7 @@ struct annotated_source *symbol__hists(struct symbol *sym, int nr_hists)
1094
1069
1095
1070
if (notes -> src -> histograms == NULL ) {
1096
1071
alloc_histograms :
1097
- annotated_source__alloc_histograms (notes -> src , symbol__size (sym ),
1098
- nr_hists );
1072
+ annotated_source__alloc_histograms (notes -> src , nr_hists );
1099
1073
}
1100
1074
1101
1075
return notes -> src ;
@@ -2854,7 +2828,7 @@ void symbol__annotate_zero_histogram(struct symbol *sym, int evidx)
2854
2828
struct annotation * notes = symbol__annotation (sym );
2855
2829
struct sym_hist * h = annotation__histogram (notes , evidx );
2856
2830
2857
- memset (h , 0 , notes -> src -> sizeof_sym_hist );
2831
+ memset (h , 0 , sizeof ( * notes -> src -> histograms ) * notes -> src -> nr_histograms );
2858
2832
}
2859
2833
2860
2834
void symbol__annotate_decay_histogram (struct symbol * sym , int evidx )
0 commit comments