On Wed, Dec 03, 2014 at 10:22:30AM +0530, Viresh Kumar wrote: > On 3 December 2014 at 04:51, Eduardo Valentin wrote: > > >> +static unsigned int find_next_max(struct cpufreq_frequency_table *table, > >> + unsigned int prev_max) > >> +{ > >> + struct cpufreq_frequency_table *pos; > >> + unsigned int max = 0; > >> + > >> + cpufreq_for_each_valid_entry(pos, table) { > >> + if (pos->frequency > max && pos->frequency < prev_max) > > > > What happens if, for some random reason, the cpufreq table is in > > ascending order and this function is called with prev_max == (unsigned > > int) -1 ? What would be the returned max? > > The last frequency of the table, i.e. the max value. What bug did you catch, > that I am not able to see.. Well, passing -1 to unsigned int will make it max unsigned int, your function will return the first freq, which in the scenario I gave, it would be the min freq, not the first max, right?