# Possible bug in keep\_m\_in\_n and patch

**URL:** <https://www.ruby-forum.com/t/possible-bug-in-keep-m-in-n-and-patch/232203>\
**Category:** GNU Radio\
**Created:** [September 24, 2014, 9:23pm UTC](https://www.ruby-forum.com/t/possible-bug-in-keep-m-in-n-and-patch/232203 "2014-09-24T21:23:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [September 24, 2014, 9:23pm UTC](https://www.ruby-forum.com/t/possible-bug-in-keep-m-in-n-and-patch/232203/1 "2014-09-24T21:23:00Z")

</div>

Dear all,

I checked the keep\_m\_in\_n block and found a possible bug in it. In the  
work  
function, the code wrote:

consume\_each(d\_n);  
return d\_m;

which I think it should be

consume\_each(blks_d\_n);  
return blks_d\_m.

while blks=std::min(noutput\_items/d\_m, ninput\_items[0]/d\_n).

Since both m and n of the block might change, which means the output to  
input rate might change. I changed the set\_output\_multiple(m) to  
set\_relative\_rate(d\_n/d\_m). And we made the set\_relative\_rate(d\_n/d\_m)  
be  
called in the set\_m and set\_n function to make sure the rate is updated  
on  
time.

The patch is attached. Could you check it?

Thanks!  
Best,  
Zhe

---

<div class="post-metadata">

**Author:** ![Zhe\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/d07c76/32.png) [@Zhe\_F](https://www.ruby-forum.com/u/Zhe_F)\
**Post date:** [September 24, 2014, 9:52pm UTC](https://www.ruby-forum.com/t/possible-bug-in-keep-m-in-n-and-patch/232203/2 "2014-09-24T21:52:10Z")

</div>

No comment on the patch, but in general, it helps us a lot if you do  
this via github & pull request.

M

---

<div class="post-metadata">

**Author:** ![Zhe\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/d07c76/32.png) [@Zhe\_F](https://www.ruby-forum.com/u/Zhe_F)\
**Post date:** [September 25, 2014, 4:37pm UTC](https://www.ruby-forum.com/t/possible-bug-in-keep-m-in-n-and-patch/232203/3 "2014-09-25T16:37:43Z")

</div>

Zhe,

To follow up on Martin’s point. First, yes, please either use the Issue  
tracker or submit a patch/pull request via git and github.

Also, just pointing out a bug is one thing, but it’s also much easier  
for  
us to test and verify if you provide us with an example file.

That having been said, yes, I think your patch is correct. The current  
behavior does not produce the wrong answer, but it’s wasting a ton of  
computation time.

Please send a patch.

Tom

On Wed, Sep 24, 2014 at 3:49 PM, Martin B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Zhe\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/d07c76/32.png) [@Zhe\_F](https://www.ruby-forum.com/u/Zhe_F)\
**Post date:** [September 25, 2014, 4:59pm UTC](https://www.ruby-forum.com/t/possible-bug-in-keep-m-in-n-and-patch/232203/4 "2014-09-25T16:59:56Z")

</div>

As was pointed out to me in IRC, we have a webpage describing how to  
submit  
patches. See this page:

[http://gnuradio.org/redmine/projects/gnuradio/wiki/Development#How-do-I-submit-patches](http://gnuradio.org/redmine/projects/gnuradio/wiki/Development#How-do-I-submit-patches)

But I forgot that you actually submitted a patch in the email, so don’t  
worry about opening an issue on this right now. I’ll take the patch and  
check it in.

(btw, in a simple test I ran, this gave a 10x speedup on that block.)

Thanks!  
Tom
