On 2/2/09, Roger Binns <rog...@rogerbinns.com> wrote:
>  Maurí­cio wrote:
>  > I know this is not a problem, but I would like to
>  > remove this warning since it's not important for
>  > the rest of the code. What could I do?
>
>
> The usual method is to cast the result to (void) but gcc still whines.
>  I suggest you just live with it.  With many people reporting warning
>  issues the assumption seems to be that somehow the compiler is reporting
>  an important insight that the developers missed and could cause SQLite
>  to trivially malfunction.  The opposite is actually true - SQLite
>  functions just fine and the compilers are making mistaken claims.
>  Consider those warnings pointing out an inadequacy in the compiler and
>  get the compiler people to fix their program!
>
>   http://sqlite.org/testing.html
>

I would hope the "usual method" would be to check the return value of
the write call to make sure that it actually wrote. Looking at the
file in question, a later pwrite() call correctly checks the return
value to see if it is negative (indicating an error), and also checks
to see if fewer bytes were written than was requested. So why should
this write() be different? The comment doesn't seem to indicate why we
can assume this particular write() will always succeed, or why we
don't care if it doesn't. The testing page you linked to suggests that
sqlite is tested under full-disk conditions, which is somewhat
reassuring, though without digging into the testing internals too
significantly I am not convinced that we could have a case where a
disk fills up just before the write() call, causing it to fail to
write the one byte and forcing the inode returned by fstat() to be the
bizarre 99999 thing again. Can you explain why that shouldn't be a
concern? If so, it would be nice to comment that in the source.

Also, if you truly believe the unused result warning to be an error,
you would want to take it up with your libc maintainers, not the
compiler maintainers. The __warn_unused_result gcc attribute is a
useful facility - I think you're just questioning its use in the
write() call in libc.

-Mike
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to