From patchwork Thu Jan 3 12:19:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 209230 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7FF462C007D for ; Thu, 3 Jan 2013 23:21:17 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TqjmM-0003hZ-GN; Thu, 03 Jan 2013 12:20:10 +0000 Received: from mail-pa0-f48.google.com ([209.85.220.48]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TqjmJ-0003hH-8n for linux-mtd@lists.infradead.org; Thu, 03 Jan 2013 12:20:08 +0000 Received: by mail-pa0-f48.google.com with SMTP id fa1so8686247pad.7 for ; Thu, 03 Jan 2013 04:20:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=XZT0nLyqdixaQlaSoqqsRC6ym0vpF/gVnpjSk+c0aHo=; b=VIBH4Gr+ZNK93cHZ055u0Hze2mH6Rw1OGPT+o/N8X+aSea9o85H+Gs0iUuvDbEwgZG CXf4rKRmstTKYH/iJVhvpCOieWNpKc/wmurRCDGMY3p9zenHzhWSM5S1Mdr3JZ4xC8qK C5oE/CPLXdAttrKZuHq0V2hRQquVP1x8ge+EKdqUNvIzYTz5sNVsIBMwHVbd06jVx3nm XIitlb+GWAIUyCwR6wg5rOJsMTjk3Vq7VHsUVpR4Hoa5UlYszKe+Up/nehbCYXFMFY+N o044A9+1yegNEkgGIsYIJv32L3OyYRZcebLjoc0gq7XgfXZwfr7SRtBVNHCvVoQZWfFd u6fQ== X-Received: by 10.68.232.71 with SMTP id tm7mr153516622pbc.118.1357215604120; Thu, 03 Jan 2013 04:20:04 -0800 (PST) Received: from localhost.localdomain (p2126-ipbf3106hodogaya.kanagawa.ocn.ne.jp. [114.149.157.126]) by mx.google.com with ESMTPS id qn3sm28095334pbb.56.2013.01.03.04.20.02 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 03 Jan 2013 04:20:03 -0800 (PST) From: Akinobu Mita To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org Subject: [PATCH -v2 13/26] ubifs: rename random32() to prandom_u32() Date: Thu, 3 Jan 2013 21:19:09 +0900 Message-Id: <1357215562-6288-14-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1357215562-6288-1-git-send-email-akinobu.mita@gmail.com> References: <1357215562-6288-1-git-send-email-akinobu.mita@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130103_072007_459870_42E77EE5 X-CRM114-Status: GOOD ( 12.68 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (akinobu.mita[at]gmail.com) -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.48 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Adrian Hunter , linux-mtd@lists.infradead.org, Akinobu Mita , Artem Bityutskiy X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Use more preferable function name which implies using a pseudo-random number generator. Signed-off-by: Akinobu Mita Cc: Artem Bityutskiy Cc: Adrian Hunter Cc: linux-mtd@lists.infradead.org --- No change from v1 fs/ubifs/debug.c | 8 ++++---- fs/ubifs/lpt_commit.c | 14 +++++++------- fs/ubifs/tnc_commit.c | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index 12817ff..7f60e90 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c @@ -2459,7 +2459,7 @@ error_dump: static inline int chance(unsigned int n, unsigned int out_of) { - return !!((random32() % out_of) + 1 <= n); + return !!((prandom_u32() % out_of) + 1 <= n); } @@ -2477,13 +2477,13 @@ static int power_cut_emulated(struct ubifs_info *c, int lnum, int write) if (chance(1, 2)) { d->pc_delay = 1; /* Fail withing 1 minute */ - delay = random32() % 60000; + delay = prandom_u32() % 60000; d->pc_timeout = jiffies; d->pc_timeout += msecs_to_jiffies(delay); ubifs_warn("failing after %lums", delay); } else { d->pc_delay = 2; - delay = random32() % 10000; + delay = prandom_u32() % 10000; /* Fail within 10000 operations */ d->pc_cnt_max = delay; ubifs_warn("failing after %lu calls", delay); @@ -2563,7 +2563,7 @@ static int corrupt_data(const struct ubifs_info *c, const void *buf, unsigned int from, to, ffs = chance(1, 2); unsigned char *p = (void *)buf; - from = random32() % (len + 1); + from = prandom_u32() % (len + 1); /* Corruption may only span one max. write unit */ to = min(len, ALIGN(from, c->max_write_size)); diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c index 9daaeef..4b826ab 100644 --- a/fs/ubifs/lpt_commit.c +++ b/fs/ubifs/lpt_commit.c @@ -2007,28 +2007,28 @@ static int dbg_populate_lsave(struct ubifs_info *c) if (!dbg_is_chk_gen(c)) return 0; - if (random32() & 3) + if (prandom_u32() & 3) return 0; for (i = 0; i < c->lsave_cnt; i++) c->lsave[i] = c->main_first; list_for_each_entry(lprops, &c->empty_list, list) - c->lsave[random32() % c->lsave_cnt] = lprops->lnum; + c->lsave[prandom_u32() % c->lsave_cnt] = lprops->lnum; list_for_each_entry(lprops, &c->freeable_list, list) - c->lsave[random32() % c->lsave_cnt] = lprops->lnum; + c->lsave[prandom_u32() % c->lsave_cnt] = lprops->lnum; list_for_each_entry(lprops, &c->frdi_idx_list, list) - c->lsave[random32() % c->lsave_cnt] = lprops->lnum; + c->lsave[prandom_u32() % c->lsave_cnt] = lprops->lnum; heap = &c->lpt_heap[LPROPS_DIRTY_IDX - 1]; for (i = 0; i < heap->cnt; i++) - c->lsave[random32() % c->lsave_cnt] = heap->arr[i]->lnum; + c->lsave[prandom_u32() % c->lsave_cnt] = heap->arr[i]->lnum; heap = &c->lpt_heap[LPROPS_DIRTY - 1]; for (i = 0; i < heap->cnt; i++) - c->lsave[random32() % c->lsave_cnt] = heap->arr[i]->lnum; + c->lsave[prandom_u32() % c->lsave_cnt] = heap->arr[i]->lnum; heap = &c->lpt_heap[LPROPS_FREE - 1]; for (i = 0; i < heap->cnt; i++) - c->lsave[random32() % c->lsave_cnt] = heap->arr[i]->lnum; + c->lsave[prandom_u32() % c->lsave_cnt] = heap->arr[i]->lnum; return 1; } diff --git a/fs/ubifs/tnc_commit.c b/fs/ubifs/tnc_commit.c index 523bbad..52a6559 100644 --- a/fs/ubifs/tnc_commit.c +++ b/fs/ubifs/tnc_commit.c @@ -683,7 +683,7 @@ static int alloc_idx_lebs(struct ubifs_info *c, int cnt) c->ilebs[c->ileb_cnt++] = lnum; dbg_cmt("LEB %d", lnum); } - if (dbg_is_chk_index(c) && !(random32() & 7)) + if (dbg_is_chk_index(c) && !(prandom_u32() & 7)) return -ENOSPC; return 0; }