Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933102AbbFINFG (ORCPT ); Tue, 9 Jun 2015 09:05:06 -0400 Received: from mail-lb0-f180.google.com ([209.85.217.180]:35340 "EHLO mail-lb0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753809AbbFINE4 (ORCPT ); Tue, 9 Jun 2015 09:04:56 -0400 From: Rasmus Villemoes To: Thomas Winischhofer , Jean-Christophe Plagniol-Villard , Tomi Valkeinen Cc: Rasmus Villemoes , 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 Message-Id: <1433855066-20260-1-git-send-email-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.1.3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1121 Lines: 31 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 --- 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 -- 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/