From: Khalid Aziz <khalid@gonehiking.org>
To: Frans Klaver <fransklaver@gmail.com>,
Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: JBottomley@odin.com, linux-scsi@vger.kernel.org,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] [SCSI] FlashPoint: optimize string comparison
Date: Wed, 08 Jul 2015 07:59:23 -0600 [thread overview]
Message-ID: <559D2CBB.8090502@gonehiking.org> (raw)
In-Reply-To: <CAH6sp9OmMje3EAVisaToorOQb+j3AWm_RE_UTpXN6eYjFny72w@mail.gmail.com>
On 07/08/2015 01:12 AM, Frans Klaver wrote:
> On Wed, Jul 8, 2015 at 7:45 AM, Christophe JAILLET
> <christophe.jaillet@wanadoo.fr> wrote:
>> Le 07/07/2015 19:04, Khalid Aziz a écrit :
>>>
>>> On 07/07/2015 02:45 AM, Frans Klaver wrote:
>>>>
>>>> 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
>>>>
>>>
>>> I suspect that is how this code came from Mylex many years ago. Using
>>> strncmp would indeed be a better way to clean this up. Also, further down in
>>> the same routine:
>>>
>>> if (FPT_scamInfo[match].state == ID_UNUSED) {
>>> for (k = 0; k < ID_STRING_LENGTH; k++) {
>>> FPT_scamInfo[match].id_string[k] =
>>> p_id_string[k];
>>> }
>>>
>>>
>>> This should use strncpy instead. There is another similar spot further
>>> down.
>>>
>>> Christophe, if you can send a new patch with these clean-ups, that would
>>> be great.
>>>
>>> Thanks,
>>> Khalid
>>
>>
>> Hi,
>>
>> I'm sorry but I won't propose a new patch for that.
>>
>> I had the same reaction at first (why not use strncmp?) but it seems to be
>> the way this driver is coded. Should we want to introduce strncmp here,
>> then, as you have noticed, strcpy should be used to. memset could be also
>> used in many places. Then looking elsewhere in the code, many things should,
>> IMHO, also be fixed. (use consistently empty lines before/after code ; use
>> consistently { }...)
>>
>> Another concern to me is "the use of carriage return". In the following
>> examples, things could be much more readable if not limited to 50 chars per
>> line, or so.
>
> 80. Parts of the code are indented way too much, resulting in these
> unreadable lines. I have to say that this entire driver looks like
> something that (sh|w)ould be in staging right now.
FlashPoint.c and BusLogic.c together make up the buslogic driver. I went
through a massive clean up of BusLogic.c (addressing issues like the
ones you guys are bringing up) when I took over maintenance of buslogic
driver and made it 64-bit clean. I am very much in agreement with
suggested clean ups, but this code has been in the kernel for a very
long time and cleaning it up at this point for the sake of clean up is
not a reason enough to destabilize a very stable driver. staging is for
drivers under development and in experimental state. buslogic driver is
most definitely not experimental. For now we either leave FlashPoint.c
as it is or clean it up as part of a bigger effort to add new
functionality or fix a major bug.
Christophe's original patch fixes an inefficiency in the code, so my
take on it is to either accept the very specific fix without modifying
rest of the code or combine this fix with clean up of at least the
entire FPT_scmachid() routine.
Thanks,
Khalid
prev parent reply other threads:[~2015-07-08 15:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-07 5:39 [PATCH] [SCSI] FlashPoint: optimize string comparison Christophe JAILLET
2015-07-07 8:45 ` Frans Klaver
2015-07-07 17:04 ` Khalid Aziz
2015-07-08 5:45 ` Christophe JAILLET
2015-07-08 7:12 ` Frans Klaver
2015-07-08 13:59 ` Khalid Aziz [this message]
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=559D2CBB.8090502@gonehiking.org \
--to=khalid@gonehiking.org \
--cc=JBottomley@odin.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=fransklaver@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
/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