Re: [Libreoffice] Warning in basic/source/runtime/runtime.cxx

2011-05-31 Thread Michael Meeks
Hi Julien,

Great to have you chasing this joke code:

-(pCollection = PTR_CAST(BasicCollection,pVar)) == pCollection )

Digging at what the code is used for it -seems- - that we want to find
this collection on the stack (if it is there), to alter the index a
'foreach' is using into it, so that it doesn't have an invalid index
next time around the loop, as/when we remove an item from the
collection. So something like [ I don't write basic ]:

foreach a in collection do
collection.remove (0)

doesn't cause grief, so I don't think:

+(pCollection = PTR_CAST(BasicCollection,pVar)) != NULL)

that works. I believe this is just a cut/paste error from dr, and we
want this instead:

+PTR_CAST(BasicCollection,pVar) == pCollection )

I'll commit that, and wait for screams.

Thanks for chasing it ! :-)

ATB,

Michael.

-- 
 michael.me...@novell.com  , Pseudo Engineer, itinerant idiot


___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] Warning in basic/source/runtime/runtime.cxx

2011-05-31 Thread David Tardon
On Tue, May 31, 2011 at 10:27:19AM +0100, Michael Meeks wrote:
   that works. I believe this is just a cut/paste error from dr, and we
 want this instead:
 
 +PTR_CAST(BasicCollection,pVar) == pCollection )
 
   I'll commit that, and wait for screams.

Moreover, I think there should be p = p-pNext at the end of the loop.
Otherwise we either hit the right collection at first try or we are
cycling until the heat death of the Universe .-)

D.
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] Warning in basic/source/runtime/runtime.cxx

2011-05-31 Thread Michael Meeks

On Tue, 2011-05-31 at 11:58 +0200, David Tardon wrote:
 On Tue, May 31, 2011 at 10:27:19AM +0100, Michael Meeks wrote:
  +PTR_CAST(BasicCollection,pVar) == pCollection )
  
  I'll commit that, and wait for screams.
 
 Moreover, I think there should be p = p-pNext at the end of the loop.
 Otherwise we either hit the right collection at first try or we are
 cycling until the heat death of the Universe .-)

Lol. And of course, it looks like nested foreaches on the same
collection would also break [ though it's not that likely to be
sure ;-]. I added to your clean by using a for(;;) loop to make it
clearer.

Thanks,

Michael.

-- 
 michael.me...@novell.com  , Pseudo Engineer, itinerant idiot


___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice] Warning in basic/source/runtime/runtime.cxx

2011-05-29 Thread Julien Nabet

Hello,

Since the last merging, I've got this :
Compiling: basic/source/runtime/runtime.cxx
cc1plus: warnings being treated as errors
/home/maryline/compile-libreoffice/libo/clone/libs-core/basic/source/runtime/runtime.cxx: 
In member function 'SbiForStack* 
SbiRuntime::FindForStackItemForCollection(BasicCollection*)':
/home/maryline/compile-libreoffice/libo/clone/libs-core/basic/source/runtime/runtime.cxx:1247:75: 
error: operation on 'pCollection' may be undefined

dmake:  Error code 1, while making '../../unxlngi6/slo/runtime

Is this diff patch would be ok ?

diff --git a/basic/source/runtime/runtime.cxx 
b/basic/source/runtime/runtime.cxx

index 308550a..76b7daf 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -1244,7 +1244,7 @@ SbiForStack* 
SbiRuntime::FindForStackItemForCollection( class BasicCollection* p

 {
 SbxVariable* pVar = p-refEnd.Is() ? (SbxVariable*)p-refEnd : 
NULL;

 if( p-eForType == FOR_EACH_COLLECTION  pVar != NULL 
-(pCollection = PTR_CAST(BasicCollection,pVar)) == pCollection )
+(pCollection = PTR_CAST(BasicCollection,pVar)) != NULL)
 {
 pRet = p;
 break;

I think pCollection must be tested against NULL but perhaps it needs 
something else.


Of course, if you're ok, I can commit and push on master.

Julien.
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] Warning in basic/source/runtime/runtime.cxx

2011-05-29 Thread Julien Nabet

Le 29/05/2011 14:47, Julien Nabet a écrit :
I think pCollection must be tested against NULL but perhaps it needs 
something else.


Of course, if you're ok, I can commit and push on master.


I forgot to tell 2 things :
- I talked about it in IRC yesterday but if the pb of undefined 
behavior is more clear now for me (thank you Norbert ! :-)), the patch 
I mentionned in the previous message hasn't been confirmed.
- I saw that the method containing this warning, SbiForStack* 
SbiRuntime::FindForStackItemForCollection( class BasicCollection* 
pCollection ), has been included during the last merging by the commit 
b969af6f23727b21115dc9be9caa6bd5959f715b


Julien.
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice