2011-08-16 09:43:55

by Pavel Raiskup

[permalink] [raw]
Subject: [PATCH 1/8] Off-by-one(two) error in form factor detection

Indexing of chassis_map array has to be done like that:
chassis_map[chassis_type * 2 - 1]

because if not, everything is shifted by one. When (e.g.) chassis_type
is 0x04 result should be "Low Profile Desktop" => "desktop" (not a
"Pizza Box" => "server"). Lets see the 2.6.1 document on:

http://www.dmtf.org/standards/smbios
---
plugins/formfactor.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/plugins/formfactor.c b/plugins/formfactor.c
index 33a8b32..3b31927 100644
--- a/plugins/formfactor.c
+++ b/plugins/formfactor.c
@@ -104,7 +104,7 @@ static int formfactor_probe(struct btd_adapter
*adapter)
return 0;
}

- formfactor = chassis_map[chassis_type * 2 + 1];
+ formfactor = chassis_map[chassis_type * 2 - 1];
if (formfactor != NULL) {
if (g_str_equal(formfactor, "laptop") == TRUE)
minor |= (1 << 2) | (1 << 3);
--
1.7.4.4


2011-08-23 15:36:49

by Anderson Lizardo

[permalink] [raw]
Subject: Re: [PATCH 1/8] Off-by-one(two) error in form factor detection

Hi Pavel,

On Tue, Aug 23, 2011 at 1:07 AM, Pavel Raiskup <[email protected]> wrote:
>> The patch doesn't apply (probably due to your email client splitting
>> lines). You might want to consider using git send-email instead:
>
> sorry for that, I'll use send-email for the next time. For now I'm sending
> patches again as attachment because I don't want to break this thread.

Just a tip: you can use --in-reply-to=<message-id> to make sure your
patch's email will be attached to a given thread.

<message-id> is the Message ID for the message you want to "reply"
with the new patch (which you can get from the message headers, look
for "Message-ID: ...").

HTH,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil

2011-08-23 05:07:32

by Pavel Raiskup

[permalink] [raw]
Subject: Re: [PATCH 1/8] Off-by-one(two) error in form factor detection

Hi Johan,

> On Tue, Aug 16, 2011, Pavel Raiskup wrote:
>> Indexing of chassis_map array has to be done like that:
>> chassis_map[chassis_type * 2 - 1]
>>
>> because if not, everything is shifted by one. When (e.g.) chassis_type
>> is 0x04 result should be "Low Profile Desktop" => "desktop" (not a
>> "Pizza Box" => "server"). Lets see the 2.6.1 document on:
>>
>> http://www.dmtf.org/standards/smbios
>> ---
>> plugins/formfactor.c | 2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> The patch doesn't apply (probably due to your email client splitting
> lines). You might want to consider using git send-email instead:

sorry for that, I'll use send-email for the next time. For now I'm sending
patches again as attachment because I don't want to break this thread.


Attachments:
0001-Off-by-one-two-error-in-form-factor-detection.patch (1.07 kB)

2011-08-22 08:29:33

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH 1/8] Off-by-one(two) error in form factor detection

Hi Pavel,

On Tue, Aug 16, 2011, Pavel Raiskup wrote:
> Indexing of chassis_map array has to be done like that:
> chassis_map[chassis_type * 2 - 1]
>
> because if not, everything is shifted by one. When (e.g.) chassis_type
> is 0x04 result should be "Low Profile Desktop" => "desktop" (not a
> "Pizza Box" => "server"). Lets see the 2.6.1 document on:
>
> http://www.dmtf.org/standards/smbios
> ---
> plugins/formfactor.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)

The patch doesn't apply (probably due to your email client splitting
lines). You might want to consider using git send-email instead:

Applying: Off-by-one(two) error in form factor detection
fatal: corrupt patch at line 10
Patch failed at 0001 Off-by-one(two) error in form factor detection

I also added Łukasz to CC since he sent a patch to this very same line a
month ago or so (and introduced the "+ 1). Łukasz, did you really verify
the correctness of your patch? (it seems you didn't)

Johan