Bug 1132

Summary: useless for loops in block-ack-test-suite.cc
Product: ns-3 Reporter: Nicola Baldo <nicola>
Component: wifiAssignee: sebastien.deronne
Status: RESOLVED FIXED    
Severity: minor CC: mk.banchi, ns-bugs, ruben
Priority: P5    
Version: ns-3-dev   
Hardware: All   
OS: All   
Attachments: naive tentative patch that makes the test fail

Description Nicola Baldo 2011-05-07 11:59:54 UTC
this is a (probable) error spotted when running check-style.py

-  for (i = m_buffer.begin (); i != m_buffer.end () && QosUtilsMapSeqControlToUniqueInteger ((*i), endSeq) < mappedSeq; i++);
-    {
-      m_buffer.insert (i, receivedSeq);
-    }
+  for (i = m_buffer.begin (); i != m_buffer.end () && QosUtilsMapSeqControlToUniqueInteger ((*i), endSeq) < mappedSeq; i++)
+    {
+      ;
+    }
+  {
+    m_buffer.insert (i, receivedSeq);
+  }
Comment 1 Nicola Baldo 2011-05-08 07:40:40 UTC
Created attachment 1106 [details]
naive tentative patch that makes the test fail

(note: as of 7142:89a701fec3a1, check-style.py has been run on wifi, so in the previously cited code from src/wifi/test/block-ack-test-suite.cc the useless "for" loops are now more evident)

the attached patch is based on the assumption that the original error was just a typo, i.e., the "for" loops were useless just because of an additional semi-colon added by mistake. So this patch does the equivalent of eliminating the original semi-colon and making the "for" look iterate over the subsequent code between braces "{}". Unfortunately, the resulting test program fails. More investigation is needed.
Comment 2 Nicola Baldo 2011-05-08 07:41:47 UTC
Mirko, you are the original author of this code, could you please take a look?
Comment 3 Mirko Banchi 2011-05-11 07:59:49 UTC
Hi Nicola...Yes,of course those semi-colons are errors...however now i note in ns-3-dev your changes:

for (i = m_buffer.begin (); i != m_buffer.end () && QosUtilsMapSeqControlToUniqueInteger ((*i), endSeq) < mappedSeq; i++)
  {
    ;
  }

{
  m_buffer.insert (i, receivedSeq);
}

an the same for the other loop...this is obviously wrong...Is this only a way to pass tests? However i'll investigate ASAP.
Comment 4 Nicola Baldo 2011-05-11 09:22:35 UTC
(In reply to comment #3)
> Hi Nicola...Yes,of course those semi-colons are errors...however now i note in
> ns-3-dev your changes:
> 
> for (i = m_buffer.begin (); i != m_buffer.end () &&
> QosUtilsMapSeqControlToUniqueInteger ((*i), endSeq) < mappedSeq; i++)
>   {
>     ;
>   }
> 
> {
>   m_buffer.insert (i, receivedSeq);
> }
> 
> an the same for the other loop...this is obviously wrong...Is this only a way
> to pass tests? However i'll investigate ASAP.

The no-op block
{
  ;
}
was added automatically by check-style.py to replace the single ";" at the end of the "for" line. I didn't do any manual change. Functionally, they are equivalent. 

The patch that I attached above aims at removing the no-op block (which is equivalent to removing the ";" on the "for" line in the original code). But with this patch, the test doesn't pass. Hence I think there is an error in the test.
Comment 5 Mirko Banchi 2011-05-11 10:20:39 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > Hi Nicola...Yes,of course those semi-colons are errors...however now i note in
> > ns-3-dev your changes:
> > 
> > for (i = m_buffer.begin (); i != m_buffer.end () &&
> > QosUtilsMapSeqControlToUniqueInteger ((*i), endSeq) < mappedSeq; i++)
> >   {
> >     ;
> >   }
> > 
> > {
> >   m_buffer.insert (i, receivedSeq);
> > }
> > 
> > an the same for the other loop...this is obviously wrong...Is this only a way
> > to pass tests? However i'll investigate ASAP.
> 
> The no-op block
> {
>   ;
> }
> was added automatically by check-style.py to replace the single ";" at the end
> of the "for" line. I didn't do any manual change. Functionally, they are
> equivalent. 
> 
> The patch that I attached above aims at removing the no-op block (which is
> equivalent to removing the ";" on the "for" line in the original code). But
> with this patch, the test doesn't pass. Hence I think there is an error in the
> test.

Of course...you are right! I observed it very quickly...sorry. However, again, i'll investigate asap. Thank you Nicola!
Comment 6 sebastien.deronne 2015-05-27 08:55:17 UTC
Mirko, what are the updates on this bug?
Comment 7 sebastien.deronne 2015-07-22 16:08:38 UTC
Mirko is having a look
Comment 8 sebastien.deronne 2015-09-18 05:22:04 UTC
fixed in changeset 11671:4ef2a0434d99