Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932794AbbFHX1q (ORCPT ); Mon, 8 Jun 2015 19:27:46 -0400 Received: from mail-lb0-f182.google.com ([209.85.217.182]:33380 "EHLO mail-lb0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932651AbbFHX1X (ORCPT ); Mon, 8 Jun 2015 19:27:23 -0400 From: Rasmus Villemoes To: Andrew Morton , "Theodore Ts'o" Cc: Joe Perches , Al Viro , Rasmus Villemoes , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 7/8] fs/jbd2/journal.c: Use strreplace Date: Tue, 9 Jun 2015 01:26:55 +0200 Message-Id: <1433806017-10823-8-git-send-email-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1433806017-10823-1-git-send-email-linux@rasmusvillemoes.dk> References: <1433806017-10823-1-git-send-email-linux@rasmusvillemoes.dk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1788 Lines: 53 In one case, we eliminate a local variable; in the other a strlen() call and some .text. Signed-off-by: Rasmus Villemoes --- v2: no changes. fs/jbd2/journal.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index b96bd8076b70..5c187ded12d6 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -1137,7 +1137,6 @@ journal_t * jbd2_journal_init_dev(struct block_device *bdev, { journal_t *journal = journal_init_common(); struct buffer_head *bh; - char *p; int n; if (!journal) @@ -1150,9 +1149,7 @@ journal_t * jbd2_journal_init_dev(struct block_device *bdev, journal->j_blk_offset = start; journal->j_maxlen = len; bdevname(journal->j_dev, journal->j_devname); - p = journal->j_devname; - while ((p = strchr(p, '/'))) - *p = '!'; + strreplace(journal->j_devname, '/', '!'); jbd2_stats_proc_init(journal); n = journal->j_blocksize / sizeof(journal_block_tag_t); journal->j_wbufsize = n; @@ -1204,10 +1201,7 @@ journal_t * jbd2_journal_init_inode (struct inode *inode) journal->j_dev = journal->j_fs_dev = inode->i_sb->s_bdev; journal->j_inode = inode; bdevname(journal->j_dev, journal->j_devname); - p = journal->j_devname; - while ((p = strchr(p, '/'))) - *p = '!'; - p = journal->j_devname + strlen(journal->j_devname); + p = strreplace(journal->j_devname, '/', '!'); sprintf(p, "-%lu", journal->j_inode->i_ino); jbd_debug(1, "journal %p: inode %s/%ld, size %Ld, bits %d, blksize %ld\n", -- 2.1.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/