linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Thomas Winischhofer <thomas@winischhofer.net>,
	Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>,
	Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] drivers/video/fbdev/sis/sis_main.c: avoid repeated strlen() calls
Date: Tue,  9 Jun 2015 15:04:26 +0200	[thread overview]
Message-ID: <1433855066-20260-1-git-send-email-linux@rasmusvillemoes.dk> (raw)

gcc is not smart enough to realize that strlen(strbuf1) cannot be
changed by the loop body, so it is forced to recompute it, at least in
the branch containing the assignment. Avoid this by using an
equivalent stopping condition.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 drivers/video/fbdev/sis/sis_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/sis/sis_main.c b/drivers/video/fbdev/sis/sis_main.c
index fcf610edf217..ea95f8bf3922 100644
--- a/drivers/video/fbdev/sis/sis_main.c
+++ b/drivers/video/fbdev/sis/sis_main.c
@@ -172,7 +172,7 @@ static void sisfb_search_mode(char *name, bool quiet)
 
 	if(strlen(name) <= 19) {
 		strcpy(strbuf1, name);
-		for(i = 0; i < strlen(strbuf1); i++) {
+		for(i = 0; strbuf1[i]; i++) {
 			if(strbuf1[i] < '0' || strbuf1[i] > '9') strbuf1[i] = ' ';
 		}
 
-- 
2.1.3


             reply	other threads:[~2015-06-09 13:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-09 13:04 Rasmus Villemoes [this message]
2015-06-12  9:36 ` [PATCH] drivers/video/fbdev/sis/sis_main.c: avoid repeated strlen() calls Tomi Valkeinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1433855066-20260-1-git-send-email-linux@rasmusvillemoes.dk \
    --to=linux@rasmusvillemoes.dk \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=plagnioj@jcrosoft.com \
    --cc=thomas@winischhofer.net \
    --cc=tomi.valkeinen@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).