Skip to content

Commit 3d251a5

Browse files
mitadedekind
authored andcommitted
UBIFS: rename random32() to prandom_u32()
Use more preferable function name which implies using a pseudo-random number generator. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
1 parent 9931fac commit 3d251a5

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

‎fs/ubifs/debug.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,7 +2459,7 @@ int dbg_check_nondata_nodes_order(struct ubifs_info *c, struct list_head *head)
24592459

24602460
static inline int chance(unsigned int n, unsigned int out_of)
24612461
{
2462-
return !!((random32() % out_of) + 1 <= n);
2462+
return !!((prandom_u32() % out_of) + 1 <= n);
24632463

24642464
}
24652465

@@ -2477,13 +2477,13 @@ static int power_cut_emulated(struct ubifs_info *c, int lnum, int write)
24772477
if (chance(1, 2)) {
24782478
d->pc_delay = 1;
24792479
/* Fail withing 1 minute */
2480-
delay = random32() % 60000;
2480+
delay = prandom_u32() % 60000;
24812481
d->pc_timeout = jiffies;
24822482
d->pc_timeout += msecs_to_jiffies(delay);
24832483
ubifs_warn("failing after %lums", delay);
24842484
} else {
24852485
d->pc_delay = 2;
2486-
delay = random32() % 10000;
2486+
delay = prandom_u32() % 10000;
24872487
/* Fail within 10000 operations */
24882488
d->pc_cnt_max = delay;
24892489
ubifs_warn("failing after %lu calls", delay);
@@ -2563,7 +2563,7 @@ static int corrupt_data(const struct ubifs_info *c, const void *buf,
25632563
unsigned int from, to, ffs = chance(1, 2);
25642564
unsigned char *p = (void *)buf;
25652565

2566-
from = random32() % (len + 1);
2566+
from = prandom_u32() % (len + 1);
25672567
/* Corruption may only span one max. write unit */
25682568
to = min(len, ALIGN(from, c->max_write_size));
25692569

‎fs/ubifs/lpt_commit.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,28 +2007,28 @@ static int dbg_populate_lsave(struct ubifs_info *c)
20072007

20082008
if (!dbg_is_chk_gen(c))
20092009
return 0;
2010-
if (random32() & 3)
2010+
if (prandom_u32() & 3)
20112011
return 0;
20122012

20132013
for (i = 0; i < c->lsave_cnt; i++)
20142014
c->lsave[i] = c->main_first;
20152015

20162016
list_for_each_entry(lprops, &c->empty_list, list)
2017-
c->lsave[random32() % c->lsave_cnt] = lprops->lnum;
2017+
c->lsave[prandom_u32() % c->lsave_cnt] = lprops->lnum;
20182018
list_for_each_entry(lprops, &c->freeable_list, list)
2019-
c->lsave[random32() % c->lsave_cnt] = lprops->lnum;
2019+
c->lsave[prandom_u32() % c->lsave_cnt] = lprops->lnum;
20202020
list_for_each_entry(lprops, &c->frdi_idx_list, list)
2021-
c->lsave[random32() % c->lsave_cnt] = lprops->lnum;
2021+
c->lsave[prandom_u32() % c->lsave_cnt] = lprops->lnum;
20222022

20232023
heap = &c->lpt_heap[LPROPS_DIRTY_IDX - 1];
20242024
for (i = 0; i < heap->cnt; i++)
2025-
c->lsave[random32() % c->lsave_cnt] = heap->arr[i]->lnum;
2025+
c->lsave[prandom_u32() % c->lsave_cnt] = heap->arr[i]->lnum;
20262026
heap = &c->lpt_heap[LPROPS_DIRTY - 1];
20272027
for (i = 0; i < heap->cnt; i++)
2028-
c->lsave[random32() % c->lsave_cnt] = heap->arr[i]->lnum;
2028+
c->lsave[prandom_u32() % c->lsave_cnt] = heap->arr[i]->lnum;
20292029
heap = &c->lpt_heap[LPROPS_FREE - 1];
20302030
for (i = 0; i < heap->cnt; i++)
2031-
c->lsave[random32() % c->lsave_cnt] = heap->arr[i]->lnum;
2031+
c->lsave[prandom_u32() % c->lsave_cnt] = heap->arr[i]->lnum;
20322032

20332033
return 1;
20342034
}

‎fs/ubifs/tnc_commit.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ static int alloc_idx_lebs(struct ubifs_info *c, int cnt)
683683
c->ilebs[c->ileb_cnt++] = lnum;
684684
dbg_cmt("LEB %d", lnum);
685685
}
686-
if (dbg_is_chk_index(c) && !(random32() & 7))
686+
if (dbg_is_chk_index(c) && !(prandom_u32() & 7))
687687
return -ENOSPC;
688688
return 0;
689689
}

0 commit comments

Comments
 (0)