lkml.org 
[lkml]   [2015]   [Jul]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] [SCSI] FlashPoint: optimize string comparison
From
On Tue, Jul 7, 2015 at 7:39 AM, Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
> Stop comparing the strings as soon as we know that they don't match.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> 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


\
 
 \ /
  Last update: 2015-07-07 11:01    [W:0.052 / U:0.736 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site