[Libosinfo] [PATCH] media: Fix misplaced parenthesis in strncmp use

Fabiano Fidêncio fabiano at fidencio.org
Wed May 11 12:52:24 UTC 2016


On Wed, May 11, 2016 at 2:44 PM, Christophe Fergeau <cfergeau at redhat.com> wrote:
> On Wed, May 11, 2016 at 02:36:17PM +0200, Fabiano Fidêncio wrote:
>> On Wed, May 11, 2016 at 2:26 PM, Christophe Fergeau <cfergeau at redhat.com> wrote:
>> > Due to a misplaced parenthesis, bootable media detection was doing
>> > strncmp(.., .., sizeof(..) != 0)
>> > instead of
>> > strncmp(.., .., sizeof(..)) != 0
>> >
>> > This means we were comparing 1 character from BOOTABLE_TAG rather than
>> > the full string.
>> > ---
>> >  osinfo/osinfo_media.c | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/osinfo/osinfo_media.c b/osinfo/osinfo_media.c
>> > index d9fcba6..f7bf120 100644
>> > --- a/osinfo/osinfo_media.c
>> > +++ b/osinfo/osinfo_media.c
>> > @@ -713,7 +713,7 @@ static void on_svd_read(GObject *source,
>> >
>> >      data->svd.system[MAX_SYSTEM - 1] = 0;
>> >
>> > -    if (strncmp(BOOTABLE_TAG, data->svd.system, sizeof(BOOTABLE_TAG) != 0)) {
>> > +    if (strncmp(BOOTABLE_TAG, data->svd.system, sizeof(BOOTABLE_TAG)) != 0) {
>> >          g_set_error(&error,
>> >                      OSINFO_MEDIA_ERROR,
>> >                      OSINFO_MEDIA_ERROR_NOT_BOOTABLE,
>> > --
>> > 2.7.4
>> >
>> > _______________________________________________
>> > Libosinfo mailing list
>> > Libosinfo at redhat.com
>> > https://www.redhat.com/mailman/listinfo/libosinfo
>>
>> ACK.
>>
>> How did you find it out? Were you looking for some specific issue or what?
>
> Ah, I nearly mentioned this in the commit log, I can add it if you want.
> I found this while trying to reproduce the -no-undefined build failure
> on linux, clang warned about that.

Aha. Good to know that clang is able to warn about this case.
Please, feel free to add it before pushing. No need to resend a v2.

>
> Christophe
>
> _______________________________________________
> Libosinfo mailing list
> Libosinfo at redhat.com
> https://www.redhat.com/mailman/listinfo/libosinfo
>


Best Regards,
-- 
Fabiano Fidêncio




More information about the Libosinfo mailing list