All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Tokarev <mjt@tls.msk.ru>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-trivial@nongnu.org, alevy@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] libcacard: fix wrong array expansion logic
Date: Mon, 26 May 2014 10:29:44 +0400	[thread overview]
Message-ID: <5382DF58.2030107@msgid.tls.msk.ru> (raw)
In-Reply-To: <87vbstawff.fsf@blackfin.pond.sub.org>

26.05.2014 10:25, Markus Armbruster wrote:
> Michael Tokarev <mjt@tls.msk.ru> writes:
> 
>> The currrent code in libcacard/vcard_emul_nss.c:vcard_emul_options()
>> has a weird bug in variable usage around expanding opts->vreader
>> array.
>>
>> There's a helper variable, vreaderOpt, which is first needlessly
>> initialized to NULL, next, conditionally, only we have to expand
>> opts->vreader, receives array expansion from g_renew() (initially
>> realloc), and next, even if we don't actually perform expansion,
> 
> I don't get the "(initially realloc)" part.  The sentence makes sense to
> me just fine without it, though.

I was in context of your patch which changes realloc() to g_renew().
And I failed to mention that this my patch is on top of yuors,
too - think of this comment as such a mention ;)

>> the value of this variable is assigned to the actual array,
>> opts->vreader, which was supposed to be expanded.
>>
>> So, since we expand the array by READER_STEP increments, only
>> once in READER_STEP (=4) the code will work, in other 3/4 times
>> it will fail badly.
>>
>> Fix this by not using this temp variable when expanding the
>> array, and by dropping the useless =NULL initializer too -
>> if it wasn't in place initially, compiler warned us about
> 
> "would have warned us"?

Oh yeah.  I tried to remember the right English construct, but
failed.  This tense always escpapes my mind for some reason :)


> Much more straightforward now.  Thanks!
> 
> Reviewed-by: Markus Armbruster <armbru@redhat.com>

Thank you.  I'll fix the comment.  And I'm now ready to push
whole -trivial.

/mjt



WARNING: multiple messages have this Message-ID (diff)
From: Michael Tokarev <mjt@tls.msk.ru>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-trivial@nongnu.org, alevy@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] libcacard: fix wrong array expansion logic
Date: Mon, 26 May 2014 10:29:44 +0400	[thread overview]
Message-ID: <5382DF58.2030107@msgid.tls.msk.ru> (raw)
In-Reply-To: <87vbstawff.fsf@blackfin.pond.sub.org>

26.05.2014 10:25, Markus Armbruster wrote:
> Michael Tokarev <mjt@tls.msk.ru> writes:
> 
>> The currrent code in libcacard/vcard_emul_nss.c:vcard_emul_options()
>> has a weird bug in variable usage around expanding opts->vreader
>> array.
>>
>> There's a helper variable, vreaderOpt, which is first needlessly
>> initialized to NULL, next, conditionally, only we have to expand
>> opts->vreader, receives array expansion from g_renew() (initially
>> realloc), and next, even if we don't actually perform expansion,
> 
> I don't get the "(initially realloc)" part.  The sentence makes sense to
> me just fine without it, though.

I was in context of your patch which changes realloc() to g_renew().
And I failed to mention that this my patch is on top of yuors,
too - think of this comment as such a mention ;)

>> the value of this variable is assigned to the actual array,
>> opts->vreader, which was supposed to be expanded.
>>
>> So, since we expand the array by READER_STEP increments, only
>> once in READER_STEP (=4) the code will work, in other 3/4 times
>> it will fail badly.
>>
>> Fix this by not using this temp variable when expanding the
>> array, and by dropping the useless =NULL initializer too -
>> if it wasn't in place initially, compiler warned us about
> 
> "would have warned us"?

Oh yeah.  I tried to remember the right English construct, but
failed.  This tense always escpapes my mind for some reason :)


> Much more straightforward now.  Thanks!
> 
> Reviewed-by: Markus Armbruster <armbru@redhat.com>

Thank you.  I'll fix the comment.  And I'm now ready to push
whole -trivial.

/mjt

  reply	other threads:[~2014-05-26  6:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-23 20:57 [Qemu-trivial] [PATCH] libcacard: fix wrong array expansion logic Michael Tokarev
2014-05-23 20:57 ` [Qemu-devel] " Michael Tokarev
2014-05-26  6:25 ` [Qemu-trivial] " Markus Armbruster
2014-05-26  6:25   ` Markus Armbruster
2014-05-26  6:29   ` Michael Tokarev [this message]
2014-05-26  6:29     ` Michael Tokarev

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=5382DF58.2030107@msgid.tls.msk.ru \
    --to=mjt@tls.msk.ru \
    --cc=alevy@redhat.com \
    --cc=armbru@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.