Re: About idlc/source/idlccompile.cxx

2013-01-13 Thread Ruslan Kabatsayev
Hi,

On Sun, Jan 13, 2013 at 9:01 PM, julien2412  wrote:
> Hello,
>
> Taking a look at this cppcheck report:
> dlc/source/idlccompile.cxx
> 198 nullPointer error   Possible null pointer dereference: source - 
> otherwise
> it is redundant to check it against null.

Looks like a false-positive of cppcheck. source is checked against
null to determine whether to take stdin or source file as data source,
then at lines 198 & 207 pSource file handle is closed only if it had
been opened (which is done only for source==0). I don't see any way
there could be a null pointer dereference.
>
> I don't understand the function "sal_Bool copyFile(const OString* source,
> const OString& target)", above all this part:
> 192 while ( !feof(pSource) )
> 193 {
> 194 if ( (readSize = fread(pBuffer, 1, totalSize, pSource)) > 0
> && !ferror(pSource) )
> 195 {
> 196 if ( (fwrite(pBuffer, 1, readSize, pTarget)) != readSize
> || ferror(pTarget) )
> 197 {
> 198 if (source != 0) {
> 199 fclose(pSource);
> 200 }
> 201 fclose(pTarget);
> 202 return sal_False;
> 203 }
> 204 }
> 205 }
> see
> http://opengrok.libreoffice.org/xref/core/idlc/source/idlccompile.cxx#173
> Isn't it overcomplicated? Why reading a file 1 per 1 byte for example?

It's not reading 1 byte at a time. It's reading totalSize bytes at a
time, getting readSize with 1 byte granularity.

>
> Julien
>
>
>
> --
> View this message in context: 
> http://nabble.documentfoundation.org/About-idlc-source-idlccompile-cxx-tp4028889.html
> Sent from the Dev mailing list archive at Nabble.com.
> ___
> LibreOffice mailing list
> LibreOffice@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/libreoffice

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


About idlc/source/idlccompile.cxx

2013-01-13 Thread julien2412
Hello,

Taking a look at this cppcheck report:
dlc/source/idlccompile.cxx
198 nullPointer error   Possible null pointer dereference: source - 
otherwise
it is redundant to check it against null.

I don't understand the function "sal_Bool copyFile(const OString* source,
const OString& target)", above all this part:
192 while ( !feof(pSource) )
193 {
194 if ( (readSize = fread(pBuffer, 1, totalSize, pSource)) > 0
&& !ferror(pSource) )
195 {
196 if ( (fwrite(pBuffer, 1, readSize, pTarget)) != readSize
|| ferror(pTarget) )
197 {
198 if (source != 0) {
199 fclose(pSource);
200 }
201 fclose(pTarget);
202 return sal_False;
203 }
204 }
205 }
see
http://opengrok.libreoffice.org/xref/core/idlc/source/idlccompile.cxx#173
Isn't it overcomplicated? Why reading a file 1 per 1 byte for example?

Julien



--
View this message in context: 
http://nabble.documentfoundation.org/About-idlc-source-idlccompile-cxx-tp4028889.html
Sent from the Dev mailing list archive at Nabble.com.
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice