mirror of
https://github.com/schoebel/mars
synced 2025-01-11 08:49:28 +00:00
lib_rank: fix potential integer overflow
This commit is contained in:
parent
9126a3819e
commit
8ef65996cf
@ -48,14 +48,14 @@ EXPORT_SYMBOL_GPL(ranking_compute);
|
||||
int ranking_select(struct rank_data rkd[], int rkd_count)
|
||||
{
|
||||
int res = -1;
|
||||
int max = INT_MIN / 2;
|
||||
long long max = LLONG_MIN / 2;
|
||||
int i;
|
||||
|
||||
MARS_IO("rkd_count = %d\n", rkd_count);
|
||||
|
||||
for (i = 0; i < rkd_count; i++) {
|
||||
struct rank_data *tmp = &rkd[i];
|
||||
int rest = tmp->rkd_current_points;
|
||||
long long rest = tmp->rkd_current_points;
|
||||
if (rest <= 0)
|
||||
continue;
|
||||
//rest -= tmp->rkd_got;
|
||||
|
@ -16,10 +16,10 @@ struct rank_info {
|
||||
|
||||
struct rank_data {
|
||||
// public readonly
|
||||
int rkd_current_points;
|
||||
long long rkd_current_points;
|
||||
// private
|
||||
int rkd_tmp;
|
||||
int rkd_got;
|
||||
long long rkd_tmp;
|
||||
long long rkd_got;
|
||||
};
|
||||
|
||||
/* Ranking phase.
|
||||
|
@ -2169,7 +2169,7 @@ int _do_ranking(struct trans_logger_brick *brick, struct rank_data rkd[])
|
||||
|
||||
#ifdef IO_DEBUGGING
|
||||
for (i = 0; i < LOGGER_QUEUES; i++) {
|
||||
MARS_IO("rkd[%d]: points = %d tmp = %d got = %d\n", i, rkd[i].rkd_current_points, rkd[i].rkd_tmp, rkd[i].rkd_got);
|
||||
MARS_IO("rkd[%d]: points = %lld tmp = %lld got = %lld\n", i, rkd[i].rkd_current_points, rkd[i].rkd_tmp, rkd[i].rkd_got);
|
||||
}
|
||||
MARS_IO("res = %d\n", res);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user