Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756753AbbGGIpk (ORCPT ); Tue, 7 Jul 2015 04:45:40 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:33866 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755116AbbGGIpe (ORCPT ); Tue, 7 Jul 2015 04:45:34 -0400 MIME-Version: 1.0 In-Reply-To: <1436247543-7326-1-git-send-email-christophe.jaillet@wanadoo.fr> References: <1436247543-7326-1-git-send-email-christophe.jaillet@wanadoo.fr> Date: Tue, 7 Jul 2015 10:45:32 +0200 Message-ID: Subject: Re: [PATCH] [SCSI] FlashPoint: optimize string comparison From: Frans Klaver To: Christophe JAILLET Cc: khalid@gonehiking.org, JBottomley@odin.com, linux-scsi@vger.kernel.org, "linux-kernel@vger.kernel.org" , kernel-janitors@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1283 Lines: 35 On Tue, Jul 7, 2015 at 7:39 AM, Christophe JAILLET wrote: > Stop comparing the strings as soon as we know that they don't match. > > Signed-off-by: Christophe JAILLET > --- > drivers/scsi/FlashPoint.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/scsi/FlashPoint.c b/drivers/scsi/FlashPoint.c > index 5c74e4c..24a4d1a 100644 > --- a/drivers/scsi/FlashPoint.c > +++ b/drivers/scsi/FlashPoint.c > @@ -6280,8 +6280,10 @@ static unsigned char FPT_scmachid(unsigned char p_card, > match = 1; > > for (k = 0; k < ID_STRING_LENGTH; k++) { > - if (p_id_string[k] != FPT_scamInfo[i].id_string[k]) > + if (p_id_string[k] != FPT_scamInfo[i].id_string[k]) { > match = 0; > + break; > + } > } > > if (match) { Why doesn't this use strncmp? Thanks, Frans -- 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/